what do I get by calling 'PixelIdxList'?

9 visualizaciones (últimos 30 días)
Ziming Zhong
Ziming Zhong el 4 de Nov. de 2017
Comentada: DGM el 4 de Dic. de 2022
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!
  3 comentarios
Walter Roberson
Walter Roberson el 28 de Mayo de 2018
Approximate translation:
Good evening please how I can convert the pixels of stats (i) .area to image in matlab for example I have the result as follows cc # 1 - area 202965 nuemoro of pixel and size I like the poster in a binary image
Image Analyst
Image Analyst el 28 de Mayo de 2018
marwa, you can't convert an area (a single scalar), or a list of pixel values in an irregularly-shaped blob, into an image - you need more than that. See my Image Segmentation Tutorial to see how you can crop out the regions from the image into sub-images using the bounding box from regionprops(), and imcrop(). Start your own question with your own image if you need more help.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 4 de Nov. de 2017
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);
  14 comentarios
Walter Roberson
Walter Roberson el 4 de Dic. de 2022
selectedpixels = A(idxpage+prod(sz(1:2))*(0:sz(3)-1))
That is the kind of calculation done by sub2ind and ind2sub
DGM
DGM el 4 de Dic. de 2022
Augh. I was thinking too much about addressing pagewise.
I don't have time to fix it now.

Iniciar sesión para comentar.

Más respuestas (1)

Image Analyst
Image Analyst el 4 de Nov. de 2017
PixelIdxList is the linear index of pixels in the blob.
From what you say, it appears you want the PixelValues measurement instead.
  4 comentarios
Ziming Zhong
Ziming Zhong el 5 de Nov. de 2017
Editada: Ziming Zhong el 5 de Nov. de 2017
Ah! So I guess I just understood it wrong but I wrote the code right. I wrote the code for extracting the color value as what you did on the blog, like mean(mypicture(idx)). So this mean intensity in RGB picture is the mean for three colors. Do I understand correct?
Image Analyst
Image Analyst el 6 de Nov. de 2017
No. You wrote the code incorrectly. See Walter's answer for the correct version. Again, your code is not correct.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by