1

Rencently I'm trying to search for some ways to detect lines in CT scans.I found that all the Hough Transform family and some other algorithms are required to deal with contours born after edge detector.I found the contours are not what I want and a lot of short lines created by these 2 steps.I get perplexed by this.Can any handsome tell me what to do with this?Some methods or algorithms used in grayscale-image straightly but not in binary-image? using opencv or numpy is perfect! Many thanks! Below is the test picture.I'm working to detect left-top straight lines and filter out the others.

enter image description here

Spektre
  • 49,595
  • 11
  • 110
  • 380
乔晓飞
  • 17
  • 3

1 Answers1

0

You have pretty consistent background so I would:

  1. detect contours

    as any pixel with not background color that is neighboring background color.

  2. Segmentate/label the contour points to form ordered "polylines"

    1. create ID buffer and set ID=0 (background or object pixels)
    2. find any yet not processed contour pixel if none found stop
    3. flood fill the contour in ID buffer by ID
    4. increment ID
    5. go to 2

    now ID buffer contains your labeled contours

  3. for each contour create ordered list of pixels forming contour "polyline"

    to speed this up you can remember each contour start point from #2 or even do this step directly in step #2.

  4. detect straight lines in contour "polylines".

    that is simple straight lines have similar slope angle between neighboring point. You can also apply regression or whatever ... the slope or unit direction vectors must be computed on pixels that are at least 5 pixels distant to each other otherwise rasterization pixelation will corrupt the results.

see some related stuff:

Spektre
  • 49,595
  • 11
  • 110
  • 380