problem of take out ROI while use Superpixels

3 visualizzazioni (ultimi 30 giorni)
hajer jon
hajer jon il 23 Ott 2019
Commentato: Uma Sharma il 14 Lug 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

Risposte (1)

Subhadeep Koley
Subhadeep Koley il 10 Gen 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 Commento
Uma Sharma
Uma Sharma il 14 Lug 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.

Accedi per commentare.

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by