Threshold image colors – Base64

I would like to use threshold filter on base64 string (data:image/png;base64,iVBOR…) using javaScript like this: function threshold(base64) { some action whith base64 string… return …