當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python skimage.color.rgba2rgb用法及代碼示例

用法:

skimage.color.rgba2rgb(rgba, background=(1, 1, 1), *, channel_axis=- 1)

使用 Alpha 混合 [1] 進行 RGBA 到 RGB 轉換。

參數

rgba(..., 4, ...) 數組

RGBA 格式的圖像。默認情況下,最終維度表示通道。

backgroundarray_like

與圖像混合的背景顏色(0 到 1 之間的 3 個浮點數 - 背景的 RGB 值)。

channel_axisint 可選

該參數指示數組的哪個軸對應於通道。

返回

out(..., 3, ...)

RGB 格式的圖像。與輸入相同的尺寸。

拋出

ValueError

如果 rgba 不是至少 2D 的形狀 (..., 4, ...)。

參考

1(1,2)

https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending

例子

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

相關用法


注:本文由純淨天空篩選整理自scikit-image.org大神的英文原創作品 skimage.color.rgba2rgb。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。