def histogram(image, nbins=256, lower_cut=0., cumulate=0):
"""
Compute the histogram of an input dataset.
Parameters
----------
image: Image
the image that contains the dataset to be analysed.
nbins: int, default 256
the histogram number of bins.
lower_cut: float, default 0
do not consider the intensities under this threshold.
cumulate: bool, default False
if set compute the cumulate histogram.
Returns
-------
hist_im: Image
the generated histogram.
"""
hist, bins = np.histogram(image.data[image.data > lower_cut], nbins)
if cumulate:
cdf = hist.cumsum()
cdf_normalized = cdf * hist.max() / cdf.max()
hist_im = pisap.Image(data=cdf_normalized)
else:
hist_im = pisap.Image(data=hist)
return hist_im
评论列表
文章目录