Effacer les filtres
Effacer les filtres

How can I detect line lies between two certain regions?

2 vues (au cours des 30 derniers jours)
faten Ahmed
faten Ahmed le 17 Mar 2020
Commenté : Image Analyst le 18 Mar 2020
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

Réponse acceptée

Image Analyst
Image Analyst le 17 Mar 2020
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 commentaires
faten Ahmed
faten Ahmed le 17 Mar 2020
Modifié(e) : faten Ahmed le 18 Mar 2020
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 le 18 Mar 2020
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, []);

Connectez-vous pour commenter.

Plus de réponses (1)

darova
darova le 17 Mar 2020
  • imbinarize image
  • use bwareaopen to clear a bit
  • use edge

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by