can anybody explain regionprops with superpixels?

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)

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

Hello! Thank you so much for your quick response. I am working upon salient object detection. Say, I have an image(for example, 300*400). I need to calculate the color distance between two pixels.I will preprocess the image with superpixels and calculate the distance between them so that we can eliminate unnecessary region and can reduce the search space. Then I need to calculate the probability of pixel whether it is 0 or 1.
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.
Thank you so much. I have calculated mean intensities for L, A,B colour spaces separately. How can I get single mean intensity vector for entire LAB image. How to create a mask for a superpixel region if it is less than certain threshold? Q2. How can I use my own distance method in dpist2()? Thanks in advance.
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.
I am so sorry I didn't get it. I have calculated for three channels (RGB to lab)
lprops = regionprops(L, I(:,:,1),'MeanIntensity','PixelValues','PixelList');
aprops = regionprops(L, I(:,:,2),'MeanIntensity','PixelValues','PixelList');
bprops = regionprops(L, I(:,:,3),'MeanIntensity','PixelValues','PixelList');
For first superpixel-Meanintensity-68.5098697306521 pixelvalue:1515x1 double; pixellist : 1515x2 double; pixelidx:1515x1 double. and so on for 44 superpixels as well as for 'a' channel and''b channel.
Q. How to calculate mean intensity, pixellists for the whole(lab) image?
Q. How to access pixellist in loop statements?
You are helping me a lot. Thanks in advance
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
I have calculated mean of LAB image with
meanlab=mean( reshape( I, [], 3 ), 1 );% got same values 41.28,5.84 16.08.
meanLOflabImage = mean2(I(:,:,1));%41.280
L1=68.50;L2=61.70:L3=40.65.
for i=1 : length(lprops)
LMI(i)=lprops(i).MeanIntensity;
if (LMI(1)-LMI(i))<5
Merge those SuperPixel regions if adjacent or assign mask % how to do that
else if
leave;
end
save them in a new L array.
Thanks in advance
Ad
Ad on 19 Apr 2017
Edited: Ad on 19 Apr 2017
please help me how to merge those superpixel regions.@Image Analyst
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
Thank you so much

Sign in to comment.

Asked:

Ad
on 15 Apr 2017

Commented:

Ad
on 20 Apr 2017

Community Treasure Hunt

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

Start Hunting!