Ask Your Question
0

Separate HSV mask

asked Jul 21 '18

SinLok gravatar image

updated Jul 23 '18

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?

Preview: (hide)

2 answers

Sort by » oldest newest most voted
1

answered Jul 23 '18

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.

Preview: (hide)

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 (Jul 23 '18)edit

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

StevenPuttemans gravatar imageStevenPuttemans (Jul 23 '18)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 (Jul 23 '18)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 (Jul 24 '18)edit
1

answered Jul 24 '18

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.
Preview: (hide)

Question Tools

1 follower

Stats

Asked: Jul 21 '18

Seen: 346 times

Last updated: Jul 24 '18