Ask Your Question
0

Separate HSV mask

asked 2018-07-20 23:53:39 -0600

SinLok gravatar image

updated 2018-07-23 08:08:31 -0600

The following is the original image :

image description

Then, I used the HSV inrange to filter the guidepath. And then the result like this: image description

Is there has any method so that I can separte the guidepath into 3 direction? Just similar the following: image description

Updated

The following image has already completed the first 2 (@StevenPuttemans suggestion) step image description

I also use 100*100 sliding window to scan thought the whole image. And then calculating the mean point inside the sliding window. The result like following: image description Then, I use the minmum spanning tree with euclidean distance to create the relationship between these point. Now, I have no idea how to remove noise edge in tree and confirm different direction. Anyone have a good suggestion?

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
1

answered 2018-07-23 07:29:34 -0600

To solve this you will definitely perform the following steps.

  • Apply some erosion and dilation to remove the noise and to fill the gaps.
  • Then you want to apply a thinning algorithm (also in OpenCV) to have single edges
  • Then you want to define the edge directions

For the last part, I would have a look at edge direction algorithms. You might be able to do something with the gradients of the image, since the direction is perpendicular to the dominant gradient directions.

edit flag offensive delete link more

Comments

The first 2 step I implemented yesterday. But I have no knowledge about gradients of the image. Could you introduce some keyword for me. I also updated my question. Could you also give some suggestion?

SinLok gravatar imageSinLok ( 2018-07-23 08:10:20 -0600 )edit

In the second image you can apply a Sobel operator, which is basically looking for gradients.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-23 08:11:40 -0600 )edit

I review some topic about the Sobel filter. It seem that it use for edge detection. So, how to apply for defining edge direction?

SinLok gravatar imageSinLok ( 2018-07-23 09:11:59 -0600 )edit

A Sobel filter defines edges based on the gradient output. The gradient should have a direction and a value. If you bin the directions over the whole image, you should find direction peaks for the gradients. I believe your directions to go will be perpendicular to that.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-07-24 02:15:01 -0600 )edit
1

answered 2018-07-24 09:21:41 -0600

kbarni gravatar image

I would add another answer.

  • Compute the gradients in the original (color) image
  • Get the mean direction in a sliding window: make a 2x2 matrix containing:

    [ Sum(Gx²)    Sum(GxGy) ]
    [ Sum(GxGy)   Sum(Gy²)  ]
    
  • Compute the PCA of this matrix. The first eigenvector will give you the mean gradient direction.

  • Use the segmented image as a mask to eliminate unwanted areas.
  • Segment the direction image to get the different lines. You can also check the histogram of the gradient directions.
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-07-20 23:53:39 -0600

Seen: 333 times

Last updated: Jul 24 '18