Home To find mean of image using .PixelValues in regionprops using matlab

# To find mean of image using .PixelValues in regionprops using matlab

Silpa
1#
Silpa Published in 2018-02-13 05:10:45Z
 I am trying to find out mean,kurtosis,skew etc of different connected regions seperately. May I found it using .PixelValue command using following code? or .PixelValue command to be used? Please help me.This is my first work.Please correct my code to find mean. % Out is my region of interest output image. [val num]=bwlabel(Out); STATS=regionprops(val,'All'); for i=1:num kk=STATS(i); kk1=kk.PixelList; % To find mean [r c]=size(kk1); ax(i)=r*c; pp(i)=sum(sum(kk1)); bx(i)=pp(i)/su; mean=bx(i); end 
Cris Luengo
2#
Cris Luengo Reply to 2018-02-15 14:27:27Z
 If you want to compute the mean of the pixel values of a within connected components of Out, then you want to do as follows (assuming a is a grey-value image): lab = bwlabel(Out); stats = regionprops(lab,a,'PixelValues');  and then, for each stats.PixelValues, compute the mean: m = zeros(size(stats)) for ii = 1:numel(stats); m(ii) = mean(stats(ii).PixelValues); end  or more simply: m = cellfun(@mean,{stats.PixelValues})  Note that regionprops can be called with a second input image, which contains the grey values. The 'PixelValues' property is a list with pixel values for each connected component. To further simplify the code, you can skip calling bwlabel, and directly pass the binary image to regionprops: stats = regionprops(Out,a,'PixelValues'); 
bla
3#
bla Reply to 2018-02-13 10:29:22Z
 you can just do: for i=1:numel(STATS); ms(i)=mean(Out(STATS(i).PixelIdxList)); end  a few comments: PixelIdxList is the linear index of the array you want, so just one number, no need for x,y. read about it here . dont call mean as a variable name it's a built in function.
 You need to login account before you can post.
Processed in 0.330147 second(s) , Gzip On .