Hello,
I have this 800×800 image and i want to count the number of black and white pixels in it. To do so i have read the image and divide it (the matrix) in 200×200 cells. But now i am with a bit of dificulty in making a scipt that can count B&W pixels in each cell and returns the values, something like this:
Cell(1,1)–> Black_pix=100; white_pix=300 Cell(1,2)–> Black_pix=100; white_pix=300
I already figured it out how to count B&W pixels in the entire image to do so, i've written the following script:
xmax=800; ymax=800; Image = imread('3080.jpg'); BW = im2bw(Image); BW1=double(BW); White_pix=0; Floc=0; for j=1:(xmax)-1 for i=1:(ymax)-1 if BW1(i,j)==0 White_pix=White_pix+1; else Black_pix=Black_pix+1; end end end
My problem is making this process for all of the cells created with "mat2cell" function. Any help would be appreciated!
Thanks
Fearing that my english was so bad that i didn't explain myself very well, i'm posting a small schematic of the paper sheet divided in smaller elements.
I need to have something like this:
Element 1 as 3000 black pixels and 4500 white pixels Element 2 as 4000 black pixels and 9800 white pixels …
Best Answer