JavaScript pixel processing

Problem: thresholding an image using a HTML5 2D canvas. It's a really simple problem, but if implemented wrong it can lead to really bad performance. Original (right. credits greyamoon) and thresholded transparent image (left). Live demo on JSFiddle.My initial idea was to make a function everyPixel(ctx, f) that…