end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

画像用diff : Perceptual Image Diff

moongiftで画像用のdiffツール「Perceptual Image Diff (pdiff)」が紹介されていました。

http://www.moongift.jp/2008/07/perceptual_image_diff/

win環境でも動作するそうですが、colinux環境にインストールしてみました。

srcの入手

http://pdiff.sourceforge.net/
pdiff自体は、sourceforge から入手できます。
現時点での最新は、ver.1.0.2のようですので、
PerceptualDiff-1.0.2.tar.gz をダウンロードしました。

依存ツールのインストール

README.txtにあるようにpdiffをインストールするには、cdiffやFreeImageを予めインストールする必要があります。
cdiffは「yum install cmake」でインストールし、FreeInputはsrcからインストールしました。
これらのインストールには特に注意すこともなかったので、ここで詳しい内容は記載しません。

Build Instructions
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
Project file)
6. To specify the install directory, use make install DESTDIR="/home/me/mydist"

pdiffのコンパイル

といっても、「cmake .」と「make」を実行するだけで、perceptualdiff が作成されます。

pdiffの使い方

と言っても、pdiffの使い方は、--helpで表示される通りです。

[endo@colinux PerceptualDiff-1.0.2]$ ./perceptualdiff --help
PerceptualDiff version 1.0.2, Copyright (C) 2006 Yangli Hector Yee
PerceptualDiff comes with ABSOLUTELY NO WARRANTY;
This is free software, and you are welcome
to redistribute it under certain conditions;
See the GPL page for details: http://www.gnu.org/copyleft/gpl.html

PeceptualDiff image1.tif image2.tif

   Compares image1.tif and image2.tif using a perceptually based image metric
   Options:
        -verbose       : Turns on verbose mode
        -fov deg       : Field of view in degrees (0.1 to 89.9)
        -threshold p     : #pixels p below which differences are ignored
        -gamma g       : Value to convert rgb into linear space (default 2.2)
        -luminance l   : White luminance (default 100.0 cdm^-2)
        -luminanceonly : Only consider luminance; ignore chroma (color) in the comparison
        -output o.ppm  : Write difference to the file o.ppm


 Note: Input or Output files can also be in the PNG or JPG format or any format
 that FreeImage supports.
[endo@colinux PerceptualDiff-1.0.2]$ 

pdiffを使ってみて

今回、pdiffを試した感想は次の通りです。

  • tifファイルを比較するのであれば、マルチページtifも比較して欲しいなぁ
  • a4サイズのtifを比較するのに、私のcolinux on let's noteでは、2-3分かかりました。
  • 比較結果として出力されるppmファイルは、win環境では、閲覧できるアプリが出回っていないようなので、今回は、ppm2tifで変換しました。