how to access each superpixel individually?

1 次查看(过去 30 天)
Ad
Ad 2017-4-13
评论: Ad 2017-4-17
I have followed the procedure and really impressed by the work https://in.mathworks.com/help/images/ref/superpixels.html?s_tid=srchtitle. My question is how to access each superpixel individually like a regular pixel because I would like to perform certain operations on each pixel individually.

回答(1 个)

Guillaume
Guillaume 2017-4-13
The thing is that despite the name, a superpixel is nothing like a pixel. It's not square, it's just an arbitrarily shaped region of the image that has been determined to be similar.
You can mask the original image to keep only the portion corresponding to a given superpixel with:
%L = superpixels(originalimage, N);
originalimage(L == superpixelindex)
And certainly you can perform operations on that portion of the image. You could also use regionprops to extract the list of pixel indices belonging to each superpixel:
regionprops(L, 'PixelList')
but there's no way to get an individual superpixel value the same way you can a single pixel value.
  6 个评论
Image Analyst
Image Analyst 2017-4-15
Guillaume - you're right. I was looking at the last "outputImage" in the help demo where the super pixels have been replaced by the mean value, but the original superpixels is basically just a description of where the various ROI outlines are - a boundaryMask. If you applied that to the original image it's possible to get a whole range of colors or gray levels instead of a single one.
Ad, I have no idea. If you have 200 superpixels, then the max value of L should be 200 and the number of elements of allIntensities should also be 200. What is the max value of L for you?
Your variables are badly named. What is I? Is that the labeled image or the original image? Don't just call it I - that's a really lousy name. And what's the point of S? You can get both MeanIntensity and PixelList all in the same call to regionprops() if you really think you need PixelList (though I'm not convinced you do because you have the labeled image which is better in most cases).
Ad
Ad 2017-4-17
Hello! I have changed the code and calculated
[L,N] = superpixels(I,50);
lprops = regionprops(L,I(:,:,1),'MeanIntensity','PixelValues','PixelList');
L1 region MeanIntensity=65.0496
Lend region MeanIntensity=38.0527
original image=291*400
L=Labelled image=291*400; 50 superpixels;pixelindexlist 1*45;S value 45*1 PixelList values.
Q1.How to merge S1 and S2 if they are similar?
Q2. How to get best weighted threshold for an LAB image? for example R*0.299+G*0.587+B*0.114 where green is dominant color ..
Thank you so much for your answers

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by