up42 / image-similarity-measures

:chart_with_upwards_trend: Implementation of eight evaluation metrics to access the similarity between two images. The eight metrics are as follows: RMSE, PSNR, SSIM, ISSM, FSIM, SRE, SAM, and UIQ.
MIT License
550 stars 68 forks source link

Further instructions within python #25

Closed ccbogel closed 3 years ago

ccbogel commented 3 years ago

Thank you for providing this tool. It works from the command line in Ubuntu 20.04 which is great.

I am trying to make image_similarity_measures work from within a python module and have tried various approaches, but I feel the Usage in python instructions could benefit with a more detailed example.

These were my attempts below:

My imports import image_similarity_measures from image_similarity_measures.quality_metrics import fsim, issm, psnr, rmse, sam, sre, ssim, uiq from image_similarity_measures.evaluate import evaluation # I tried adding this import after other attempts

My failed attempts res = image_similarity_measures("--org_img_path=tmp1.png --pred_img_path=tmp2.png --metric=all") res = image_similarity_measures.evaluate("tmp1.png", "tmp2.png", "all") res = image_similarity_measures.evaluate.evaluation("tmp1.png", "tmp2.png", "all") res = rmse("images/tmp1.png", "images/tmp2.png")

akx commented 3 years ago

You'll need to load the images first, you can't just pass in strings:

import cv2
import image_similarity_measures.quality_metrics as qm

i1 = cv2.imread("images/tmp1.png")
i2 = cv2.imread("images/tmp2.png")
print(qm.rmse(i1, i2))
nekhtiari commented 3 years ago

@ccbogel what @akx said is the way to go. Please let us know if you can make it work.

ccbogel commented 3 years ago

Thank you these instructions help a lot. FYI, I am using these measures for comparing product packaging. So will experiment and see which of the measures appear to work best for colours and shapes between images. FYI2, I have created a short Qt interface for loading files, resizing to match and doing 1 to 1 comparisons.