def filter.morphology.join

gralha-svg-render@0.1.0.1 · svg.bend:4645

import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-image@0.1.0.1/image.bend as Img

4645# Morphology takes component-wise extrema of premultiplied channels.
4646def filter.morphology.join(+a: Img.Color, +b: Img.Color, +dilate: Bool) -> Img.Color:
4647  Img.Color{ar, ag, ab, aa} = a
4648  Img.Color{br, bg, bb, ba} = b
4649  Img.Color{U.choose(F32, dilate, U.max(ar, br), U.min(ar, br)), U.choose(F32, dilate, U.max(ag, bg), U.min(ag, bg)), U.choose(F32, dilate, U.max(ab, bb), U.min(ab, bb)), U.choose(F32, dilate, U.max(aa, ba), U.min(aa, ba))}

Uses (6)

Used by (1)