ImageMagick内部入門第十七回、Distortion #2 Shepards

>100 Views

May 01, 24

スライド概要

profile-image

バイナリはともだち。こわくないよ

シェア

またはPlayer版

埋め込む »CMSなどでJSが使えない場合

関連スライド

各ページのテキスト
1.

ImageMagick 内部入門 第十七回 (Distortion〜空間歪曲#2) Shepards 2024/4/26(金) “よや” <[email protected]>

2.

内部入門シリーズ(1/2) • (第一回) 全体構成 • (第二回) データ構造 〜 ImageList, ImageInfo • (第三回) Magick API 〜 MagickWand / MagickCore • (第四回) 画像形式処理 〜 Coders と Delegate • (第五回) メタデータ 〜 XMP, Profile • (第六回) システム設定 〜 policy.xml 等 • (第七回) 減色 〜 ColorCube • (第八回) ビットdepth 〜 depth 変換 • (第九回) 2値化 〜 threshold • (第十回) ディザリング 〜 組織 (拡散ディザは延期) • (第十一回) ICCプロファイル 〜 RGB  CMYK 色空間 • (第十二回) 色フィルタ 〜 Colorize ColorMatrix

3.

内部入門シリーズ (2/2) • (第十三回) 色modulate 〜 modulate (変調) • (第十四回) WebP 画像 • (第十五回) 画像比較 〜 Compare • (第十六回) 空間歪曲#1 〜 Distortion SRT, Affine, Perspective • (第十七回) 空間歪曲#2 〜 Distortion Shepards ← 今回の話 • (第十八回) 空間置換#2 〜 Composite Displacement • (第十九回) 空間歪曲#3 〜 Distortion Resize • (第二十回) 空間歪曲#4 〜 Distortion ARC, Polar, Barrel • (第二十一回) 畳み込み 〜畳み込み、 Convolve • (第N回) 各画像処理 • モルフォロジー、OpenMP, distribute-pixel-cache

4.

目次 • -distort Shepards の使い方 • Shepard's アルゴリズム • ImageMagick Shepard's 実装 • Shepard の名前の由来 • Shepard's アルゴリズムができた経緯 • Displaceと似てる?

5.

Distortion shepards • Pin を動かして画像を歪めるような操作ができる • 周りも引きずられるのでシームレス(つなぎ目無し)

6.

Distortion shepards • 指定した点を移動して、残りも Shepard's algorithm で補間 % magick wizard: -distort Shepards "0,0,100,100,300,300,200,200" wizard-shepards.jpg 0,0 100,100 300,300 200,200

7.

Distortion shepards • (ちなみに)一点だけだと、ただの全体移動 % magick wizard: -distort Shepards "0,0,100,100" wizard-shepards.jpg 0,0 100,100

8.

Shepard's algorithm • Inverse distance weighting とも呼ぶ • https://en.wikipedia.org/wiki/Inverse_distance_weighting • 制御点との距離の逆数で重み付けして補間する

9.

Shepard's algorithm (p乗) • 2乗 を p 乗に拡張 • p = 2 のバランスが良い • p を大きくほど分離具合が強くなる

10.

Shepard's algorithm (近傍参照) • 制御点が増えると重たくなる • 近傍のみ計算する方法もある

11.

ImageMagick の Shepard はどっち? • pはいくつ? • デフォルトは p = 2.0 • ImageMagick では -define shepards:power=(数値) で変更可 • -define shepards:power=2.5 のように実数型を指定する • 近傍参照は? • 近傍に絞らない。全制御点を毎度計算する • つまりパラメータが増えると指数的に重たくなる

12.

Distortion shepards 実装 • MagickCore/distort.c • arguments が引数 • s.x, s.y は変換前(src)座標 • coeff[0]は power/2 の値

13.

そもそも Shepards とは? • https://dl.acm.org/doi/pdf/10.1145/800186.810616 • A two-dimensional interpolation function for irregularly-spaced data • By DONALD SHEPARD – Harvard College • 二次元画像の任意の歪みに対する良い補間方法 • ハーバード大学の研究生 > Shepard 氏

14.

Shepard's algorithm のできた経緯 • 元々、ハーバード大学の GIS ソフト、SYMAP の副産物 • https://en.wikipedia.org/wiki/Inverse_distance_weighting The motive force behind the Laboratory, Howard Fisher, conceived an improved computer mapping program that he called SYMAP, which, from the start, Fisher wanted to improve on the interpolation. He showed Harvard College freshmen his work on SYMAP, and many of them participated in Laboratory events. One freshman, Donald Shepard, decided to overhaul the interpolation in SYMAP, resulting in his famous article from 1968. • https://en.wikipedia.org/wiki/Harvard_Laboratory_for_Comp uter_Graphics_and_Spatial_Analysis • GIS 情報を地図上にマッピングする • 地球の歪みがあるので座標変換が複雑

15.

Displace と似てる? • 任意の点を移動という点で Compose Displace を連想する • が、Displace は全ピクセルの座標変換の結果を全て明示的に指 定するので、Shepard's algorithmのような処理はなく全く別も の • 処理は全く似てない (主観)

16.

参考URL • https://www.imagemagick.org/Usage/distorts/#freeform_dis torts

17.

まとめ (目次と同じ) • -distort Shepards の使い方 • Shepard's アルゴリズム • ImageMagick Shepard's 実装 • Shepard の名前の由来 • Shepard's アルゴリズムができた経緯 • Displaceと似てる?

18.

おしまい