PIL patches

From Noah.org
Jump to navigationJump to search

Add difference_rms to PIL

This is a patch against the Python Imaging Library Imaging-1.1.6. This add the method ImageChops.difference_rms(im1, im2) which returns a float giving the RMS difference between the two given images, im1 and im2. This is about 10 times faster than doing it in Python. This can be used to detect changes in images (say, for motion detection) or to compare the effect of different image operations. If the two images are exactly equal then difference_rms() will return 0.0. As the images diverge the value returned will increase. It will always be a positive number. In general, the greater the difference between the two images then the greater the RMS difference will be.

To apply the patch and build PIL execute the following commands. This assumes that Imaging-1.1.6.tar.gz and Imaging-1.1.6.patch are in the same directory.

tar xzf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6
patch -p 1 < Imaging-1.1.6.patch
python setup.py install

Download patch

<include src="/var/www/usr/local/apache2/htdocs/engineering/src/python/Imaging-1.1.6.patch" highlight="diff" />