MATLAB Answers

how to find size of scale bar on image

8 views (last 30 days)
Xanm ft
Xanm ft on 10 Jan 2020
Answered: Alex Mcaulley on 10 Jan 2020
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.

  0 Comments

Sign in to comment.

Answers (1)

Alex Mcaulley
Alex Mcaulley on 10 Jan 2020
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.

  0 Comments

Sign in to comment.

Sign in to answer this question.