how to access each superpixel individually?
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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
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).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!