X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 07 Sep 2012 02:30 PM by  anon
Line Detection
 5 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:19
New Member


--
07 Sep 2012 02:30 PM
    I'm looking for a way to detect lines (possibly using hough transform?) in an image and either output the lines as x,y corrdinates or as a shapefile of only the lines. I haven't had much success in anything I've tried and am wondering if anyone here can help? My endless googling hasn't resulted in much help. Thanks

    Deleted User



    New Member


    Posts:
    New Member


    --
    10 Sep 2012 11:50 AM
    It would seem like the HOUGH function with the 'backproject' keyword could work. Have you tried that and if so what were the results? You mentioned having tried other things, what were they and what results did you get?

    Deleted User



    New Member


    Posts:19
    New Member


    --
    11 Sep 2012 08:34 AM
    The closest I've come is with the hough and backproject. I can get an image of the lines to display, but is there anyway to export these lines as a shapefile or output their x,y coordinates as a text file?

    Deleted User



    New Member


    Posts:19
    New Member


    --
    11 Sep 2012 09:02 AM
    This link could help as I was shown: http://stackoverflow.com/...transformation-rho-t But I'm unsure of how to convert this into idl functions. Can anyone else help with this?

    Deleted User



    New Member


    Posts:
    New Member


    --
    11 Sep 2012 10:43 AM
    You mentioned that you have an image output with your Hough backproject. That image is an array of values that could be the coordinates of the lines. Here is something you can try: IDL>result=Hough( your_array, /backproject) IDL> help, result The IDL Help states that when BACKPROJECT is set, Result will be an array of dimension NX by NY. Check the Help for what NX and NY should be.

    Deleted User



    New Member


    Posts:19
    New Member


    --
    12 Sep 2012 02:23 PM
    NX and NY give me the dimensions of the full image (if I'm correct on that?) but I need the specific location of the lines within those dimensions and I can't figure out how to export those. Here is my code so far... PRO houghtrans ; Determine path to file. ;file = FILEPATH('H:\Test\Hough\lake.tif') ; Import image from file into IDL. image = READ_tiff('H:\Test\Hough\dock.tif') ; Determine size of image. imageSize = SIZE(image, /DIMENSIONS) ; Create window and display original image DEVICE, DECOMPOSED = 1 WINDOW, 0, XSIZE = imageSize[1], YSIZE = imageSize[2], $ TITLE = 'lake, hough' TV, image, TRUE = 1 ; Use layer from green channel as the intensity of the ; image. intensity = REFORM(image[1, *, *]) ; Determine size of intensity image. intensitySize = SIZE(intensity, /DIMENSIONS) ; Mask intensity image . mask = intensity GT 150 DEVICE, DECOMPOSED = 0 LOADCT, 0 ;Create another window and display the masked image: WINDOW, 1, XSIZE = intensitySize[0], $ YSIZE = intensitySize[1], $ TITLE = 'Mask' TVSCL, mask ;Stop ; Transform mask. transform = HOUGH(mask, RHO = rho, THETA = theta) ; Scale transform to obtain just the lines over 100 pixels. transform = (TEMPORARY(transform) - 100) > 0 ; Backproject to compare with original image. backprojection = HOUGH(transform, /BACKPROJECT, $ RHO = rho, THETA = theta, $ NX = intensitySize[0], NY = intensitySize[1]) ;stop ;print, intensitySize ;print, rho, theta ;print, theta openw, 2, 'H:\Test\rho.txt' printf, 2, rho, format= '(i0)' close, 2 openw, 3, 'H:\Test\theta.txt' printf, 3, theta, format= '(f12.10)' close, 3 ;print, intensitySize ;Stop ; Reverse color table to clarify lines. If you are on ; a TrueColor display, set the DECOMPOSED keyword to 0 ; before using any color table related routines. DEVICE, DECOMPOSED = 0 LOADCT, 0 TVLCT, red, green, blue, /GET TVLCT, 255 - red, 255 - green, 255 - blue ; Display results. WINDOW, 1, XSIZE = intensitySize[0], $ YSIZE = intensitySize[1], $ TITLE = 'Resulting Lines' TVSCL, backprojection
    You are not authorized to post a reply.