"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/exposure/exposure.py" between
scikit-image-0.19.2.tar.gz and scikit-image-0.19.3.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

exposure.py  (scikit-image-0.19.2):exposure.py  (scikit-image-0.19.3)
skipping to change at line 29 skipping to change at line 29
if low_boundary < 0: if low_boundary < 0:
offset = low_boundary offset = low_boundary
dyn_range = high_boundary - low_boundary dyn_range = high_boundary - low_boundary
# get smallest dtype that can hold both minimum and offset maximum # get smallest dtype that can hold both minimum and offset maximum
offset_dtype = np.promote_types(np.min_scalar_type(dyn_range), offset_dtype = np.promote_types(np.min_scalar_type(dyn_range),
np.min_scalar_type(low_boundary)) np.min_scalar_type(low_boundary))
if arr.dtype != offset_dtype: if arr.dtype != offset_dtype:
# prevent overflow errors when offsetting # prevent overflow errors when offsetting
arr = arr.astype(offset_dtype) arr = arr.astype(offset_dtype)
arr = arr - offset arr = arr - offset
else: return arr
offset = 0
return arr, offset
def _bincount_histogram_centers(image, source_range): def _bincount_histogram_centers(image, source_range):
"""Compute bin centers for bincount-based histogram.""" """Compute bin centers for bincount-based histogram."""
if source_range not in ['image', 'dtype']: if source_range not in ['image', 'dtype']:
raise ValueError( raise ValueError(
f'Incorrect value for `source_range` argument: {source_range}' f'Incorrect value for `source_range` argument: {source_range}'
) )
if source_range == 'image': if source_range == 'image':
image_min = int(image.min().astype(np.int64)) image_min = int(image.min().astype(np.int64))
image_max = int(image.max().astype(np.int64)) image_max = int(image.max().astype(np.int64))
skipping to change at line 73 skipping to change at line 71
Returns Returns
------- -------
hist : array hist : array
The values of the histogram. The values of the histogram.
bin_centers : array bin_centers : array
The values at the center of the bins. The values at the center of the bins.
""" """
if bin_centers is None: if bin_centers is None:
bin_centers = _bincount_histogram_centers(image, source_range) bin_centers = _bincount_histogram_centers(image, source_range)
image_min, image_max = bin_centers[0], bin_centers[-1] image_min, image_max = bin_centers[0], bin_centers[-1]
image, offset = _offset_array(image, image_min, image_max) image = _offset_array(image, image_min, image_max)
hist = np.bincount(image.ravel(), minlength=image_max - image_min + 1) hist = np.bincount(
image.ravel(), minlength=image_max - min(image_min, 0) + 1
)
if source_range == 'image': if source_range == 'image':
idx = max(image_min, 0) idx = max(image_min, 0)
hist = hist[idx:] hist = hist[idx:]
return hist, bin_centers return hist, bin_centers
def _get_outer_edges(image, hist_range): def _get_outer_edges(image, hist_range):
"""Determine the outer bin edges to use for `numpy.histogram`. """Determine the outer bin edges to use for `numpy.histogram`.
These are obtained from either the image or hist_range. These are obtained from either the image or hist_range.
 End of changes. 2 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)