12,505,902 members (55,588 online)
Rate this:
See more:
I have a image containing Multiple lines in different color's and this line can be overlap I need to count Number of line's from Image,
and also need to detect line area.
How could I achieve it.

With Regards
Manoj
Posted 10-Apr-12 3:15am
V. 10-Apr-12 9:23am

I have no clue what you have or what you're trying to achieve. Can you elaborate?

Rate this:

## Solution 1

I'd try something like that

1. Check for existing colours in the image
2. For each existing colour, Hough-transform[^] the image to get straight lines (could be tricky if colours actually are gradients)
3. You should now have some equations that represent straight lines. An equation should have two parameters. Find a formula that transforms two sets of such parameters into a distance.
4. Every pair of lines whose distance is less than a threshold (experiment for the value) are indeed segments of the same line. You could use a clustering algorithm[^].
manoj kumar choubey 11-Apr-12 2:20am

Thank you lukeer
Rate this:

## Solution 2

the solution provider by lukeer is good, but could take a lot of work.
you can also do it with a quick pass over the image.

since those are lines, you will and not curves you can easily do this by:
1) walk the matrix of the image, this is going to be O(n^2) and for each color you find (that is not background). grab the min and max x and y coordinates, then you can get the two points of each line with these values.

now, finding "colors"
1) if the image colors are solid (no gradients) then is just what I placed above. but
2) if line colors are a bit distorted (due to jpeg compression etc) then you just use a distance function to compare 2 colors. since a color is a vector with (R,G,B), you can have the distance D(colorA,ColorB) and use threshold, so if D(colorA,colorB)<threshold it will be considered the same color.

hope it helps.
v2
manoj kumar choubey 11-Apr-12 2:20am

Thak you Leonardo paneque
Rate this:

## Solution 3

Really a nice article...........

Comparing two images
lukeer 11-Apr-12 2:17am

What's that got to do with finding lines in an image, despite the obvious image-processing background?
manoj kumar choubey 11-Apr-12 2:21am

Thank you vino

Top Experts
Last 24hrsThis month
 OriginalGriff 253 Karthik Bangalore 235 David_Wimbley 215 Maciej Los 200 ppolymorphe 161
 OriginalGriff 7,386 ppolymorphe 3,980 Maciej Los 3,741 David_Wimbley 3,087 Karthik Bangalore 2,977