Measure the distance of a curve within an image

12 次查看(过去 30 天)
I am trying to learn how to take measurements of different aspects in an image. With the image provided, how would I measure the length of the curved blue line and the diameter of the green circle if the hight of the red box is 3 meters. I will post my code if I can actually get something working. Thank you.

回答(2 个)

Benjamin Thompson
Benjamin Thompson 2022-1-25
You could use imshow to load and display the image, then ginput get get a series of manually selected points on the line. If you have the image processing toolbox, imtool has a bit more image analysis capabilities, and colorThresholder can be used to create a blue color mask so you can get the list of pixels that are part of the blue line and then do further math on those pixels positions.

Image Analyst
Image Analyst 2022-1-25
I'd just get a mask of the blue line. Like
[r, g, b] = imsplit(rgbImage);
blueMask = r == 0 & g == 0 & b == 255;
or you can use the Color Thresholder app on the Apps tab of the tool ribbon.
If the line is known to be a single pixel wide then you can just count the number of non-zero pixels.
lineLength = nnz(blueMask);
If the line is thick, then you can get the skeleton image with bwskel first
blueMask = bwskel(blueMask);
lineLength = nnz(blueMask);

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by