Click here to Skip to main content
15,878,852 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
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
Comments
V. 10-Apr-12 9:23am    
I have no clue what you have or what you're trying to achieve. Can you elaborate?

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[^].
 
Share this answer
 
Comments
Manoj Kumar Choubey 11-Apr-12 2:20am    
Thank you lukeer
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.
 
Share this answer
 
v2
Comments
Manoj Kumar Choubey 11-Apr-12 2:20am    
Thak you Leonardo paneque
Sure it will help you,Uploading two images and comparing both images are same by comparing its bandwidth,pixel,etc.

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


Comparing two images
 
Share this answer
 
Comments
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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900