Using Matlab 2012, I want to count the number of pixels in certain portions of image so i try the following code which give error at sum(sum ) function . could any one help me ? or is there another solution to get the number of pixels within certain coordinates rather than this code:
clear sumclear allclose allimage=imread('Headers-29.jpg');image=im2bw(image,graythresh(image)); %binarization
image=imcomplement(image);[m n]=size(image);X_segmented=[];Y_segmented=[];Width_segmented=[];Hight_segmented=[];cropped_segmented={};Bounding=regionprops( image, 'BoundingBox'); % Minimum x-y coordinates of a block and its x, y lengths
for g=1:length(Bounding) X_segmented(g,1)=Bounding(g).BoundingBox(1); Y_segmented(g,1)=Bounding(g).BoundingBox(2); Width_segmented(g,1)=Bounding(g).BoundingBox(3); Hight_segmented(g,1)=Bounding(g).BoundingBox(4); x_Plus(g,1)=X_segmented(g)+Width_segmented(g); y_plus(g,1)=Y_segmented(g)+Hight_segmented(g); bvv(g,:)=[X_segmented(g,1) x_Plus(g,1) Y_segmented(g,1) y_plus(g,1)]; endfor g=1:size(bvv,1) sumnn(g,:)=sum(sum( image(bvv(g,1): bvv(g,2) , bvv(g,3):bvv(g,4))));endend
Best Answer