utilvo/browser_alpha_matting

1.1.2

Latest
uploaded 1 day ago
Fixed-point Q16 RGBA8888 straight-alpha foreground unmixing, halo decontamination, and RGB565 scanline compositing for ESP-IDF display pipelines.

Readme

# browser_alpha_matting (ESP-IDF C99 Component)

Division-free fixed-point (`Q16`) straight-alpha foreground color unmixing and `RGBA8888 -> RGB565` scanline compositing routines for ESP32 / ESP32-S3 / ESP32-P4 display pipelines (LVGL and `esp_lcd`).

## Mathematical Formulation

Given an observed boundary pixel $C_{\text{obs}}$ with alpha $\alpha \in (0, 1)$ composited over a known background $B$:

$$F = \text{clamp}_{[0,255]}\left(\frac{C_{\text{obs}} - (1 - \alpha) B}{\alpha}\right)$$

`bam_unmix_rgba8888_inplace` precomputes a 256-entry `Q16` reciprocal LUT on the stack so boundary decontamination executes in integer arithmetic without floating-point division traps on RISC-V or Xtensa cores.

## Usage

```c
#include "browser_alpha_matting.h"

// Remove white (255, 255, 255) background halo from an RGBA8888 sprite buffer
bam_unmix_rgba8888_inplace(sprite_rgba, width * height, 255, 255, 255, 6);
```

## Reference Implementation

Interactive browser reference implementation and alpha-matting test bench: [https://utilvo.com/background-remover](https://utilvo.com/background-remover)

## License

MIT

Links

To add this component to your project, run:

idf.py add-dependency "utilvo/browser_alpha_matting^1.1.2"

download archive

Stats

  • Archive size
    Archive size ~ 3.48 KB
  • Downloaded in total
    Downloaded in total 0 times
  • Downloaded this version
    This version: 0 times

Badge

utilvo/browser_alpha_matting version: 1.1.2
|