フィルターのクリア

How can I detect line lies between two certain regions?

2 ビュー (過去 30 日間)
faten Ahmed
faten Ahmed 2020 年 3 月 17 日
コメント済み: Image Analyst 2020 年 3 月 18 日
I have matrix I and I want to detect and coloring the line ( or thin region) which has DN (4) and located between the region which has DN (0) and the region which has DN (3).
I =
0 0 0 0 4 4 3 3
0 0 0 4 4 3 3 2
0 0 4 4 3 2 2 2
0 4 4 3 3 2 2 3

採用された回答

Image Analyst
Image Analyst 2020 年 3 月 17 日
Simply use
coloredLabels = label2rgb (I, 'hsv', 'k', 'shuffle'); % pseudo random color labels
Here is a full demo:
I =[...
0 0 0 0 4 4 3 3
0 0 0 4 4 3 3 2
0 0 4 4 3 2 2 2
0 4 4 3 3 2 2 3]
hFig = figure;
subplot(2, 1, 1);
imshow(I, [], 'InitialMagnification', 1600);
fontSize = 16;
title('I', 'FontSize', fontSize);
% colorize the matrix
coloredLabels = label2rgb (I, 'hsv', 'k', 'shuffle'); % pseudo random color labels
% coloredLabels is an RGB image. We could have applied a colormap instead.
subplot(2, 1, 2);
imshow(coloredLabels, 'InitialMagnification', 1600);
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Colorized I', 'FontSize', fontSize);
hp = impixelinfo; % Show color as use mouses around over image.
  4 件のコメント
faten Ahmed
faten Ahmed 2020 年 3 月 17 日
編集済み: faten Ahmed 2020 年 3 月 18 日
the previous image is the result, Thank you. But, I want the line only between the building roof (DN 3) and the black region (DN 0, it is the shadow of the building)
Note that, there are many lines have DN=4, but I wnat to detect the lines beside black region only.
Image Analyst
Image Analyst 2020 年 3 月 18 日
Take the 3 region and the 0 region and dilate one of them and then AND them. Something like (untested)
region3 = imdilate(labeledImage == 3, true(3));
borderImage = region3 & (labeledImage == 0);
imshow(borderImage, []);

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

その他の回答 (1 件)

darova
darova 2020 年 3 月 17 日
  • imbinarize image
  • use bwareaopen to clear a bit
  • use edge

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by