I am getting an error while running regionprops. How?
Mostrar comentarios más antiguos
[L,N] = superpixels(I,50);% superpixels=44
props = regionprops(L,'MeanIntensity','PixelValues','PixelList','PixelIdxList');
I am getting this error."REGIONPROPS needs I as an input to calculate 'MeanIntensity'".
Thankyou
Respuestas (2)
Image Analyst
el 19 de Abr. de 2017
0 votos
You need to pass in the original image. You can't just pass in the labeled image. If you want the mean intensity of regions in an image, of course you need to pass in the image itself. The labeled image L merely tells where the regions are in the original image. You have to pass in the image itself as the second argument if you want to measure its intensities in those regions.
13 comentarios
Ad
el 19 de Abr. de 2017
Image Analyst
el 19 de Abr. de 2017
Yes, you have to pass in each color channel separately, not a 3-D RGB or LAB or HSV image. Like
L_Image = labImage(:, :, 1); % Extract the L channel.
props = regionprops(L, L_Image,'MeanIntensity','.......
Note, you used:
[L,N] = superpixels(I.......
following the Mathworks example of using crummy variable names. So I think you got confused between that L and the L of LAB color space. Be careful. The badly named L returned from superpixels is actually a labeled image, not the L color space image. It would be better to use descriptive variable names like
[labeledImage, numberOfLabels] = superpixels(.....
labImage = rgb2lab(rgbImage);
L_Image = labImage(:, :, 1); % Extract the L channel only.
A_Image = labImage(:, :, 2); % Extract the A channel only.
B_Image = labImage(:, :, 3); % Extract the B channel only.
propsL = regionprops(labeledImage, L_Image,'MeanIntensity','.......
propsA = regionprops(labeledImage, A_Image,'MeanIntensity','.......
propsB = regionprops(labeledImage, B_Image,'MeanIntensity','.......
Now you can get the mean value of each superpixel in each of the L, A, and B color channels.
Image Analyst
el 20 de Abr. de 2017
That is not right. Summing A and B into L would make no physical sense whatsoever and I recommend you don't do it so I'm not going to tell you how. It would be like describing a person by adding together their weight and height and age. It just doesn't make sense.
Ad
el 22 de Abr. de 2017
Image Analyst
el 22 de Abr. de 2017
Yes, you can do that. That is computing the Delta E color difference. It's doing the square root of the sum of the squares of differences between L, a, and b, and that is valid, whereas just summing an L, a, and b by themselves is not valid.
Ad
el 22 de Abr. de 2017
Editada: Walter Roberson
el 22 de Abr. de 2017
Walter Roberson
el 22 de Abr. de 2017
You could take max(), min(), mean(), median(), or some kind of weighted average.
What reason did you have for calculating the distance matrix?
Image Analyst
el 22 de Abr. de 2017
Editada: Image Analyst
el 22 de Abr. de 2017
I don't even know what "How to convert superpixel properties to individual pixel properties?" means. And what is that matrix? Is that from pdist2() where you passed in the LAB values of all the superpixels, like
distances = pdist2(labValues, labValues);
If so, then the array contains the delta E (color difference) between every superpixel and every other superpixel. Not sure what you want to do after that because I totally don't understand your last sentence/question. You have the original value and know the locations (row, column) and color value of every individual pixel inside each superpixel, but I really don't know what you mean by "individual pixel properties" and how you'd get those from superpixels.
Superpixels are an aggregation of pixels into similar adjacent groupings. You always still have the original image so if you want something from the original image, just use it. You can't go backwards without the original image. It would be like saying I have the mean of the entire image, now tell me the gray level of all the individual pixels. You just can't do that.
Ad
el 23 de Abr. de 2017
Walter Roberson
el 23 de Abr. de 2017
If the color distance between P1 and P2 is "low", and the color distance between P2 and P3 is "low", but the color distance between P1 and P3 is not "low", then how do you want to handle the situation?
Ad
el 23 de Abr. de 2017
Walter Roberson
el 19 de Abr. de 2017
0 votos
You are passing in a label matrix but asking for mean intensity. In order to do both at the same time you need to pass the intensity matrix as well. If I recall correctly you would pass it as the second argument.
1 comentario
Ad
el 19 de Abr. de 2017
Categorías
Más información sobre Image Segmentation en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


