I have a python code that takes a black and white image and a black and white template as input and aims to find the template within the image. Before having to update the skimage library to version 0.19.3, the skimage.mesure.compare_ssim function was used in this way:
for pt1, ft1 in zip(templ.points, templ.feats):
for pt2, ft2 in zip(image.points, image.feats):
ret = skimage.mesure.compare_ssim(ft1, ft2, win_size=FEATURE_SSIM_WIN, K1= FEATURE_SSIM_K1 , K2= FEATURE_SSIM_K2)
if ret < FEATURE_SSIM_THR:
continue
matches.append([pt1, pt2, ret])
where ft1 and ft2 are features extracted from specific points of both the image and the template with a data range of 0 to 1.0.
When updated, the compare_ssim function has been replaced by skimage.metrics.structural_similarity and I have updated the code in this way :
for pt1, ft1 in zip(templ.points, templ.feats):
for pt2, ft2 in zip(image.points, image.feats):
ret = skimage.metrics.structural_similarity(ft1, ft2, win_size=FEATURE_SSIM_WIN, data_range=1.0, K1= FEATURE_SSIM_K1 , K2= FEATURE_SSIM_K2)
if ret < FEATURE_SSIM_THR:
continue
matches.append([pt1, pt2, ret])
However, It is not working as it was before. It is giving me incorrect matching points that don´t fit properly
I have tried different values for the data range (255, ft1.max()-ft1.min(), ft2.max()-ft2.min()...) and to adjust the Ks to 0.01 and 0.03 with a threshold suitable for these values. I have also tried to use these parameters
ret = skimage.metrics.structural_similarity(ft1, ft2, data_range=1.0, gaussian_weights=True, sigma=1.5,use_sample_covariance=False)
that are the ones that more closely match the Matlab script by Wang et. al. But it still doesn’t work as before.
Do you have any idea what I might be doing wrong for it not to work as before?