- ‘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
- ‘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.
Image processing and contour detection
조회 수: 98 (최근 30일)
이전 댓글 표시
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
채택된 답변
Sachin
2023년 4월 14일
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 -
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.
Please refer the following page for more information about boundary function:
Please refer OpenCV documentation for more information on finding contours
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!