Colour-layout converter for Image payloads. Re-encodes each input into the layout set by color_model — BGR, BGRA, GRAY, RGB, or RGBA. Use when downstream expects a specific channel layout different from what upstream emits.
Typical backends
Webcam frames arrive in one channel layout; the converter re-encodes them to the layout the classifier expects before inference.
Caveats
- I/O contractAn input already in the target layout is returned unmodified — no allocation, no copy, no precision loss.
- I/O contract`RGBA -> RGB` and `BGRA -> BGR` DROP the alpha channel; transparency is lost permanently.
- I/O contract`RGB -> RGBA` and `BGR -> BGRA` ADD an opaque alpha channel of `255`, not the source frame's alpha.
- AccuracyConversion to a single-channel grayscale target uses weighted luma (`0.299 R + 0.587 G + 0.114 B`), not channel averaging, via
color_model. - I/O contractPixel values are not rescaled or re-typed; only the channel layout and channel count change.
- Hard constraintAn unrecognised source/target pair raises an unsupported conversion error mid-tick and aborts the message.
- I/O contractThe output
Image's `color_space` field is updated to match color_model; downstream consumers must rely on that field rather than on assumptions about upstream layout. - State lifetime
color_model is captured once at startup; changing it requires a restart.