How do I find how many pixels in an image has a specific colour in React.js

Viewed 25

Assuming I have an image, how do i loop over the pixels of that image to get the number of pixels with a particular color for example black. I have tried canvas but did not work in react for some reason. What is the best way to do this in react, Is there a package I can maybe use for this purpose ? I am a beginner to these image processing stuff.

1 Answers

Actually, there is such a possibility in Canvas if it were installed correctly in React.JS (which you can do)

Follow this link for proper implementation and installation

CANVAS on medium.com

For read a single x,y pixel of pictures you can do (so yes, you can iterate and check if the color match):

var pixelX_Y = canvas.getContext('2d').getImageData(X, Y, 1, 1).data;
Related