mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-15 11:25:53 +08:00
add py wrappers
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from .rank import *
|
||||
from .percentile_rank import *
|
||||
from .bilateral_rank import *
|
||||
@@ -0,0 +1,18 @@
|
||||
"""
|
||||
:author: Olivier Debeir, 2012
|
||||
:license: modified BSD
|
||||
"""
|
||||
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import warnings
|
||||
from skimage import img_as_ubyte
|
||||
|
||||
__all__ = ['bilateral_mean']
|
||||
|
||||
|
||||
|
||||
def bilateral_mean(image, selem, out=None, shift_x=False, shift_y=False, s0=10, s1=10):
|
||||
pass
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""
|
||||
:author: Olivier Debeir, 2012
|
||||
:license: modified BSD
|
||||
"""
|
||||
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import warnings
|
||||
from skimage import img_as_ubyte
|
||||
|
||||
__all__ = ['percentile_mean']
|
||||
|
||||
|
||||
def percentile_mean(image, selem, out=None, shift_x=False, shift_y=False, p0=.0, p1=1.):
|
||||
"""Return greyscale local mean of an image.
|
||||
|
||||
Mean is computed on the given structuring element. Only pixel values contained inside the
|
||||
percentile interval [p0,p1] are taken into account.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : ndarray
|
||||
Image array (uint8 array or uint16).
|
||||
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).
|
||||
Shift is bounded to the structuring element sizes.
|
||||
|
||||
Returns
|
||||
-------
|
||||
local mean : uint8 array or uint16 array depending on input image
|
||||
The result of the local mean.
|
||||
|
||||
Examples
|
||||
--------
|
||||
to be updated
|
||||
>>> # Erosion shrinks bright regions
|
||||
>>> from skimage.morphology import square
|
||||
>>> bright_square = np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 0, 0, 0, 0]], dtype=np.uint8)
|
||||
>>> erosion(bright_square, square(3))
|
||||
array([[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 1, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0]], dtype=uint8)
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
"""
|
||||
:author: Olivier Debeir, 2012
|
||||
:license: modified BSD
|
||||
"""
|
||||
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import warnings
|
||||
from skimage import img_as_ubyte
|
||||
|
||||
__all__ = ['mean','percentile_mean','bilateral_mean']
|
||||
|
||||
|
||||
def percentile_mean(image, selem, out=None, shift_x=False, shift_y=False, p0=.0, p1=1.):
|
||||
"""Return greyscale local mean of an image.
|
||||
|
||||
Mean is computed on the given structuring element. Only pixel values contained inside the
|
||||
percentile interval [p0,p1] are taken into account.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : ndarray
|
||||
Image array (uint8 array or uint16).
|
||||
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).
|
||||
Shift is bounded to the structuring element sizes.
|
||||
|
||||
Returns
|
||||
-------
|
||||
local mean : uint8 array or uint16 array depending on input image
|
||||
The result of the local mean.
|
||||
|
||||
Examples
|
||||
--------
|
||||
to be updated
|
||||
>>> # Erosion shrinks bright regions
|
||||
>>> from skimage.morphology import square
|
||||
>>> bright_square = np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 0, 0, 0, 0]], dtype=np.uint8)
|
||||
>>> erosion(bright_square, square(3))
|
||||
array([[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 1, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0]], dtype=uint8)
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def bilateral_mean(image, selem, out=None, shift_x=False, shift_y=False, s0=10, s1=10):
|
||||
pass
|
||||
|
||||
def mean(image, selem, out=None, shift_x=False, shift_y=False):
|
||||
"""Return greyscale local mean of an image.
|
||||
|
||||
Mean is computed on the given structuring element.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
image : ndarray
|
||||
Image array (uint8 array or uint16).
|
||||
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).
|
||||
Shift is bounded to the structuring element sizes.
|
||||
|
||||
Returns
|
||||
-------
|
||||
local mean : uint8 array or uint16 array depending on input image
|
||||
The result of the local mean.
|
||||
|
||||
Examples
|
||||
--------
|
||||
to be updated
|
||||
>>> # Erosion shrinks bright regions
|
||||
>>> from skimage.morphology import square
|
||||
>>> bright_square = np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 0, 0, 0, 0]], dtype=np.uint8)
|
||||
>>> erosion(bright_square, square(3))
|
||||
array([[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 1, 0, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 0, 0]], dtype=uint8)
|
||||
|
||||
"""
|
||||
pass
|
||||
# if image is out:
|
||||
# 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)
|
||||
|
||||
|
||||
+10
-10
@@ -6,11 +6,11 @@ from Cython.Distutils import build_ext
|
||||
|
||||
setup(
|
||||
cmdclass = {'build_ext': build_ext},
|
||||
ext_modules = [Extension("crank8", ["_crank8.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("crank8_percentiles", ["_crank8_percentiles.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("crank16", ["_crank16.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("crank16_bilateral", ["_crank16_bilateral.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("crank16_percentiles", ["_crank16_percentiles.pyx"], include_dirs=[np.get_include()])]
|
||||
ext_modules = [Extension("_crank8", ["_crank8.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("_crank8_percentiles", ["_crank8_percentiles.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("_crank16", ["_crank16.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("_crank16_bilateral", ["_crank16_bilateral.pyx"], include_dirs=[np.get_include()]),
|
||||
Extension("_crank16_percentiles", ["_crank16_percentiles.pyx"], include_dirs=[np.get_include()])]
|
||||
)
|
||||
|
||||
|
||||
@@ -34,15 +34,15 @@ setup(
|
||||
# cython(['_crank16_percentiles.pyx'], working_path=base_path)
|
||||
# cython(['_crank16_bilateral.pyx'], working_path=base_path)
|
||||
#
|
||||
# config.add_extension('crank8', sources=['_crank8.c'],
|
||||
# config.add_extension('_crank8', sources=['_crank8.c'],
|
||||
# include_dirs=[get_numpy_include_dirs()])
|
||||
# config.add_extension('crank8_percentiles', sources=['_crank8_percentiles.c'],
|
||||
# config.add_extension('_crank8_percentiles', sources=['_crank8_percentiles.c'],
|
||||
# include_dirs=[get_numpy_include_dirs()])
|
||||
# config.add_extension('crank16', sources=['_crank16.c'],
|
||||
# config.add_extension('_crank16', sources=['_crank16.c'],
|
||||
# include_dirs=[get_numpy_include_dirs()])
|
||||
# config.add_extension('crank16_percentiles', sources=['_crank16_percentiles.c'],
|
||||
# config.add_extension('_crank16_percentiles', sources=['_crank16_percentiles.c'],
|
||||
# include_dirs=[get_numpy_include_dirs()])
|
||||
# config.add_extension('crank16_bilateral', sources=['_crank16_bilateral.c'],
|
||||
# config.add_extension('_crank16_bilateral', sources=['_crank16_bilateral.c'],
|
||||
# include_dirs=[get_numpy_include_dirs()])
|
||||
#
|
||||
# return config
|
||||
|
||||
@@ -2,18 +2,18 @@ import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.morphology import cmorph
|
||||
from skimage.rank import crank8
|
||||
from skimage.morphology import dilation
|
||||
from skimage.rank import _crank8
|
||||
|
||||
from tools import log_timing
|
||||
|
||||
@log_timing
|
||||
def cr_max(image,selem):
|
||||
return crank8.maximum(image=image,selem = selem)
|
||||
return _crank8.maximum(image=image,selem = selem)
|
||||
|
||||
@log_timing
|
||||
def cm_dil(image,selem):
|
||||
return cmorph.dilate(image=image,selem = selem)
|
||||
return dilation(image=image,selem = selem)
|
||||
|
||||
|
||||
def compare():
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
import skimage.rank as rank
|
||||
|
||||
print dir(rank)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user