2

This is similar to a question here But I couldn't use its solution. I'm working in Julia and I'm not sure how it works in this case. Here is an image I'm working on enter image description here

Due to the curve in line, and unsmooth edges, its not straightforward to get width 'd' of the line. I dont know how to find orthogonal line at each point and get distance d1,d2.. I plan to take its average later to get an estimate of line width. Any tips? Thanks

Royi
  • 4,640
  • 6
  • 46
  • 64
h612
  • 544
  • 2
  • 11
  • 1
    Compute the distance transform of the object, which gives you at each point the distance to the nearest background pixel. The skeleton goes along the ridge of the distance strand form, where the distance to two opposing edges is equal. Read the distance value at the skeleton pixels to get this distance, which is half the width. – Cris Luengo Jan 18 '23 at 02:18
  • @CrisLuengo Ok sorry I half understood, I've the distance transform via `dist = 1 .- distance_transform(feature_transform(Gray.(line_image) .> 0.5));` How do i read distance from skeleton pixel? – h612 Jan 18 '23 at 02:39
  • 1
    Sorry, I don't know Julia nor the functions you're using there. But if you pick one skeleton pixel, and then look at the value of the distance transform image at those coordinates, and multiply the value by two, then you have the thickness at that point. You can do this for each skeleton pixel, and maybe average the values, or maybe you have a specific point at which you need to measure the width? – Cris Luengo Jan 18 '23 at 06:25

1 Answers1

1

Using distance transform gets distance from neighbouring pixels, dist = 1 .- distance_transform(feature_transform(Gray.(line_image) .> 0.5)); and lookingup closest pixel with greater distance is the pixel of interest. Using Euclidian distance from an index in centrepoint (skeleton) to nearest distance * 2 gets width of the line.

h612
  • 544
  • 2
  • 11