Difference between revisions of "PIL patches"

From Noah.org
Jump to navigationJump to search
 
(22 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:Engineering]]
 
[[Category:Engineering]]
This is a patch against the Python Imaging Library Imaging-1.1.6.
+
[[Category:Python]]
This add the method ImageChops.difference_rms(im1, im2) which returns
+
[[Category:Free_Software]]
a float giving the RMS difference between the two given images.
+
== Note ==
This is about 10 times faster than doing it in Python. This can be
+
?isn't this equivalent to:
used to detect changes in images (motion) or to compare the effect
+
 
of different image operations. If the two images are exactly equal then
+
    ImageStat.Stat(ImageChops.difference(i, im)).rms
differnce_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.
+
 
 +
-- Fredrik Lundh fredrik at pythonware.com
 +
 
 +
== Add "difference_rms" method to the PIL ==
 +
 
 +
I originally wrote this to help implement a video stabilization filter. In video stabilization I take two frames of a video and shift one of them around until the RMS Difference is minimized. You could also use this to quantify how much a lossy compression algorithm distorts an image relative to some other compression algorithm.
 +
 
 +
This is a patch against the [http://www.pythonware.com/products/pil/ Python Imaging Library Imaging-1.1.6].
 +
This adds the method <em>ImageChops.difference_rms(im1, im2)</em> which returns a float of 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.
 +
 
 +
<pre>
 +
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
 +
</pre>
  
 
[http://www.noah.org/engineering/src/python/Imaging-1.1.6.patch Download patch]
 
[http://www.noah.org/engineering/src/python/Imaging-1.1.6.patch Download patch]
  
<include src="/var/www/usr/local/apache2/htdocs/engineering/src/python/Imaging-1.1.6.patch"/>
+
<include src="/var/www/usr/local/apache2/htdocs/engineering/src/python/Imaging-1.1.6.patch" highlight="diff" />

Latest revision as of 06:04, 28 March 2008

Note

?isn't this equivalent to:

    ImageStat.Stat(ImageChops.difference(i, im)).rms

-- Fredrik Lundh fredrik at pythonware.com

Add "difference_rms" method to the PIL

I originally wrote this to help implement a video stabilization filter. In video stabilization I take two frames of a video and shift one of them around until the RMS Difference is minimized. You could also use this to quantify how much a lossy compression algorithm distorts an image relative to some other compression algorithm.

This is a patch against the Python Imaging Library Imaging-1.1.6. This adds the method ImageChops.difference_rms(im1, im2) which returns a float of 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" />