how to find size of scale bar on image

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.

Answers (1)

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.

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 10 Jan 2020

Answered:

on 10 Jan 2020

Community Treasure Hunt

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

Start Hunting!