# Image processing and contour detection

98 vues (au cours des 30 derniers jours)
KATHAN BHAVSAR le 12 Avr 2023
With respect to the image below, how can I detect the the upper (red) and lower (green) contour on the boundaries shown n the image below. Also, how do I calculate the distance between the two boundaries (blue)?
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponse acceptée

Sachin le 14 Avr 2023
Hi
I understand that you want to find the contours in the image.
I suggest you to use Image processing and Computer Vision Toolbox. The toolbox provides two functions -
1. ‘bwboundaries' – This function is used to compute the boundary of a binary image . It takes a binary image as input and computes the boundary of the connected region in the binary image
2. ‘bwtraceboundary’ – This function is used to trace a boundary in a binary image.It takes a binary image as input and a starting point on the boundary and trace the boundary of the connected region in the image.
These function provides boundary coordinates that can be used find the distance between two points
grayImage = rgb2gray(image);
threshold = 50; % Set threshold value
binaryImage = grayImage > threshold;
boundaries = bwboundaries(binaryImage);
imshow(image);
hold on;
for k = 1:length(boundaries)
boundary = boundaries{k};
plot(boundary(:,2), boundary(:,1), 'b', 'LineWidth', 2);
end
If you encounter any issues with these functions, you can also use OpenCV library to find contours.
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
KATHAN BHAVSAR le 15 Avr 2023
Thank you, I will certainly try this out.

Connectez-vous pour commenter.

### Plus de réponses (1)

Image Analyst le 15 Avr 2023
To find average width of a blob, see attached demo.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!

Translated by