I determine the similarity between two binary images using the function matchShapes with its internally used Hu Moments.
img1 = cv2.imread(path1, cv2.IMREAD_GRAYSCALE) img1 = cv2.bitwise_not(img1) img2 = cv2.imread(path2, cv2.IMREAD_GRAYSCALE) img2 = cv2.bitwise_not(img2) _,threshold = cv2.threshold(img1, 25, 255, cv2.THRESH_BINARY) _,threshold2 = cv2.threshold(img2, 25, 255, cv2.THRESH_BINARY) cv2.matchShapes(threshold, threshold2, cv2.CONTOURS_MATCH_I1, 0.0)
My question is addressed to ShapeMatchModes.
According to the documentation, the Hu moments are transfomed as follows, before the distance respectively the similarity is calculated through one ShapeMatchMode:
As far as I know, however, Hu moments can be negative. How is this solved for the logarithm, since this is not defined for negative numbers?
Thanks in advance!