# Determining the pattern direction of a bitmap image

How can I obtain average direction of the pattern shown in the figure below. It is the direction of the red arrow relative to the yellow (horizontal) line. Any ideas for an approach? I couldn't figure out a way to approach. This is a spatio-temporal image created from a video. Thank you.

• What is exactly your problem, what have been done so far? Please edit your post. Aug 7, 2017 at 21:47
• Found solution at stackoverflow.com/questions/45547038/… Aug 10, 2017 at 15:10
• glad to hear that, so please delete your post because it is considered duplicated now. Aug 10, 2017 at 16:33
• @MimSaad according to community standards it is not duplicate since "The duplicate question must exist on Signal Processing Stack Exchange" Aug 10, 2017 at 16:38
• you should be a lawyer ;) Aug 10, 2017 at 17:10

Solution is using structure tensors

from skimage.feature import structure_tensor

Axx, Axy, Ayy = structure_tensor(gray_image, sigma=1)
tan2t = (2*Axy)/(Axx-Ayy)
t=np.arctan(tan2t)/2
data = t.ravel()

# find the mode of data array (can use histogram). it is the direction.


another question and answers from other community