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


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

用法:

skimage.color.rgb2gray(rgb, *, channel_axis=- 1)

計算 RGB 圖像的亮度。

參數

rgb(..., 3, ...) 數組

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

返回

outndarray

亮度圖像 - 一個與輸入數組大小相同的數組,但移除了通道維度。

拋出

ValueError

如果 rgb 不是至少 2-D 形狀 (..., 3, ...)。

注意

此轉換中使用的權重針對當代 CRT 熒光粉進行了校準:

Y = 0.2125 R + 0.7154 G + 0.0721 B

如果存在 Alpha 通道,則將其忽略。

參考

1

http://poynton.ca/PDFs/ColorFAQ.pdf

例子

>>> from skimage.color import rgb2gray
>>> from skimage import data
>>> img = data.astronaut()
>>> img_gray = rgb2gray(img)

相關用法


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