Module Expr Str Import alias identifier ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults Str NameLoad NameLoad body Expr Str Assert CompareEq Call NameLoad AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr If BoolOpAnd CompareEq NameLoad Str Call AttributeLoad NameLoad attr CompareGt NameLoad NameLoad body Raise Call NameLoad Str orelse If BoolOpAnd CompareEq NameLoad Str Call AttributeLoad NameLoad attr CompareLt NameLoad NameLoad body Raise Call NameLoad Str TryExcept body ImportFrom alias handlers ExceptHandler type NameLoad body Raise Call NameLoad Str If CompareIs NameLoad NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpMult ListLoad Num AttributeLoad NameLoad attr keyword NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIs NameLoad NameLoad body If UnaryOpNot Call NameLoad ListComp CompareEq BinOpMod NameLoad Num Num comprehension NameStore AttributeLoad NameLoad attr body Raise Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr ListComp BinOpFloorDiv NameLoad Num comprehension NameStore AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index ListComp Call NameLoad NameLoad BinOpAdd NameLoad Num comprehension NameStore NameLoad NameLoad Assign NameStore Call AttributeLoad BinOpDiv Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Num attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd AttributeLoad NameLoad attr Num keyword NameLoad Assign SubscriptStore NameLoad Slice Num BinOpAdd Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpMult Num NameLoad Assign SubscriptStore NameLoad Index Num Num Assign NameStore ListComp Call NameLoad NameLoad UnaryOpUSub NameLoad comprehension NameStore NameLoad If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse Raise Call NameLoad BinOpMod Str NameLoad Assign NameStore BinOpMult Call AttributeLoad NameLoad attr NameLoad NameLoad Assign SubscriptStore NameLoad Index BinOpAdd ListLoad Num NameLoad NameLoad Assign SubscriptStore NameLoad Index BinOpAdd ListLoad Num NameLoad NameLoad Assign NameStore BinOpFloorDiv Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Slice Num AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore BinOpFloorDiv SubscriptLoad AttributeLoad NameLoad attr Index Num AttributeLoad AttributeLoad NameLoad attr attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index ListComp Call NameLoad UnaryOpUSub NameLoad BinOpSub NameLoad NameLoad comprehension TupleStore NameStore NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad SubscriptLoad NameLoad ExtSlice Slice Index NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr ListComp Call AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad comprehension NameStore NameLoad AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr AttributeLoad NameLoad attr If CompareEq NameLoad Str body Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore UnaryOpUSub Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr Assign NameStore UnaryOpUSub Call AttributeLoad NameLoad attr Call NameLoad NameLoad AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Slice Num SubscriptLoad NameLoad Slice Num Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Slice Num SubscriptLoad NameLoad Slice Num If CompareEq NameLoad Str body Assign TupleStore NameStore NameStore Call NameLoad NameLoad orelse If CompareEq NameLoad Str body Assign TupleStore NameStore NameStore Call NameLoad UnaryOpUSub NameLoad Assign NameStore UnaryOpUSub NameLoad Assign NameStore SubscriptLoad NameLoad Index Num Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index SubscriptLoad NameLoad Slice NameLoad Assign AttributeStore NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr BinOpMult Num NameLoad Return SubscriptLoad NameLoad Index NameLoad decorator_list
N/A N/A 
This morphological reconstruction routine was adapted from CellProfiler, code
licensed under both GPL and BSD licenses.

Website: http://www.cellprofiler.org
Copyright (c) 2003-2009 Massachusetts Institute of Technology
Copyright (c) 2009-2011 Broad Institute
All rights reserved.
Original author: Lee Kamentsky

 N/A numpy np filters._rank_order rank_order reconstruction N/A N/A seed mask method selem offset N/A dilation None None N/A N/A Perform a morphological reconstruction of an image.

    Morphological reconstruction by dilation is similar to basic morphological
    dilation: high-intensity values will replace nearby low-intensity values.
    The basic dilation operator, however, uses a structuring element to
    determine how far a value in the input image can spread. In contrast,
    reconstruction uses two images: a "seed" image, which specifies the values
    that spread, and a "mask" image, which gives the maximum allowed value at
    each pixel. The mask image, like the structuring element, limits the spread
    of high-intensity values. Reconstruction by erosion is simply the inverse:
    low-intensity values spread from the seed image and are limited by the mask
    image, which represents the minimum allowed value.

    Alternatively, you can think of reconstruction as a way to isolate the
    connected regions of an image. For dilation, reconstruction connects
    regions marked by local maxima in the seed image: neighboring pixels
    less-than-or-equal-to those seeds are connected to the seeded region.
    Local maxima with values larger than the seed image will get truncated to
    the seed value.

    Parameters
    ----------
    seed : ndarray
        The seed image (a.k.a. marker image), which specifies the values that
        are dilated or eroded.
    mask : ndarray
        The maximum (dilation) / minimum (erosion) allowed value at each pixel.
    method : {'dilation'|'erosion'}
        Perform reconstruction by dilation or erosion. In dilation (or
        erosion), the seed image is dilated (or eroded) until limited by the
        mask image. For dilation, each seed value must be less than or equal
        to the corresponding mask value; for erosion, the reverse is true.
    selem : ndarray
        The neighborhood expressed as a 2-D array of 1's and 0's.

    Returns
    -------
    reconstructed : ndarray
       The result of morphological reconstruction.

    Examples
    --------
    >>> import numpy as np
    >>> from skimage.morphology import reconstruction

    First, we create a sinusoidal mask image with peaks at middle and ends.

    >>> x = np.linspace(0, 4 * np.pi)
    >>> y_mask = np.cos(x)

    Then, we create a seed image initialized to the minimum mask value (for
    reconstruction by dilation, min-intensity values don't spread) and add
    "seeds" to the left and right peak, but at a fraction of peak value (1).

    >>> y_seed = y_mask.min() * np.ones_like(x)
    >>> y_seed[0] = 0.5
    >>> y_seed[-1] = 0
    >>> y_rec = reconstruction(y_seed, y_mask)

    The reconstructed image (or curve, in this case) is exactly the same as the
    mask image, except that the peaks are truncated to 0.5 and 0. The middle
    peak disappears completely: Since there were no seed values in this peak
    region, its reconstructed value is truncated to the surrounding value (-1).

    As a more practical example, we try to extract the bright features of an
    image by subtracting a background image created by reconstruction.

    >>> y, x = np.mgrid[:20:0.5, :20:0.5]
    >>> bumps = np.sin(x) + np.sin(y)

    To create the background image, set the mask image to the original image,
    and the seed image to the original image with an intensity offset, `h`.

    >>> h = 0.3
    >>> seed = bumps - h
    >>> background = reconstruction(seed, bumps)

    The resulting reconstructed image looks exactly like the original image,
    but with the peaks of the bumps cut off. Subtracting this reconstructed
    image from the original image leaves just the peaks of the bumps

    >>> hdome = bumps - background

    This operation is known as the h-dome of the image and leaves features
    of height `h` in the subtracted image.

    Notes
    -----
    The algorithm is taken from [1]_. Applications for greyscale reconstruction
    are discussed in [2]_ and [3]_.

    References
    ----------
    .. [1] Robinson, "Efficient morphological reconstruction: a downhill
           filter", Pattern Recognition Letters 25 (2004) 1759-1767.
    .. [2] Vincent, L., "Morphological Grayscale Reconstruction in Image
           Analysis: Applications and Efficient Algorithms", IEEE Transactions
           on Image Processing (1993)
    .. [3] Soille, P., "Morphological Image Analysis: Principles and
           Applications", Chapter 6, 2nd edition (2003), ISBN 3540429883.
     N/A N/A N/A tuple N/A seed shape N/A tuple N/A mask shape N/A N/A N/A method dilation N/A N/A np any N/A seed mask N/A N/A N/A ValueError Intensity of seed image must be less than that of the mask image for reconstruction by dilation. N/A N/A N/A N/A method erosion N/A N/A np any N/A seed mask N/A N/A N/A ValueError Intensity of seed image must be greater than that of the mask image for reconstruction by erosion. N/A N/A _greyreconstruct reconstruction_loop N/A N/A N/A ImportError N/A N/A N/A ImportError _greyreconstruct extension not available. N/A N/A selem None N/A N/A selem N/A N/A np ones N/A N/A 3 N/A seed ndim dtype bool N/A N/A selem N/A N/A selem astype bool N/A N/A offset None N/A N/A N/A N/A all N/A N/A N/A d 2 1 N/A d N/A selem shape N/A N/A N/A ValueError Footprint dimensions must all be odd N/A offset N/A N/A np array N/A N/A d 2 N/A d N/A selem shape N/A N/A selem N/A N/A N/A slice d N/A d 1 N/A d offset False N/A padding N/A N/A N/A N/A N/A np array N/A selem shape 2 astype int N/A dims N/A N/A np zeros N/A N/A seed ndim 1 dtype int N/A N/A dims N/A 1 N/A N/A N/A np array N/A seed shape N/A 2 padding N/A N/A dims N/A 0 2 N/A inside_slices N/A N/A slice p N/A p N/A p padding N/A N/A method dilation N/A N/A pad_value N/A N/A np min seed N/A N/A N/A method erosion N/A N/A pad_value N/A N/A np max seed N/A N/A N/A ValueError N/A Reconstruction method can be one of 'erosion' or 'dilation'. Got '%s'. method N/A images N/A N/A N/A np ones dims pad_value N/A N/A images N/A N/A N/A 0 inside_slices seed N/A N/A images N/A N/A N/A 1 inside_slices mask N/A value_stride N/A N/A N/A np array N/A N/A images strides N/A 1 N/A N/A images dtype itemsize N/A image_stride N/A N/A N/A images strides N/A 0 N/A N/A images dtype itemsize N/A selem_mgrid N/A N/A np mgrid N/A N/A N/A slice N/A o N/A d o N/A N/A d o N/A zip N/A selem shape offset N/A selem_offsets N/A N/A N/A selem_mgrid N/A N/A N/A selem transpose N/A nb_strides N/A N/A np array N/A N/A N/A np sum N/A value_stride selem_offset N/A selem_offset selem_offsets N/A np int32 N/A images N/A N/A images flatten N/A index_sorted N/A N/A N/A N/A np argsort images astype N/A np int32 N/A N/A method dilation N/A N/A index_sorted N/A index_sorted N/A -1 N/A prev N/A N/A N/A np ones N/A len images N/A np int32 N/A next N/A N/A N/A np ones N/A len images N/A np int32 N/A N/A prev N/A N/A index_sorted N/A 1 N/A index_sorted N/A -1 N/A N/A next N/A N/A index_sorted N/A -1 N/A index_sorted N/A 1 N/A N/A method dilation N/A N/A N/A value_rank value_map N/A rank_order images N/A N/A N/A method erosion N/A N/A N/A value_rank value_map N/A rank_order N/A images N/A value_map N/A value_map N/A start N/A index_sorted N/A 0 N/A N/A reconstruction_loop value_rank prev next nb_strides start image_stride N/A rec_img N/A value_map N/A N/A value_rank N/A image_stride N/A N/A rec_img shape N/A N/A N/A np array N/A seed shape N/A 2 padding N/A N/A rec_img N/A inside_slices N/A