how to find size of scale bar on image

25 次查看(过去 30 天)
I have converted the image I've attatched into matrix form, but I'm wondering is there away to go through each pixel of the image until the first black pixel (eg the first black pixel on the scale bar and the last black pixel on the scale bar) is detected? I'm trying to work out the length of the scale bar in pixels. I'm really new to MATLAB so if anyone could help/explain It would really help me out.

回答(1 个)

Alex Mcaulley
Alex Mcaulley 2020-1-10
One approach would be:
  1. First, you need to segment the scale bar using any segmentation function, for example imbinarize (using a small threshold)
  2. Then, using regionprops (with the inverted mask, ~BW)you can obtain the length of the segmented objects using the property 'MajorAxisLength'. If the threshold is good enough, the object with the maximum length should be your scale bar.

Community Treasure Hunt

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

Start Hunting!

Translated by