problem of take out ROI while use Superpixels

1 vue (au cours des 30 derniers jours)
hajer jon
hajer jon le 23 Oct 2019
Commenté : Uma Sharma le 14 Juil 2022
Hi
i wrote code that select ROI then devide image to patches then appaly superpixels but the superpixels results show that non ROI is calcute superpixels on it how can i let not take the non ROI while counting???
I3=read(v,1);
BW = roipoly(I3);
for t=1:4
imca=im2patch{t}
figure;imshow(imca);
t=t+1;
[Lce,N] = superpixels(imca,500);
BWL1 = boundarymask(Lce);
masimg1=imoverlay(imca,BWL1);
figure;imshow(masimg1);
end;roiandsuperpicels.jpg

Réponses (1)

Subhadeep Koley
Subhadeep Koley le 10 Jan 2020
Hi, you are getting such output because you are applying super-pixel over segmentation on the whole image. You can use the function roifilt2 to apply your filtering only to the ROI. Refer the code below.
I = imread('peppers.png');
BW = roipoly(I);
imshow(BW);
% Create function handle
f = @(x)superpixels(x,500);
% Apply 2-D superpixel oversegmentation on the ROI
if size(I, 3) == 3
J = roifilt2(rgb2gray(I), BW, f);
else
J = roifilt2(I, BW, f);
end
% Create the mask
mask = boundarymask(J, 8);
% Overlay the mask above the image
figure;imshow(labeloverlay(I, mask, 'Transparency', 0.3, 'Colormap', 'parula'));
SLIC.png
Hope this helps!
  1 commentaire
Uma Sharma
Uma Sharma le 14 Juil 2022
Hi,
This response was very helpful! Using the function handle, how can I get the label and numIterations data from the superpixel function for the superpixels in the ROI? Please let me know if there are any solutions to this.

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by