1

I would like to ask for advice - what kind of algorithm should I use to auto-detect a line on the image?

Before: (from http://tinyurl.com/l6d5x9s)

Before processing

I want to achieve this kind of result (from http://tinyurl.com/pnfaphv):

After processing

Thank you in advance for any help!

Teepeemm
  • 4,331
  • 5
  • 35
  • 58
user3052757
  • 43
  • 2
  • 7
  • 1
    That's not a little noise...that's JPEG artifacted, salt-and-pepper, and what looks like regular Gaussian noise all over the place. Have you tried a blur+edge filter? – nneonneo Jun 11 '14 at 01:04
  • i tried houghtransform and the result (http://i.stack.imgur.com/wZkwn.jpg). maybe you should post more images that as a group is more representative of the problem you want solved. – Zaw Lin Jun 11 '14 at 02:46
  • Actually i tried to implement houghtransform but it is not as easy as i expected. There is example of bigger image with this line -> http://i.imgur.com/RYKxm8n.png It is a little curved. Is houghtransform will be enough for this? I tried also some filters etc but it wasn't working. – user3052757 Jun 11 '14 at 22:00
  • can you draw what is the desired result? i tried houghtransform that i used in lpr scenario from (http://stackoverflow.com/questions/24046089/calculating-skew-of-text-opencv/24121568#24121568) and it detected jawline. however, i feel that maybe it cannot work generically. can you try (http://www.ipol.im/pub/art/2012/gjmr-lsd/)? this is what i get(http://i.stack.imgur.com/W4pam.jpg). then you need to link the lines which are close together and has similar angles to produce a long curve. maybe it can work – Zaw Lin Jun 13 '14 at 03:57
  • if that doesnt work..maybe you can try a classification based approach if the intensity of curve you want to detect has similar range. one of my colleagues used a neural network to segment teeth and it worked well. you can use the surrouding image patch and/or first order edge features as input – Zaw Lin Jun 13 '14 at 04:01
  • i found some related literature @ (http://mobimgproc.googlecode.com/svn-history/r11/trunk/MSthesis.pdf) – Zaw Lin Jun 13 '14 at 04:09
  • Desired result should look like this: http://i.imgur.com/RRD3rXD.png. Moreover, first step of program will be to mark two extreme points(green pionts)of this line by simple mouseclick - it will helps a lot. Basicly, i made houghtransform of this image http://i.imgur.com/RYKxm8n.png and the result is http://i.imgur.com/LNAfcqc.png. Point with most curve-crosind is (487,237) and the line-function is y=-0,65-580,68 and it looks like this http://www.wolframalpha.com/input/?i=y%3D-0.65x-580.68 so its quite simillar to desired image. But what next? How can I draw this line on this image? – user3052757 Jun 13 '14 at 14:31
  • assuming that image center is treated as origin,if you already have the line equation, you need to consider two cases 1) line is vertical, then line equation is x=rho and you need to connect the two points (rho+w/2,0),(rho+w/2,h) 2) line is not vertical, then you must find the intersection points of left and right border and the line and connect them, use x=0 and x=w to solve for y and connect them. – Zaw Lin Jun 13 '14 at 14:51
  • for java code you can refer to this (http://www.developpez.net/forums/d495285/autres-langages/algorithmes/contribuez/image-detecteur-ligne-hough/). since the site require registration, i have uploaded them somewhere here (http://www.datafilehost.com/d/be981c93). both compiled jar file and sources downloaded from the site – Zaw Lin Jun 13 '14 at 14:57
  • Could you upload this literature (http://mobimgproc.googlecode.com/svn-history/r11/trunk/MSthesis.pdf) on external server? I can't download it. It looks like hough transform won't help with detect this line. I thought about classification based of intensity of curve pixels but when we zoom in this curve, the values of pixels will be inaccurate and i think that algorithm can go in wrong direction..Maybe second parametr to compare e.g. distance between two points marked by mouseclick connected to pixel value comparing will help to achieve curve detection? What dependence should be between them? – user3052757 Jun 14 '14 at 00:34
  • http://www.datafilehost.com/d/6aa8476a another thing you can try is active contour based approach. most of them require manual initialization and they runs quite slow. but seems like these wont be issue for you. – Zaw Lin Jun 14 '14 at 03:05

2 Answers2

1

The easiest solution would be to look at the Hough transform. If you have a reasonably straight line, use a linear method. If your line is expected to be curved, use a circular method with large radii.

The Hough transform will not actually identify pixels in the line. It will just give you the position and angle of the line. It will also give you the thickness, if you threshold the result and measure the size of the point. Normally you do this anyway, using the centroid to find the actual centre of the line.

paddy
  • 60,864
  • 6
  • 61
  • 103
1

Gaussian blur, then adaptive thresholding and use canny edge.Might work

Pruthvi P
  • 536
  • 1
  • 7
  • 31