how to detect two parallel lines in a binary image with MATLAB
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$).