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

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.

Please find the inputs and desired outputs below:

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

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

Adaptive structuring element or if not any other method.