JordanPainter Painter
2010-04-13 13:18:05 UTC
Hiya, I'm trying to set a threshold to reduce my values to 1's and 0's then get a total of these 0's and 1's so i can work out a ratio of black to white? My image is a a large jpeg file.
I've tried this so far:
im = 'image.jpg';
im = uint8(im);
level = graythresh(im);
BW = im2bw(im,level);
x = imread(BW);
blackcount = sum(BW(1,:))
whitecount = sum(BW(:,1))
I used the sum code at the bottom for just the standard image but it only pulled up the completely white and completely black pixels i think. So i added the threshold but i can't get it to work. Any help is welcome, thanks a lot!
I've tried this so far:
im = 'image.jpg';
im = uint8(im);
level = graythresh(im);
BW = im2bw(im,level);
x = imread(BW);
blackcount = sum(BW(1,:))
whitecount = sum(BW(:,1))
I used the sum code at the bottom for just the standard image but it only pulled up the completely white and completely black pixels i think. So i added the threshold but i can't get it to work. Any help is welcome, thanks a lot!