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


Python cucim.skimage.exposure.histogram用法及代碼示例

用法:

cucim.skimage.exposure.histogram(image, nbins=256, source_range='image', normalize=False)

返回圖像的直方圖。

numpy.histogram 不同,此函數返回 bin 的中心,並且不會重新組合整數數組。對於整數數組,每個整數值都有自己的 bin,這提高了速度和intensity-resolution。

在展平圖像上計算直方圖:對於彩色圖像,應在每個通道上單獨使用該函數以獲得每個顏色通道的直方圖。

參數

image數組

輸入圖像。

nbins整數,可選

用於計算直方圖的 bin 數量。對於整數數組,此值將被忽略。

source_range字符串,可選

‘image’(默認)確定輸入圖像的範圍。 ‘dtype’ 確定該數據類型圖像的預期範圍。

normalize布爾型,可選

如果為 True,則通過其值的總和對直方圖進行歸一化。

返回

hist數組

直方圖的值。

bin_centers數組

bin 中心的值。

例子

>>> import cupy as cp
>>> from skimage import data
>>> from cucim.skimage import exposure, img_as_float
>>> image = img_as_float(cp.array(data.camera()))
>>> cp.histogram(image, bins=2)
(array([ 93585, 168559]), array([0. , 0.5, 1. ]))
>>> exposure.histogram(image, nbins=2)
(array([ 93585, 168559]), array([0.25, 0.75]))

相關用法


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