# Highlighting the contour of a specific region and its lowest end points.

2 vues (au cours des 30 derniers jours)
Anjan Goswami le 16 Mai 2020
I have to plot the contour of an specific area of the attached 'InputImage.png' as shown by green countour in the attached 'sample...png'. I wanted to use bwtraceboundary() but I couldn't manage to determine the row and column coordinates of a pixel on the border. If I sort the biggest area, then is it possible to show the contour of that area?
Also, I have to highlight the two endpoints at the base as shown in the 'sample...png'. How can it be done?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Anjan Goswami le 16 Mai 2020
I have solved the problem. The code is as below:
%get the row number of the lowest white pixels
lowestRow = find(sum(crownAndSecondaryDroplet, 2)>0, 1, 'last'); % Bottom white row of the image
hp = impixelinfo(); %to check the output of the lowest row
%find the column numbers of the lowest row
colummsOfLowestRow= find(crownAndSecondaryDroplet(lowestRow,:)==1);
%find the x value for the leftmost and the rightmost pixels of the lowest row
lowestLeftXvalue = min(colummsOfLowestRow);
lowestRightXvalue = max(colummsOfLowestRow);
%get the boundary of the contour
boundary = bwtraceboundary(crownAndSecondaryDroplet,[lowestRow, lowestLeftXvalue],'N');
%display the image
figure, imshow(crownAndSecondaryDroplet, []);
title('Image with Rim Contour', 'FontSize', fontSize, 'Interpreter', 'None');
axis on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
hold on;
%plot the contour and lowest end points
plot(boundary(:,2),boundary(:,1),'g','LineWidth',2);
plot(lowestLeftXvalue , lowestRow, 'r+', 'LineWidth', 3, 'MarkerSize', 20 );
plot(lowestRightXvalue , lowestRow, 'r+', 'LineWidth', 3, 'MarkerSize', 20 );
hold off;
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!

Translated by