jquery-grayscale
jquery-grayscale copied to clipboard
Improve performance of grayscale calculation steps
The grayscale calculation involving nested loops that check properties of the image on every loop are inefficient. On top of that, the extra calculation to determine the pixel position based on the interation of the nested loops adds more overhead
This can be collapsed into a single iterative loop, without an inner calculation. Considering this loop runs literally thousands of times on even a small image, simplification makes for a significant performance improvement.