how to detect two parallel lines in a binary image with MATLAB I am working on license plate detection using hough transform. I am trying to detect the horizontal and vertical edges and then to find the parallel lines.

My code:

img = rgb2gray(img);

img = medfilt2(img);

v = edge(img,'sobel','vertical');
v = bwlabel(v);
stats = regionprops(v, 'Area','BoundingBox','Image');
ids = find([stats.Area] &gt; 30 &amp; [stats.Area] &lt; 2000);
v = ismember(v,ids);


Output:



Now I want to detect the parallel lines. I have consulted different examples on Mathworks but unfortunately I couldn't get much of it. Someone please guide me how to detect two almost straight and parallel lines in a binary image?
You mentioned the Hough transform, but your code doesn't use it. However, it can help you to find out the orientations of lines.

The maximum values of the Hough transform correspond to probable lines. These maxima are defined by their coordinates $(\rho, \theta)$, where $\rho$ is the distance from the origin to the closest point on the straight line, and $\theta$ is the angle between the $x$ axis and the line connecting the origin with that closest point (see Wikipedia).

Therefore, two parallel lines have a close $\theta$ (or $\theta + \pi$).