Measure the distance of a curve within an image
12 views (last 30 days)
Show older comments
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.
0 Comments
Answers (2)
Benjamin Thompson
on 25 Jan 2022
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.
0 Comments
Image Analyst
on 25 Jan 2022
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);
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!