This is a development version (0.26.1rc0.dev0) and may be unstable.Go to latest (0.26.1rc0.dev0+git20260530.b607368ff)
{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0 / skimage / color / colorconv / rgba2rgb

function

skimage.color.colorconv:rgba2rgb

source: /_skimage2/color/colorconv.py:185

Signature

def rgba2rgb(rgba, background = (1, 1, 1), *, channel_axis = -1)

Summary

RGBA to RGB conversion using alpha blending [1].

Parameters

rgba : (..., C=4, ...) array_like

The image in RGBA format. By default, the final dimension denotes channels.

background : array_like

The color of the background to blend the image with (3 floats between 0 to 1 - the RGB value of the background).

channel_axis : int, optional

This parameter indicates which axis of the array corresponds to channels.

Returns

out : (..., C=3, ...) ndarray

The image in RGB format. Same dimensions as input.

Raises

: ValueError

If rgba is not at least 2D with shape (..., 4, ...).

Examples

from skimage import color
from skimage import data
img_rgba = data.logo()
img_rgb = color.rgba2rgb(img_rgba)
✓

Aliases

  • skimage.color.rgba2rgb