@@ 5,6 5,7 @@ Copyright (C) 2006 Yangli Hector Yee
Go version Copyright (C) 2012 Sean Russell
This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as published by
the Free Software Foundation.
@@ 14,45 15,62 @@ WARRANTY; without even the implied warra
PARTICULAR PURPOSE. See the GNU General Public License for more details in the
+This is a translation of Yangli Hector Yee's C++ perceptual diffing algorithm
+for images; you can find the original source here:
+Version 1.0.0 of the Go version is a literal translation, with very little
+alteration for Go idioms; one exception is RGBAImage, which was largely
+unnecessary due to Go's image library. Another was the removal of the hand-coded
+parseargs code in favor of Go's flag library. A third was some re-partitioning
+of code for the arguments handling and set-up.
+Some notes about this translation:
+1. There were no tests in the original software, and the first Go version also
+ has no automated tests.
+2. Yangli's code was a pleasure to translate: it was optimized, but
+ selectively; it was readable; it was clean.
+3. I've included an executable analog for Yangli's executable, but a library
+ can also be built for inclusion in other programs.
-1. Download cross platform make from http://www.cmake.org
-2. Download freeimage from https://sourceforge.net/projects/freeimage
-3. Edit CMakeLists.txt to tell it where to find your free image build
-4. Type cmake .
-5. Type make . (or on Windows systems cmake makes a Visual Studio
-6. To specify the install directory, use make install DESTDIR="/home/me/mydist"
+For the library:
+ go get hg.germane-software.com/perceptualdiff
+For the executable:
+ go get hg.germane-software.com/perceptualdiff/perceptualdiff
+There are no other dependencies.
-perceptualdiff image1.(tif | png) image2.(tif | png) [options]
--verbose : Turns on verbose mode
--fov deg: field of view, deg, in degrees. Usually between 10.0 to 85.0.
-This controls how much of the screen the oberserver is seeing. Front row of
-a theatre has a field of view of around 25 degrees. Back row has a field of
- view of around 60 degrees.
--threshold p : Sets the number of pixels, p, to reject. For example if p is
- 100, then the test fails if 100 or more pixels are perceptably different.
--gamma g : The gamma to use to convert to RGB linear space. Default is 2.2
--luminance l: The luminance of the display the observer is seeing. Default
- is 100 candela per meter squared
--colorfactor : How much of color to use, 0.0 to 1.0, 0.0 = ignore color.
--downsample : How many powers of two to down sample the image.
--output foo.ppm : Saves the difference image to foo.ppm
+perceptualdiff [options] image1.(jpg | png) image2.(jpg | png)
+ -verbose : Turns on verbose mode
+ -fov deg : field of view, deg, in degrees. Usually between 10.0 to 85.0.
+ This controls how much of the screen the oberserver is seeing.
+ Front row of a theatre has a field of view of around 25 degrees.
+ Back row has a field of view of around 60 degrees.
+ -threshold p : Sets the number of pixels, p, to reject. For example if p is
+ 100, then the test fails if 100 or more pixels are perceptably
+ -gamma g : The gamma to use to convert to RGB linear space. Default is 2.2
+ -luminance l: The luminance of the display the observer is seeing. Default
+ is 100 candela per meter squared
+ -colorfactor : How much of color to use, 0.0 to 1.0, 0.0 = ignore color.
+ -downsample : How many powers of two to down sample the image.
+ -output foo.(jpg|png) : Saves the difference image
Hector Yee, project administrator and originator - hectorgon.blogspot.com
-Scott Corley, for png file IO code
-Tobias Sauerwein, for make install, package_source Cmake configuration
Cairo Team for bugfixes
-Jim Tilander, Rewrote the IO to use FreeImage.
+Sean Russell did the Go translation
-1.0 - Initial distribution
-1.0.1 - Fixed off by one convolution error and libpng interface to 1.2.8
-1.0.2 - [jt] Converted the loading and saving routines to use FreeImage
-1.1 - Added colorfactor and downsample options. Also always output
-difference file if requested. Always print out differing pixels even if the test passes.
-1.1.1 - Turn off color test in low lighting conditions.
+1.0.0 - Initial distribution
@@ 28,7 28,9 @@ import (
-const copyright = `PerceptualDiff version 1.1.1, Copyright (C) 2006 Yangli Hector Yee
+const copyright = `PerceptualDiff Go version 1.0.0
+Original Copyright (C) 2006 Yangli Hector Yee
+Go version Copyright (C) 2012 Sean E. Russell
PerceptualDiff comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome
to redistribute it under certain conditions
@@ 68,9 70,6 @@ func parse_Args(c *perceptualdiff.Compar
fmt.Printf("PeceptualDiff <image1> <image2>\n\n")
fmt.Printf("Compares image1 and image2 using a perceptually based image metric\n")
- fmt.Printf("Note: Input or Output files can also be in the PNG or JPG format ")
- fmt.Printf("or any format\n")
- fmt.Printf("that FreeImage supports.\n")