Finding crosses and their orientation on a given image I want to recognize table structure from some arbitrary photo image and store it in some formal notation (Let it be HTML table notation).

For example I have this blurry image as input:


After binarization I achieved this:


Now to detect structure I want to detect intersections between lines, their type (T-type, X-type, or simple corner), their orientations and their location on the image. After this I'm going to use all gained information for further joining of adjacent crosses in some structure, and translate this structure into formal representation.

The problem is in detecting crosses and their orientation:



In general these crosses may be scaled and/or rotated.
Maybe someone could help with method of solving this problem? Or maybe recommend different methods for this whole task?

That's what I have written so far:

 # -*- coding: utf-8 -*-

 import cv2
 import cv
 import numpy

 original = cv2.imread("/home/user/my_photo-1.jpg")
 grayscale = cv2.cvtColor(original, cv2.COLOR_BGR2GRAY)
 smoothed = cv2.GaussianBlur(grayscale, (5,5), 0)
 cv2.imshow("original", original)
 cv2.imshow("grayscale", grayscale)

 binarized = cv2.adaptiveThreshold(grayscale, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 7, 8)
 binarized = cv2.Canny(grayscale, 50, 200)
 cv2.imshow("binarized", binarized)
 cv2.waitKey(0)


Thanks in advance for any response/idea.
Try to use cv2.HoughLinesP (see an example) to detect the straight lines (segments). As a result you will get the segments' endpoints, so finding all the intersections and its type will be quite simple maths.
The problem will be rather with finding the proper and universal parameters.

Theoretically you could use a morphological operation called hit-and-miss transform, but this will be difficult in your case, as the lines are hand-drawn and even after thinning the crosspoints may be difficult to be properly classified (as 'T', '+' or 'corner').

I would suggest you to make some morphological preprocessing to improve the binary image you have got.