problem of take out ROI while use Superpixels

1 回表示 (過去 30 日間)
hajer jon
hajer jon 2019 年 10 月 23 日
コメント済み: Uma Sharma 2022 年 7 月 14 日
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

回答 (1 件)

Subhadeep Koley
Subhadeep Koley 2020 年 1 月 10 日
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 件のコメント
Uma Sharma
Uma Sharma 2022 年 7 月 14 日
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.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by