I have been looking for a method to find the width of a line.

I found the solution(link: http://www.mathworks.com/matlabcentral/answers/88645-average-width-of-lines),

"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."

Can anyone please explain the following? 1. what is summing up to get image area? 2. what is summing up skeletoniized image to get length? I did not get this.

I have to find the thickness of a string from a given image. I can take the image of any dimension and quality I want. How do i measure the thickness of a string? That is what I was trying to resemble as width of a line. Essentially, thickness of a string can be thought as width of a line, I think.

Moreover, I can not assign any unit to my measurement i.e., m/cm/mm. So I have to measure some sort of ratio to represent the thickness and reach a decision.

My outcome should be Yes or No based on the thickness. For example, if the thickness is greater that a certain value I would not take the string to process.

The string can be made of anything.

  • 1
    $\begingroup$ Your question is unclear. You want a method to find line width, and then provide solution to average width of monochromatic (black and white only) lines? $\endgroup$ – Evil Jun 10 '16 at 0:54
  • 2
    $\begingroup$ 1. Please edit the question to make the problem statement clearer. What does "find the width of a line" mean? How is the line represented? What is the input? Can you provide an example? How do you plan to specify which line you want to find the width of? How do you plan to address the comments ("the problem is not well-defined"..) on the web page you link to? Your current question is too terse. 2. What is your best guess at the interpretation of those phrases? What possible interpretations have you considered? $\endgroup$ – D.W. Jun 10 '16 at 1:16
  • 2
    $\begingroup$ 3. What research have you done? Skeletonizing is a standard concept in image processing and is even described in the obvious place on Wikipedia. If your question is answered in the obvious place on Wikipedia, you probably haven't done enough research before asking. We expect you to do a significant amount of research before asking, and to show us in the question what you've found. See cs.stackexchange.com/help/how-to-ask. $\endgroup$ – D.W. Jun 10 '16 at 1:16
  • $\begingroup$ Edit should give self-contained question - no "edit" tags inside. Your measurement will be in px. What do you mean by string thickness? Font size? Text height? Single letter leg width? What if it changes? For example O will vary from 2 to 5 px, what then? Do you have font used or possibly size (of the font)? $\endgroup$ – Evil Jun 10 '16 at 23:46
  • 2
    $\begingroup$ To further improve the question, please see here. $\endgroup$ – Juho Jun 11 '16 at 7:16

"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."

Input images is a binary image, thus either the pixel value will be zero(black pixel) or 255(while pixel).

enter image description here

Summing up the image gives the sum of all while pixels(black pixel are zero).

i.e., the area of whole white line

$Area = Sum/255$

After skeletonizing the image, the thick white lines become almost one pixel thick.

enter image description here

Summing it up will give the approximate length of the line.

Now, as we know the area occupied by the white line and length of the line.

Dividing them will result the thickness of the line.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.