import warnings
import numpy as np

from skimage import img_as_float
from skimage.util.dtype import dtype_range, dtype_limits
from skimage._shared.utils import deprecated


__all__ = ['histogram', 'cumulative_distribution', 'equalize',
           'rescale_intensity', 'adjust_gamma', 'adjust_log', 'adjust_sigmoid']


DTYPE_RANGE = dtype_range.copy()
DTYPE_RANGE.update((d.__name__, limits) for d, limits in dtype_range.items())
DTYPE_RANGE.update({'uint10': (0, 2**10 - 1),
                    'uint12': (0, 2**12 - 1),
                    'uint14': (0, 2**14 - 1),
                    'bool': dtype_range[np.bool_],
                    'float': dtype_range[np.float64]})


def histogram(image, nbins=256):
    """Return histogram of image.

    Unlike `numpy.histogram`, this function returns the centers of bins and
    does not rebin integer arrays. For integer arrays, each integer value has
    its own bin, which improves speed and intensity-resolution.

    The histogram is computed on the flattened image: for color images, the
    function should be used separately on each channel to obtain a histogram
    for each color channel.
Exemple #2
0
import warnings
import numpy as np

from skimage import img_as_float
from skimage.util.dtype import dtype_range, dtype_limits

__all__ = [
    'histogram', 'cumulative_distribution', 'equalize', 'rescale_intensity',
    'adjust_gamma', 'adjust_log', 'adjust_sigmoid'
]

DTYPE_RANGE = dtype_range.copy()
DTYPE_RANGE.update((d.__name__, limits) for d, limits in dtype_range.items())
DTYPE_RANGE.update({
    'uint10': (0, 2**10 - 1),
    'uint12': (0, 2**12 - 1),
    'uint14': (0, 2**14 - 1),
    'bool': dtype_range[np.bool_],
    'float': dtype_range[np.float64]
})


def histogram(image, nbins=256):
    """Return histogram of image.

    Unlike `numpy.histogram`, this function returns the centers of bins and
    does not rebin integer arrays. For integer arrays, each integer value has
    its own bin, which improves speed and intensity-resolution.

    The histogram is computed on the flattened image: for color images, the
    function should be used separately on each channel to obtain a histogram
Exemple #3
0
def test_invert_roundtrip():
    for t, limits in dtype_range.items():
        image = np.array(limits, dtype=t)
        expected = invert(invert(image))
        assert_array_equal(image, expected)