# pymatting/pymatting

A Python library for alpha matting

Repository: https://github.com/pymatting/pymatting
Canonical: https://ross.abutalabs.com/products/pymatting
Homepage: https://pymatting.github.io
Language: Python
License: MIT
License Family: permissive
Topics: alpha-matting, image-processing, foreground, python3
Last push: 2026-04-07T17:41:58+00:00

## Health v2 (maintenance only)
Score: 67/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 76, release rhythm 36, longevity 100
- inputs: {"age_days": 2413, "days_push": 148, "days_rel": 219, "gap_med": 385, "n_releases_24m": 2}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1914, forks 225 (observed 2026-08-28T04:05:53.610273+00:00)

## What it is
PyMatting is a Python library for alpha matting that estimates an alpha matte from an input image and a hand-drawn trimap to extract foreground objects. It implements multiple matting algorithms, foreground estimation, fast KNN search, and GPU-accelerated (CUDA/OpenCL) computation.

## Use cases
- cut out a subject from an image given a trimap
- estimate the alpha channel of a foreground object
- extract foreground pixels from a photo for compositing onto a new background
- compute alpha mattes with GPU acceleration
- compare alpha matting algorithm implementations in Python

## When to choose
- you have a trimap and need high-quality alpha matte estimation in Python
- you need multiple matting algorithms (closed-form, KNN, random walk, etc.) in one library
- you want GPU-accelerated foreground estimation via CUDA or OpenCL
- you need a simple cutout function for image editing pipelines

## When to avoid
- you need automatic background removal without a trimap
- you work outside Python or need a standalone GUI tool
- you need real-time video matting at high frame rates

## Facets
- artifact type: library
- maturity: active
- function: image-processing, machine-learning
- domain: image-processing, computer-vision, graphics
- platform: python, cross-platform
- tags: alpha-matting, trimap, foreground-extraction, cutout, image-segmentation, numba, cuda, opencl, gpu

## Member repositories
- pymatting/pymatting (main) score 67

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:53.610273+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:10:26.234956+00:00, confidence not recorded.
  - readme: https://github.com/pymatting/pymatting (fetched 2026-08-28T04:05:53.610273+00:00, sha 74382753f317)
  - homepage: https://pymatting.github.io (fetched 2026-08-29T10:49:40.312033+00:00, sha 6a921a31cd76)
  - registry_pypi: https://pypi.org/pypi/pymatting/json (fetched 2026-08-29T10:49:40.314559+00:00, sha d5649416f2b3)
- Data as of 2026-08-30T08:39:29.467469+00:00.
