mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-03 05:11:30 +08:00
Merge pull request #640 from sciunto/missingdoc
DOCFIX: add docstrings to Cython grayscale dilate/erode & make them private funcs
This commit is contained in:
@@ -8,11 +8,34 @@ cimport numpy as np
|
||||
from libc.stdlib cimport malloc, free
|
||||
|
||||
|
||||
def dilate(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] out=None,
|
||||
char shift_x=0, char shift_y=0):
|
||||
def _dilate(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] out=None,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""Return greyscale morphological erosion of an image.
|
||||
|
||||
Morphological erosion sets a pixel at (i,j) to the minimum over all pixels
|
||||
in the neighborhood centered at (i,j). Erosion shrinks bright regions and
|
||||
enlarges dark regions.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : ndarray
|
||||
Image array.
|
||||
selem : ndarray
|
||||
The neighborhood expressed as a 2-D array of 1's and 0's.
|
||||
out : ndarray
|
||||
The array to store the result of the morphology. If None is
|
||||
passed, a new array will be allocated.
|
||||
shift_x, shift_y : bool
|
||||
shift structuring element about center point. This only affects
|
||||
eccentric structuring elements (i.e. selem with even numbered sides).
|
||||
|
||||
Returns
|
||||
-------
|
||||
eroded : uint8 array
|
||||
The result of the morphological erosion.
|
||||
"""
|
||||
cdef Py_ssize_t rows = image.shape[0]
|
||||
cdef Py_ssize_t cols = image.shape[1]
|
||||
cdef Py_ssize_t srows = selem.shape[0]
|
||||
@@ -63,10 +86,35 @@ def dilate(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
return out
|
||||
|
||||
|
||||
def erode(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] out=None,
|
||||
char shift_x=0, char shift_y=0):
|
||||
def _erode(np.ndarray[np.uint8_t, ndim=2] image,
|
||||
np.ndarray[np.uint8_t, ndim=2] selem,
|
||||
np.ndarray[np.uint8_t, ndim=2] out=None,
|
||||
char shift_x=0, char shift_y=0):
|
||||
"""Return greyscale morphological dilation of an image.
|
||||
|
||||
Morphological dilation sets a pixel at (i,j) to the maximum over all pixels
|
||||
in the neighborhood centered at (i,j). Dilation enlarges bright regions
|
||||
and shrinks dark regions.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
|
||||
image : ndarray
|
||||
Image array.
|
||||
selem : ndarray
|
||||
The neighborhood expressed as a 2-D array of 1's and 0's.
|
||||
out : ndarray
|
||||
The array to store the result of the morphology. If None, is
|
||||
passed, a new array will be allocated.
|
||||
shift_x, shift_y : bool
|
||||
shift structuring element about center point. This only affects
|
||||
eccentric structuring elements (i.e. selem with even numbered sides).
|
||||
|
||||
Returns
|
||||
-------
|
||||
dilated : uint8 array
|
||||
The result of the morphological dilation.
|
||||
"""
|
||||
|
||||
cdef Py_ssize_t rows = image.shape[0]
|
||||
cdef Py_ssize_t cols = image.shape[1]
|
||||
|
||||
@@ -58,8 +58,8 @@ def erosion(image, selem, out=None, shift_x=False, shift_y=False):
|
||||
raise NotImplementedError("In-place erosion not supported!")
|
||||
image = img_as_ubyte(image)
|
||||
selem = img_as_ubyte(selem)
|
||||
return cmorph.erode(image, selem, out=out,
|
||||
shift_x=shift_x, shift_y=shift_y)
|
||||
return cmorph._erode(image, selem, out=out,
|
||||
shift_x=shift_x, shift_y=shift_y)
|
||||
|
||||
|
||||
def dilation(image, selem, out=None, shift_x=False, shift_y=False):
|
||||
@@ -111,8 +111,8 @@ def dilation(image, selem, out=None, shift_x=False, shift_y=False):
|
||||
raise NotImplementedError("In-place dilation not supported!")
|
||||
image = img_as_ubyte(image)
|
||||
selem = img_as_ubyte(selem)
|
||||
return cmorph.dilate(image, selem, out=out,
|
||||
shift_x=shift_x, shift_y=shift_y)
|
||||
return cmorph._dilate(image, selem, out=out,
|
||||
shift_x=shift_x, shift_y=shift_y)
|
||||
|
||||
|
||||
def opening(image, selem, out=None):
|
||||
|
||||
Reference in New Issue
Block a user