jterrace / pyssim

A Python module for computing the Structural Similarity Image Metric (SSIM)
MIT License
339 stars 62 forks source link

Is it possible to make `scipy` an optional requirement? #29

Open victordomingos opened 5 years ago

victordomingos commented 5 years ago

I have been working on a Python application (optimize-images) that could benefit from the functionality provided by this package. However, as it's intended to be cross platform and compatible with Pythonista on iOS (which includes Pillow and Numpy as built-in features, but can't use other packages that aren't pure Python or have binary package as dependencies), I can't use it. I have been looking on the source code to check for the dependencies and it seems that there are just a few places where scipy is required.

Would it be possible to make scipy an optional requirement and add the necessary workaround pure Python or Numpy based? I am sure this alternative code wouldn't be as fast as the scipy based one, but on the other hand it would be great for those cases where for some reason scipy is out or reach.

jterrace commented 5 years ago

Looks like the two things being used are:

The latter is only used in the CW-SSIM algorithm, so it'd be easy to make CW-SSIM unavailable if scipy isn't available.

The former (correlate1d) is used in several places, so you'd have to find a pure numpy implementation.

victordomingos commented 5 years ago

I have been looking for that, without success. I have even placed a question on StackOverflow to see if someone could help, but until now I just got a tip identifying a function that seems to be a C implementation on top of Numpy, that would need to be "translated" to Python. Unfortunately, that is a task I am not prepared for, as my C language knowledge is very rudimentary.

victordomingos commented 5 years ago

Maybe this helps: https://codereview.stackexchange.com/questions/31089/using-the-ssim-method-for-large-images