mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 20:30:14 +08:00
Add cube selem.
This commit is contained in:
@@ -114,3 +114,29 @@ def disk(radius, dtype=np.uint8):
|
||||
s = X**2
|
||||
s += Y**2
|
||||
return np.array(s <= radius * radius, dtype=dtype)
|
||||
|
||||
|
||||
def cube(width, dtype=np.uint8):
|
||||
"""
|
||||
Generates a cube-shaped structuring element (the 3D equivalent of
|
||||
a square). Every pixel along the perimeter has a chessboard distance
|
||||
no greater than radius (radius=floor(width/2)) pixels.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
width : int
|
||||
The width, height and depth of the cube
|
||||
|
||||
Other Parameters
|
||||
----------------
|
||||
dtype : data-type
|
||||
The data type of the structuring element.
|
||||
|
||||
Returns
|
||||
-------
|
||||
selem : ndarray
|
||||
A structuring element consisting only of ones, i.e. every
|
||||
pixel belongs to the neighborhood.
|
||||
|
||||
"""
|
||||
return np.ones((width, width, width), dtype=dtype)
|
||||
|
||||
Reference in New Issue
Block a user