can anybody explain regionprops with superpixels?
Show older comments
I have generated 200 superpixels and used S=regionprops(L,'pixelList'); I got S= 196*1 struct value. How to access them and how do I know which one is column or row? help me is idx=label2idx(L); idx{i} helpful to access superpixel region?
Answers (1)
Image Analyst
on 15 Apr 2017
1 vote
With superpixels, row and column don't really have any meaning, do they? So don't think like that. You need to think about what you really want to do with the superpixels, or even if superpixels are what you really should be doing in the first place to process your image. Post your image and tell us what you want to do with it (like what you need to measure), and explain why you think superpixels is the best approach to accomplishing that. Maybe it is, but maybe it isn't - I don't know yet.
10 Comments
Ad
on 16 Apr 2017
Image Analyst
on 16 Apr 2017
Convert to LAB color space, then get the mean LAB intensities of all the regions with regionprops().
Then pass that in for both arguments of pdist2() (in the Statistics and Machine Learning Toolbox) to get the Delta E (the color difference) between every superpixel and every other superpixel. Off the top of my head I don't know how to determine which superpixel region is next to (adjacent) to another superpixel region.
Ad
on 17 Apr 2017
Image Analyst
on 17 Apr 2017
You can use brackets to extract all the MeanIntensities you get from regionprops into a single vector:
props = regionprops(labeledImage, LImage, 'MeanIntensity');
allLValues = [props.MeanIntensity]; % Extract from structure into array.
Do the same for the A image and the B image.
Ad
on 17 Apr 2017
Edited: Image Analyst
on 17 Apr 2017
Image Analyst
on 17 Apr 2017
Your first superpixel region has 1515 pixels in it. To get all the mean L values, you'd do
allLValues = [props.MeanIntensity]; % Extract from structure into array.
meanLValue = mean(allLValues);
Be careful with that though, because the superpixels may have different number of pixels in them so the mean as I showed above is not weighted by the area of each superpixel region. If you want the mean of the whole image, you can simply use mean2():
meanLOfWholeImage = mean2(I:,:,1);
meanAOfWholeImage = mean2(I:,:,2);
meanBOfWholeImage = mean2(I:,:,3);
I don't really know what it means to have the pixels lists of the whole image. Each superpixel will have a list of pixels in it. For the whole image, the pixel list will essentially just be every pixel in the whole image. If you want to access individual superpixel pixellists, you could do
for k = 1 : length(lprops)
thisPixelList = lprops(k).PixelList; % No need to repeat for aprops and b props since they're the same pixel coordinates.
thisPixelValuesL = lprops(k).PixelValues;
thisPixelValuesA = aprops(k).PixelValues;
thisPixelValuesB = bprops(k).PixelValues;
end
Image Analyst
on 19 Apr 2017
I don't have any code for you. I suggest you follow the concepts of region growing here: https://en.wikipedia.org/wiki/Region_growing
Ad
on 20 Apr 2017
Categories
Find more on Image Segmentation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!