Closed mamunTomal closed 2 years ago
Hi @mamunTomal, thanks for reporting. I can reproduce the RuntimeWarning, however the evaluation metric is still correctly reported. Could you give more detail on how you are using the package?
Hi @chrieke the same error I am receiving.
D:\quality_metrics.py:160: RuntimeWarning: divide by zero encountered in log2
return -np.sum(np.nan_to_num(H * np.log2(H)))
D:\quality_metrics.py:160: RuntimeWarning: invalid value encountered in multiply
return -np.sum(np.nan_to_num(H * np.log2(H)))
D:\quality_metrics.py:177: RuntimeWarning: invalid value encountered in double_scalars
return numerator / denominator
Out[9]: 0.0
I printed H matrix, and it is a 10x10 matrix with some zero elements. My python version is 3.7, using via import, and the error occurs for every test images.
Hi @chrieke I received the same error as shown by @Safiullahmarwat. I used python 3.6 and 3.7 in different environments. The CLI was used in Pycharm. I later resorted to write my own code in Matlab and got the results from there. I plan to share the matlab implementation of ISSM once I am sure it is bug free.
Hi @mamunTomal can you please share the values you used for thresholds? as in this code
g = cv2.Canny((x* 0.0625).astype(np.uint8), 100, 200)
h = cv2.Canny((y* 0.0625).astype(np.uint8), 100, 200)
here g and h, both are zero valued matrices. I think this is the issue. It seems like other quality functions, the author have imagined the image to be 12bit imagery. for other functions, i replaced the value of 4095 with 255, as I am using 8 bit images. dont know how to replace the value 0.0625. [Update] I just removed 0.0625 and kept the original type (as the original type is also uint8) and it worked for me. Thank you the author such a great work.
g = cv2.Canny(x, 100, 200)
h = cv2.Canny(y, 100, 200)
I am happy that it is resolved. We need to be more clear that we first implemented this library considering satellite images with physical values (e.g. surface or top-of-the-atmosphere products with some sort of corrections) for each pixel which can be captured with 12bits numbers. (Note that the end product is in 16bit because computers are optimized to deal with 8, 16, or 32 bit numbers).
@chrieke Also this one, can you close it. Thanks!
The following error shows up and returns ISSM=0
site-packages/image_similarity_measures/quality_metrics.py:146: RuntimeWarning: divide by zero encountered in log2 return -np.sum(np.nan_to_num(H * np.log2(H)))