1

I know that similar questions have been asked many times, but still I have not found a satisfactory answer for what I am looking for. I want to be able to compare two versions of the same image, in order to detect the amount of perceptual artifacts resulting from JPEG compression, without any further changes (i.e., no crops, no rotation...). I mean, not just the histogram or the number of pixels that are different (those would be probably easy to get from Pillow), but instead I would like to be able to obtain some kind of measure of their overall visual impact.

Reading through some articles in SO and in other places, I have found multiple references to SSIM algorithm, that seems to do precisely what I am looking for. There is even a Python (https://github.com/jterrace/pyssim), but the problem is that all those implementations seem to depend on packages that can't be installed in some of my target devices. I am using Pythonista 3 on iOS, which includes Pillow 2.9.0 and numpy, but scipy (required by pysimm) is not compatible.

Is there any other viable way to calculate SIMM or a similar comparison value that does not require anything more that Python 3.6, Pillow and/or Numpy 1.8.0?

Victor Domingos
  • 1,003
  • 1
  • 18
  • 40
  • There is an implementation of SSIM in scikit image. Have u tried that? – Jeru Luke Jun 21 '18 at 17:26
  • 1
    It seems that scikit-image also has some requirements that are not compatible with Pythonista (being script one the them). Basically anything that requires compiled code and is not provided by the app itself is probably incompatible. The best bet in this case would be a pure-python approach, or anything that would need only the included Numpy and Pillow versions. – Victor Domingos Jun 21 '18 at 17:32
  • 1
    There is also a mention to RMSE or NRMSE, that also could help, here: https://stackoverflow.com/q/13875989/6167478 (but, once again, it requires `scipy`…) – Victor Domingos Jun 21 '18 at 19:53
  • 1
    Looking through the source code involved, all operations are entirely numpy-based. You should be able to extract the scipy image parts without issue. – Martijn Pieters Oct 07 '18 at 10:24
  • Last time I looked into the code, I got stuck in a thing called wavelets. – Victor Domingos Oct 07 '18 at 10:25
  • There is just [one function](https://github.com/jterrace/pyssim/blob/8cbe809a12348f8e8d089d7616ae8bdb1b8bade2/ssim/utils.py#L11-L17) that uses [a pure python SciPy function](https://github.com/scipy/scipy/blob/v0.14.0/scipy/ndimage/filters.py#L110-L140), that ends up calling a [C implementation on top of Numpy](https://github.com/scipy/scipy/blob/8dba340293fe20e62e173bdf2c10ae208286692f/scipy/ndimage/src/ni_filters.c#L38-L135). You *could* try and see if that can be reimplemented in Python, maybe numpy vectorised ops are fast enough for your use cases? – Martijn Pieters Oct 07 '18 at 10:39
  • I will take a look, but my very rudimentary knowledge of C will probably be an issue :) – Victor Domingos Oct 07 '18 at 12:09
  • Maybe this helps: https://codereview.stackexchange.com/questions/31089/using-the-ssim-method-for-large-images – Victor Domingos Oct 08 '18 at 18:19

0 Answers0