Ask Your Question
0

Generalizing the size for Detecting Horizontal and Vertical Lines [closed]

asked 2019-07-18 10:32:20 -0500

Dronzer gravatar image

updated 2019-07-22 10:08:01 -0500

Is there a way to generalize the vertical and horizontal size in the given code below? The given Vertical and horizontal size for getStucturingElement() doesn't work in all the cases and I should change them depending on ther grid thickness. Grid Image

Please find the inputs and desired outputs below: grid_result

Input Grid2 Result 2

code link

edit retag flag offensive reopen merge delete

Closed for the following reason too subjective and argumentative by Dronzer
close date 2019-07-23 14:21:40.719953

Comments

You mean, to have sort of an adaptive structuring element? I don't think so. What exactly is your goal?

Witek gravatar imageWitek ( 2019-07-18 16:02:24 -0500 )edit

Yes, I would like to denote each intersection point as coordinates starting from top left as (0,0),(1,0),....

Dronzer gravatar imageDronzer ( 2019-07-18 23:31:07 -0500 )edit

Adaptive structuring element or if not any other method.

Dronzer gravatar imageDronzer ( 2019-07-18 23:32:04 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-07-19 05:32:15 -0500

kbarni gravatar image

To get only the intersections, just use the Harris corner detector. It will have maximum values in the middle, no matter the line width.

To get the structure, use a morphological skeleton algorithm (it's a kind of adaptive erosion). It's not part of OpenCV if I remember correctly, but you can find some implementations on the web.

edit flag offensive delete link more

Comments

I have to name each corner as a coordinate and I am not sure how to make it possible when I detect corners.

Dronzer gravatar imageDronzer ( 2019-07-19 05:49:32 -0500 )edit
1
sturkmen gravatar imagesturkmen ( 2019-07-19 06:20:35 -0500 )edit

I have to name each corner as a coordinate...

Just detect the maxima of the image given by the Harris corner detector.

kbarni gravatar imagekbarni ( 2019-07-19 06:54:28 -0500 )edit

@sturkmen I have tried using thinning algorithm and then trying getStructuringElement but the continuous lines are separated while finding horizontal and vertical lines which make it difficult for counting the number of lines.

Dronzer gravatar imageDronzer ( 2019-07-19 07:35:47 -0500 )edit

@kbarni When I try to find corner detection there are few false positives. While changing the parameters I have 2 corners at the same intersection point.

Dronzer gravatar imageDronzer ( 2019-07-19 08:06:32 -0500 )edit

@Dronzer. Are you talking about the size of black sqaures?

supra56 gravatar imagesupra56 ( 2019-07-20 08:37:16 -0500 )edit
1

@supra56 yes, I mean the size.

Dronzer gravatar imageDronzer ( 2019-07-20 12:45:38 -0500 )edit

@Dronzer You need to detect the local maxima in the image, to eliminate multiple detections.

There are several ways to do this, you can eliminate every corner in a D pixel radius around a detection. The subpixel accuracy method in the description I linked can be another solution.

kbarni gravatar imagekbarni ( 2019-07-22 08:51:58 -0500 )edit

@kbarni I have modified the question a bit and provided input and desired output that I am looking for. Thank you!

Dronzer gravatar imageDronzer ( 2019-07-22 10:06:39 -0500 )edit

...and did you try so solve it? Or you are just waiting for us to give you the solution? (it won't happen)

kbarni gravatar imagekbarni ( 2019-07-23 10:25:58 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-07-18 10:32:20 -0500

Seen: 64 times

Last updated: Jul 22