Finding the mean and standard deviation

I is an rgb image
d = unique(I);
out = [];
for jj = 1:numel(d)
r = bwconncomp(I == d(jj),4);
out = [out;[repmat({d(jj)},r.NumObjects,1) r.PixelIdxList']];
end
and i get output as(below is example some part of output)
[ 44] [ 1x3 double]
[ 46] [ 1x3 double]
[ 19] [ 1x3 double]
[ 44] [ 1x3 double]
[ 20] [ 1x3 double]
[ 43] [ 1x3 double]
[ 19] [ 1x3 double]
[ 39] [ 1x3 double]
[ 41] [ 1x3 double]
[ 20] [ 1x3 double]
[ 40] [ 1x3 double]
[ 41] [ 1x3 double]
[ 21] [ 1x3 double]
[ 42] [ 1x3 double]
for each block i have to find the mean and standard deviation ,please help

Answers (1)

Post this as a follow up to the original question at http://www.mathworks.com/matlabcentral/answers/46552-grouping-the-pixel-having-same-values I don't even know what you mean by the mean. Each "block" has the value d(jj) so that's the mean, and of course the std dev would be zero.

3 Comments

I dont want o make that thread complicated ,thats posted a new question twice ,my output must be as
A rgb image as input and then divide the pixels having same value into blocks (have to display the image) and then find the meana nd standard deviation for each block
In the above for each block i tries using
meanValues = cellfun(@(x) mean(x(:)),out(:,2))
but dontknow if it is correct or not,please help
Again, since each block is a unique color, the mean color should be that color and the SD should be zero. Isn't that right?
for example
I=imread('rice.png');
C = mat2cell(I,[128 128],[128 128]);
meanValues = cellfun(@(x) mean(x(:)),C)
meanValues =
131.3774 129.7532
94.9357 88.9209
so for each block i get mean values ,is it possible to do the same for my problem

Sign in to comment.

Asked:

on 30 Aug 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!