フィルターのクリア

Region Growing algorithm not working properly

3 ビュー (過去 30 日間)
Warid Islam
Warid Islam 2022 年 10 月 6 日
コメント済み: Warid Islam 2022 年 10 月 7 日
I am implementing the region growing segmentation of 'ZhengGuoJin_03_0098_0180.png'. The segmentation result should look like 'seg.png', where the segmented region should be the region inside the red boundary. However, my segmentation result displays a completely black image. I think there might be leakage in my region growing algorithm although I am not sure about that. I have implemented the following lines of code.
l=imread('ZhengGuoJin_03_0098_0180.png');
figure,imshow(l)
grayImage = min(l, [], 3);
binaryImage = grayImage < 200;
binaryImage = bwareafilt(binaryImage, 1);
[rows, columns] = find(binaryImage);
row1 = min(rows);
row2 = max(rows);
col1 = min(columns);
col2 = max(columns);
% Crop
croppedImage = l(row1:row2, col1:col2, :);
figure,imshow(croppedImage)
croppedImage=rgb2gray(croppedImage);
boundaries = bwboundaries(croppedImage);
[xu, yu] = ginput(1);
minDistance = inf;
for k = 1 : numel(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
distances = sqrt((x - xu).^2 + (y - yu).^2);
thisMinDistance = min(distances)
% If this one is the closest, log it.
if thisMinDistance < minDistance
minDistance = thisMinDistance;
selectedIndex = k;
end
end
fprintf('You chose boundary #%d.\n', selectedIndex);
% Highlight the one they picked.
thisBoundary = boundaries{selectedIndex};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
hold on;
plot(x, y, 'm-', 'LineWidth', 2);
% x=256;y=256;
[x,y]=getpts;x=round(x);y=round(y);
a=imgaussfilt(croppedImage,2);
% a=rgb2gray(a);
b=adapthisteq(a);
m=regiongrowing_MLT(b,x,y,12);
m=imfill(m,'holes');
bw=imbinarize(m);
bw=bwareafilt(bw,1);
seg = region_seg(m, bw, 30);
figure, imshow(seg)
seg1=double(croppedImage).*double(seg);
figure, imshow(seg1)
img_class=class(l);
fill=cast(seg1,img_class);
figure, imshow(fill)

採用された回答

Image Analyst
Image Analyst 2022 年 10 月 6 日
Try this
imshow(seg1, [])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by