companding_mu_law — 2D gray op

Data kinds: imageimage

Call: fullseye.apply(img, "companding_mu_law", a=0.5, b=0.5) (the 2-D model is one image plus two scalar knobs a,b∈[0,1])

companding_mu_law: input → output

*The figure is the actual output on a synthetic 128×128 input. Left: input, right: output. Point clouds are drawn as a top-down scatter (brightness = z), 1-D series as a line plot, volumes as the maximum-intensity projection along z, videos as the middle frame, complex images as magnitude; return values that are not pictures are shown as the values themselves.*

Sweeping knob a (0.1 / 0.5 / 0.9, the other knob at its default):

companding_mu_law: knob a sweep (docs site)

Sweeping knob b (0.1 / 0.5 / 0.9, the other knob at its default):

companding_mu_law: knob b sweep (docs site)

On other images (synthetic scene / photo / coins. Top row: inputs, bottom row: their outputs. Knobs at default):

companding_mu_law: other inputs (docs site)

*The 4th column is a colour (H,W,3) input. This op handles colour without crossing channels (it does not convolve the colour channel as a third spatial axis).*

Usage

> This operator's description has not been translated yet. The original text follows as it is.

μ 則の圧伸(compand = compress + expand)。`a が μ、b` がビット数。

`F(x) = ln(1 + mu*x) / ln(1 + mu)` で暗部を伸ばしてから量子化し、逆変換で戻す。

結果として刻みが暗部で細かく明部で粗くなる —— 目も撮像系も暗部の差に敏感なので、

同じビット数で見た目の劣化が小さい。電話の音声符号化(G.711)と同じ原理で、

画像では対数的な階調割り当てにあたる。

`amu = 1 + 254*a(1〜255、a=0 で実質そのまま)、b` がビット数 1〜8。

Lloyd–Max との違い: あちらはその画像の分布に合わせるので符号表が画像ごとに

変わる。こちらは固定の曲線なので、別の画像・別の装置と値をそのまま比べられる。

分布が対数的に偏っているという仮定が当たっていれば近い性能が出て、外れていれば

Lloyd–Max のほうが良い。

適用条件(実測つき): 入力が `[0,1]` で、0 付近に画素が集中しているとき。

指数分布の合成画像で一様量子化と比べると、暗部集中なら二乗誤差は `0.57` 倍

(3 bit)・`0.51 倍(5 bit)に下がる。**明部集中では逆に 7.7` 倍(3 bit)・

`18` 倍(5 bit)悪化する** —— 白地に暗い傷、という検査画像はまさにこれなので、

そのときは `1 - x` を通してから当てること。段数が非常に少ないとき(2 bit)は

曲線が強すぎて偏った分布でも一様量子化に負ける(実測 1.17 倍)。

Detailed usage guide

gallery2d_gray_arith family guide

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.

Try it in Studio

The program below has been verified to run (same input as the figure). In Studio's help this block becomes buttons that load and run it on the spot.

companding_mu_law 0.50 0.50

▸ Load this pipeline  ·  Load & run

Runnable examples (verified samples that actually call this op)

gallery2d_gray_arithpy -3.11 examples/gallery2d_gray_arith.py

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

identity · gaussian · mean_box · bilateral · unsharp · median · min_filter · max_filter

Same category (gray)

gamma · quantize_uniform · quantize_lloyd_max · quantization_error · dither_ordered · dither_floyd_steinberg · banding_map · invert


*Provenance: ops.py — 2D 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.