DualISO 処理ツール cr2hdr を mac で使う.


漢だったら DualISO で HDR 計測したいですよね!

http://www.magiclantern.fm/forum/?topic=7139.0
https://syoyo.wordpress.com/2013/09/01/550d-magic-lantern-dual-iso-finally-works/

でも DualISO 画像処理をしてくれる cr2hdr が mac 版は古くてしかも GUI 版しかありませんね... コマンドラインで新しいの使いたいですね.

cr2hdr のビルド

まず, Magic lantern のソースコードを checkout しておきます.

MagicLantern の C コードは gcc を前提にしていくつか gcc 固有の拡張が入っているので(Apple gcc(clang) ではコンパイルエラーになる), brew で gcc 5 あたりをインストールしておきます.

Makefile.user.default で PYTHON のパスを設定しなおします.

module/dual_iso に移ります.

Makefile.cr2hdr で HOSTCC と CR2HDR_CFLAG を修正します. Then,

$ make cr2hdr

Voala! cf2hdr が無事コンパイルできました.

cr2hdr を使う.

依存ツールを brew でインストールします.

$ brew install exiftool
$ brew install dcraw
$ ./cr2hdr cornellbox_dualiso.CR2 
cr2hdr: a post processing tool for Dual ISO images

Active options:
--amaze-edge    : use a temporary demosaic step (AMaZE) followed by edge-directed interpolation (default)
--cs2x2         : apply 2x2 chroma smoothing in noisy and aliased areas (default)
--wb=graymax    : set AsShotNeutral by maximizing the number of gray pixels (default)

Input file      : cornellbox_dualiso.CR2
Camera          : Canon EOS Kiss X4 (unknown, assuming 5D Mark III)
Full size       : 5344 x 3516
Active area     : 5202 x 3465
Black borders   : 142 left, 51 top
Black level     : 2048
ISO pattern     : dBBd GBRG
White levels    : 10194 12084
Noise levels    : 5.92 6.40 6.37 5.87 (14-bit)
ISO difference  : 1.01 EV (201)
Black delta     : 3.16
Black adjust    : -68
Dynamic range   : 10.44 (+) 10.62 => 11.62 EV (in theory)
Looking for hot/cold pixels...
Hot pixels      : 19
Cold pixels     : 8079
AMaZE interpolation ...
Amaze took 2.68 s
Edge-directed interpolation...
Semi-overexposed: 0.41%
Deep shadows    : 16.13%
Horizontal stripe fix...
Full-res reconstruction...
ISO overlap     : 6.4 EV (approx)
Half-res blending...
Chroma smoothing...
Building alias map...
Filtering alias map...
Smoothing alias map...
Final blending...
Noise level     : 171.27 (20-bit), ideally 165.62
Dynamic range   : 11.57 EV (cooked)
Black adjust    : -41
AsShotNeutral   : 0.47 1 0.63, 5553K/g=0.97 (gray max)
Output file     : cornellbox_dualiso.DNG 
cornellbox_dualiso.DNG: copying EXIF from cornellbox_dualiso.CR2

Voala! 無事処理された DNG が生成されました.

TODO

Dual ISO 処理がおそいので RAW 動画で連番を処理させるとたいへんなことに...

  • 画像処理のバッチ処理スケジューラーほしい.
    • Amazon プライムフォトに CR2 や RAW 動画をアップロードしておき, AWS Lambda でバッチ処理できないだろうか.
  • OpenCL とか GLSL とか MIT Halide とかで高速画像処理をしてくれる優秀な高速画像処理若人を探す旅に出たい.