Skip to main content

encode_rle

Function encode_rle 

Source
pub fn encode_rle(
    mask: &[u8],
    width: u32,
    height: u32,
) -> Result<CocoRle, Error>
Expand description

Encode a binary mask (row-major, 0/1 values) as COCO RLE.

COCO RLE uses column-major (Fortran) order, starting with a background count. This function transposes the input from row-major to column-major before run-length encoding.

§Arguments

  • mask - Binary mask in row-major order (0 = background, nonzero = foreground)
  • width - Image width in pixels
  • height - Image height in pixels

§Returns

A CocoRle with counts and size fields.