I've been trying to implement the local ridge orientation for fingerprints in python. I've used the Gradient method, and using sobel operator to get the gradients I need. However it turned out that this method has quite a lot of flaws, especially around 90 degrees. I could include the code that I've done so far, but as it does not work as I want, I don't know if it's needed. I've also looked at the line segment method, however, I'm working with latent fingerprints so it is hard to know if one should look for maximum of black or white in the line segments. I've also tried to implement an algorithm to detect the area of maximum concentration of continous lines, but I couldn't get this to work. Any suggestion for other algorithms to use?
EDIT:
I'm using a function to apply my function to blocks, but that is hardly relevant
def lro(im_np):
orientsmoothsigma = 3
Gxx = cv2.Sobel(im_np,-1,2,0)
Gxy = cv2.Sobel(im_np,-1,1,1)
Gyy = cv2.Sobel(im_np,-1,0,2)
Gxx = scipy.ndimage.filters.gaussian_filter(Gxx, orientsmoothsigma)
Gxy = numpy.multiply(scipy.ndimage.filters.gaussian_filter(Gxy, orientsmoothsigma), 2.0)
Gyy = scipy.ndimage.filters.gaussian_filter(Gyy, orientsmoothsigma)
denom = numpy.sqrt(numpy.add(numpy.power(Gxy,2), (numpy.power(numpy.subtract(Gxx,Gyy),2))))# + eps;
sin2theta = numpy.divide(Gxy,denom) # Sine and cosine of doubled angles
cos2theta = numpy.divide(numpy.subtract(Gxx,Gyy),denom)
sze = math.floor(6*orientsmoothsigma);
if not sze%2: sze = sze+1
cos2theta = scipy.ndimage.filters.gaussian_filter(cos2theta, orientsmoothsigma) # Smoothed sine and cosine of
sin2theta = scipy.ndimage.filters.gaussian_filter(sin2theta, orientsmoothsigma)#filter2(f, sin2theta); # doubled angles
orientim = math.pi/2. + numpy.divide(numpy.arctan2(sin2theta,cos2theta),2.)
return orientim