jpeg_ghost_quality — IMGFORENSICS compression op

Data kinds: imagesimage2d

Call: import imgforensics; imgforensics.jpeg_ghost_quality(ghosts, qualities=None) -> 'np.ndarray' (or opsimgforensics.get("jpeg_ghost_quality"))

Usage

A series of ghost maps → a map of the quality at which each pixel's residual is smallest. `image2d`.

> The detailed description below is the original text — the summary and the headings are translated.

`qualities を省くと :func:jpeg_ghost_map` の既定(40..95 step 5)を仮定する

—— **枚数が合わなければ :class:ValueError**(添字と品質がずれた地図を返さない)。

返りは品質そのものを画素値に持つ `(H, W)` なので、値域は [0, 1] ではない。

表示するときは正規化すること(この op は数値を返すのであって絵を返さない)。

合成後に一度でも保存すると、この argmin は使えない。 2026-09-06 に

測った。背景 q92・素材 q60 で 32x32 を貼った 128x128 で:

==================== ================== ================

条件 貼付部の最頻品質 背景の最頻品質

==================== ================== ================

合成後に保存しない 60(正解) 95

合成後に q95 で保存 95(背景と同じ) 95

==================== ================== ================

理由は掃引の残差が品質に対して単調減少すること —— 最後の保存品質が

掃引の上端にあると、`argmin` は全画素でそこに張り付く(実測: 保存後の

残差平均は 230.7 → 5.9e-02 と一直線に下がる)。実運用の改竄は必ず保存を

経るので、この読み出しは実画像では定数地図になる。既存テスト

`test_jpeg_ghost_finds_the_pasted_quality` が通るのは、合成後に一度も

保存していないからである(それ自体は正しい単体テストで、argmin の実装は

間違っていない —— 読み出し方が現場に合わない)。

代わりに使うもの: 掃引方向の残差曲線の谷の深さ(局所的な凹み)。

同じ実験で画素ごとの ROC を取ると、argmin 読み出しは AUC 0.500(乱数と同じ)、

谷の深さ読み出しは AUC 0.997 / 偽陽性 1 % で検出率 0.944 だった

(`examples/poc_forensics_roc.py`)。それでも全体を q60 で保存し直すと

0.475 まで落ちる —— JPEG ゴーストは後処理に弱い、というのが正しい要約。

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Runnable examples (verified samples that actually call this op)

image_forensics_auditpy -3.11 examples/image_forensics_audit.py

poc_forensics_rocpy -3.11 examples/poc_forensics_roc.py

Ops the type connects to (they accept image2d as input)

perceptual_hash · fingerprint_correlate · error_level_map · jpeg_quality_estimate · jpeg_ghost_map · noise_inconsistency_map · copy_move_regions · watermark_embed

Same category (compression)

error_level_map · jpeg_quality_estimate · jpeg_ghost_map


*Provenance: imgforensics.py — IMGFORENSICS operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.