how to access each superpixel individually?
이전 댓글 표시
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
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월 13일
편집: Image Analyst
2017년 4월 13일
Not so directly as the original image, but you can get the value of the superpixel if you pass in the labeled image, and the superpixel image, and ask regionprops() for 'MeanIntensity'.
props = regionprops(labeledImage, superPixelImage, 'MeanIntensity');
allIntensities = [props.MeanIntensity];
Note: superPixelImage is a grayscale image or one channel of an RGB image.
Guillaume
2017년 4월 13일
Well, as long as you consider the mean intensity as the value of a group of pixels.
Ad
2017년 4월 14일
Ad
2017년 4월 15일
편집: Image Analyst
2017년 4월 15일
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
2017년 4월 17일
카테고리
도움말 센터 및 File Exchange에서 Image Segmentation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!