Finding adjacent superpixels in an image
Show older comments
After segmenting an image into N superpixels, I need to specify the superpixels that are adjacent to a superpixel.
[L,NumLabels] = superpixels(A,200);
How can I specify the adjacent superpixels for each of superpixels?
B=imread('H.jpg');
[L,N] = superpixels(B,200);
glcms=graycomatrix(L);
kkkk=glcms(:,50); %SupNum=50
[rrrr,~]=find(kkkk>0);
aa=find(rrrr==50);
rrrr(aa)=[];

How it could be fixed or any working solution ?
Answers (1)
Image Analyst
on 10 Mar 2019
Edited: Image Analyst
on 10 Mar 2019
glcms is an 8 by 8 matrix. It does not have a fiftieth column. Not sure what you're thinking, so not sure how to fix it. What superpixel (what label number) are you hoping to find neighboring superpixels of?
rgbImage=imread('H.jpg');
subplot(2, 1, 1);
imshow(rgbImage);
axis('on', 'image');
title('Original Image', 'FontSize', 18);
[labeledImage, N] = superpixels(rgbImage,200);
subplot(2, 1, 2);
imshow(labeledImage, []);
axis('on', 'image');
title('Labeled Image', 'FontSize', 18);
% Nonsense after this:
glcms=graycomatrix(labeledImage);
kkkk=glcms(:,50); %SupNum=50
[rrrr,~]=find(kkkk>0);
aa=find(rrrr==50);
rrrr(aa)=[];

1 Comment
Nazir Shanbe
on 11 Mar 2019
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!