jterrace / pyssim

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

refactoring + autoresize + multiple comparison #7

Closed koteth closed 10 years ago

koteth commented 10 years ago

I’ve done a small refactoring for myself. I’ve also enabled the possibility to compare an image against a list (directory) of images. if you pass 2 images as input the output is the same as the old code. if you want to take my code is ok .

jterrace commented 10 years ago

I like the enhancements, but why did you move everything out of init and main ?

koteth commented 10 years ago

hi, init.py in python is mainly a marker that qualifies a directory as a package. it's usually empty so it's the last place where I search for a block of code in a project. For this reason I prefer not to use it if is not needed.

Regarding main.py file, it is usually present if you want to run a program with 'python ', but the README file suggests to install the module. So, once it is correctly installed (in setup.py i've pointed to "pyssim = ssim.ssim:main'"), the main file is not needed anymore.

jterrace commented 10 years ago

init being empty is a commonly used convention, but you typically import anything you want to be globally accessible from your module into it. I can't merge this because you broke compatibility with anyone using the module like this:

import ssim
ssim.compute_ssim(...)

The main file allows you to do this:

python -m ssim

or from developemt:

python ssim
koteth commented 10 years ago

you are right, I have made some small backward compatibility enhancements in order to support the 3 scenarios you have explained. Now it should be ok.

koteth commented 10 years ago

done

jterrace commented 10 years ago

Thanks for your contribution!

jterrace commented 10 years ago

Hey, would you mind sending me a PR to add yourself to the AUTHORS file?