MATLAB: What do I get by calling ‘PixelIdxList’

image processingImage Processing Toolboximage segmentation

Hi! I recently using 'PixelIdxList' in the 'regionprop' function to calculate the color of the particle I labeled. But I don't really understand what color that 'PixelIdxList' gives?
I mean, I extract the 'PixelIdxList' from a RGB image, and calculate the mean value of pixels. But as we know, RGB image has red, green and blue in its array. When I calculate the mean(PixelIdxList) in an RGB image, I only get one value. So what colour does this mean value present?
My goal is to generate the mean grey value from the RGB image. Can I use this mean value from PixelIdxList?
Thank you!

Best Answer

PixelIDxList does not give any image value. PixelIDxList gives array locations.
R = original_image(:,:,1);
G = original_image(:,:,2);
B = original_image(:,:,3);
blobinfo = regionprops(BWorLabeledImage, 'PixelIdxList');
one_idxlist = blobinfo(1).PixelIdxList;
R_in_region = R(one_idxlist);
G_in_region = G(one_idxlist);
B_in_region = B(one_idxlist);
mean_R_in_region = mean(R_in_region);
mean_G_in_region = mean(G_in_region);
mean_B_in_region = mean(B_in_region);