Average width of lines

6 visualizaciones (últimos 30 días)
M
M el 30 de Sept. de 2013
Comentada: Image Analyst el 17 de Feb. de 2022
Hi all,
I want to know the procedure to calculate the average width of white lines in the image below.
Is it also possible to measure the widths at many different places?
Thanks
  1 comentario
Jan
Jan el 30 de Sept. de 2013
The problem is not well defined. What should happen at the intersection of the two lines? Does "width" still mean the minimal distance from one point on the edge to the points of the opposite edge? But the "opposite edge" belongs to the other line at the intersections. How is the "width" defined at the limits of the picture? In the lower left there might be some points, where the minimal distance cross some black pixels - is this valid?
The question is far from being trivial when you define it exactly. Only simplifications would allow to determine an "average width", but the exact definition of the problem cannot be guessed automatically, but this is your turn.

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 30 de Sept. de 2013
For a rough estimate, I'd just sum up the image to get the area, then skeletonize the image and sum up that image to get the total length. Then divide the area by the length. Will that work for you? If it's not accurate enough then explain why not, and what specific level of accuracy you require.
  1 comentario
M
M el 1 de Oct. de 2013
Thank you for the reply. I tried this method and obtained fairly good results. The accuracy is within acceptable range for my application. Thanks a lot.

Iniciar sesión para comentar.

Más respuestas (2)

Jan
Jan el 30 de Sept. de 2013
Some illustrations about the points, where I do not see a unique definition of "width":
Overlaps of more than 2 lines might occur also as well as lines which overlap the edge of the image of a wide range.
  2 comentarios
vaishali
vaishali el 30 de Sept. de 2013
how poly-line distance metric will be used to measure distance at middle white line?
M
M el 1 de Oct. de 2013
Thank you for the reply. My problem was to simply find the average width for all the lines, which can be done easily using the method explained by Image Analyst below. Overlapping lines do not give a very accurate measurement, but for my application, it can be overlooked. The edges are ok because the extra pixels at one edge can compensate for the missing pixels on the other edge.

Iniciar sesión para comentar.


Anand
Anand el 30 de Sept. de 2013
Another (more complicated and time-consuming) approach to try is the following:
1. Use edge to find edges in the image. Adjust the parameters to make sure all line segments are found. Use morphological functions like imdilate/imerode to get continuous line segments.
2. Use the hough function to find the Hough Transform of the image.
3. Find peaks in the Hough Transform. Adjust the thresholds enough to find peaks for all your desired line segments. Keep in mind that the horizontal and vertical line segments may come in as well.
4. Use the houghlines function to find coordinates for line segments found. Do some post-processing to eliminate unwanted lines.
5. Find parallel line segments by comparing the slopes of the lines (slope of a line can be found using (y2-y1)/(x2-x1)).
6. Find the perpendicular distance between the lines.
  3 comentarios
Ningjing Zhang
Ningjing Zhang el 17 de Feb. de 2022
How to perform some post-processing to eliminate unwanted lines?
Image Analyst
Image Analyst el 17 de Feb. de 2022
@Ningjing Zhang You have to make a mask of the ones you want to erase and then do
binaryImage(maskOfLinesToErase) = false;
of course how to get maskOfLinesToErase depends entirely on how you define which lines are not wanted.

Iniciar sesión para comentar.

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by