mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-20 12:40:31 +08:00
Merge pull request #1184 from stefanv/filter_rename
Rename and deprecate filter module to prevent shadowing of built-in keyword
This commit is contained in:
@@ -3,8 +3,9 @@ Remember to list any API changes below in `doc/source/api_changes.txt`.
|
||||
Version 0.13
|
||||
------------
|
||||
* Remove deprecated `None` defaults for `skimage.exposure.rescale_intensity`
|
||||
* Remove deprecated `skimage.filter.canny` import in filter/__init__.py file (canny is now in `skimage.feature.canny`).
|
||||
* Remove deprecated `skimage.filters.canny` import in filters/__init__.py file (canny is now in `skimage.feature.canny`).
|
||||
* Don't forget to complete api_changes.txt. (`GitHub discuss <https://github.com/scikit-image/scikit-image/pull/1113>`__ )
|
||||
* Remove deprecated ``skimage.filter`` module.
|
||||
|
||||
Version 0.12
|
||||
------------
|
||||
@@ -20,4 +21,4 @@ Version 0.12
|
||||
`skimage.transform.ProjectiveTransform._matrix`,
|
||||
`skimage.transform.PolynomialTransform._params`,
|
||||
`skimage.transform.PiecewiseAffineTransform.affines_*` attributes
|
||||
* Remove deprecated functions `skimage.filter.denoise_*`
|
||||
* Remove deprecated functions `skimage.filters.denoise_*`
|
||||
|
||||
+9
-9
@@ -33,7 +33,7 @@ UseBackends: Waf
|
||||
Library:
|
||||
Packages:
|
||||
skimage, skimage.color, skimage.data, skimage.draw, skimage.exposure,
|
||||
skimage.feature, skimage.filter, skimage.graph, skimage.io,
|
||||
skimage.feature, skimage.filters, skimage.graph, skimage.io,
|
||||
skimage.io._plugins, skimage.measure, skimage.morphology,
|
||||
skimage.scripts, skimage.restoration, skimage.segmentation,
|
||||
skimage.transform, skimage.util
|
||||
@@ -61,9 +61,9 @@ Library:
|
||||
Extension: skimage.transform._hough_transform
|
||||
Sources:
|
||||
skimage/transform/_hough_transform.pyx
|
||||
Extension: skimage.filter._ctmf
|
||||
Extension: skimage.filters._ctmf
|
||||
Sources:
|
||||
skimage/filter/_ctmf.pyx
|
||||
skimage/filters/_ctmf.pyx
|
||||
Extension: skimage.measure._ccomp
|
||||
Sources:
|
||||
skimage/measure/_ccomp.pyx
|
||||
@@ -127,18 +127,18 @@ Library:
|
||||
Extension: skimage._shared.geometry
|
||||
Sources:
|
||||
skimage/_shared/geometry.pyx
|
||||
Extension: skimage.filter.rank.generic_cy
|
||||
Extension: skimage.filters.rank.generic_cy
|
||||
Sources:
|
||||
skimage/filter/rank/generic_cy.pyx
|
||||
Extension: skimage.filter.rank.percentile_cy
|
||||
skimage/filters/rank/generic_cy.pyx
|
||||
Extension: skimage.filters.rank.percentile_cy
|
||||
Sources:
|
||||
skimage/filter/rank/percentile_cy.pyx
|
||||
Extension: skimage.filter.rank.core_cy
|
||||
Extension: skimage.filters.rank.core_cy
|
||||
Sources:
|
||||
skimage/filter/rank/core_cy.pyx
|
||||
Extension: skimage.filter.rank.bilateral_cy
|
||||
Extension: skimage.filters.rank.bilateral_cy
|
||||
Sources:
|
||||
skimage/filter/rank/bilateral_cy.pyx
|
||||
skimage/filters/rank/bilateral_cy.pyx
|
||||
Extension: skimage.restoration._unwrap_1d
|
||||
Sources:
|
||||
skimage/restoration/_unwrap_1d.pyx
|
||||
|
||||
@@ -109,7 +109,7 @@ find an elevation map using the Sobel gradient of the image.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter import sobel
|
||||
from skimage.filters import sobel
|
||||
|
||||
elevation_map = sobel(coins)
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ randomly set to 0. The **median** filter is applied to remove the noise.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import median
|
||||
from skimage.filters.rank import median
|
||||
from skimage.morphology import disk
|
||||
|
||||
noise = np.random.random(noisy_image.shape)
|
||||
@@ -107,7 +107,7 @@ image.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import mean
|
||||
from skimage.filters.rank import mean
|
||||
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=[10, 7])
|
||||
|
||||
@@ -133,11 +133,11 @@ the central one.
|
||||
.. note::
|
||||
|
||||
A different implementation is available for color images in
|
||||
`skimage.filter.denoise_bilateral`.
|
||||
`skimage.filters.denoise_bilateral`.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import mean_bilateral
|
||||
from skimage.filters.rank import mean_bilateral
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -183,7 +183,7 @@ equalization emphasizes every local gray-level variations.
|
||||
"""
|
||||
|
||||
from skimage import exposure
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -230,7 +230,7 @@ picture.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import autolevel
|
||||
from skimage.filters.rank import autolevel
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -260,7 +260,7 @@ result.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import autolevel_percentile
|
||||
from skimage.filters.rank import autolevel_percentile
|
||||
|
||||
image = data.camera()
|
||||
|
||||
@@ -298,7 +298,7 @@ otherwise by the minimum local.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import enhance_contrast
|
||||
from skimage.filters.rank import enhance_contrast
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -330,7 +330,7 @@ percentile *p0* and *p1* instead of the local minimum and maximum.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import enhance_contrast_percentile
|
||||
from skimage.filters.rank import enhance_contrast_percentile
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -366,19 +366,19 @@ threshold is determined by maximizing the variance between two classes of
|
||||
pixels of the local neighborhood defined by a structuring element.
|
||||
|
||||
The example compares the local threshold with the global threshold
|
||||
`skimage.filter.threshold_otsu`.
|
||||
`skimage.filters.threshold_otsu`.
|
||||
|
||||
.. note::
|
||||
|
||||
Local is much slower than global thresholding. A function for global Otsu
|
||||
thresholding can be found in : `skimage.filter.threshold_otsu`.
|
||||
thresholding can be found in : `skimage.filters.threshold_otsu`.
|
||||
|
||||
.. [4] http://en.wikipedia.org/wiki/Otsu's_method
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import otsu
|
||||
from skimage.filter import threshold_otsu
|
||||
from skimage.filters.rank import otsu
|
||||
from skimage.filters import threshold_otsu
|
||||
|
||||
p8 = data.page()
|
||||
|
||||
@@ -459,7 +459,7 @@ closing and morphological gradient.
|
||||
|
||||
"""
|
||||
|
||||
from skimage.filter.rank import maximum, minimum, gradient
|
||||
from skimage.filters.rank import maximum, minimum, gradient
|
||||
|
||||
noisy_image = img_as_ubyte(data.camera())
|
||||
|
||||
@@ -511,7 +511,7 @@ images.
|
||||
"""
|
||||
|
||||
from skimage import data
|
||||
from skimage.filter.rank import entropy
|
||||
from skimage.filters.rank import entropy
|
||||
from skimage.morphology import disk
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
@@ -549,7 +549,7 @@ from time import time
|
||||
|
||||
from scipy.ndimage.filters import percentile_filter
|
||||
from skimage.morphology import dilation
|
||||
from skimage.filter.rank import median, maximum
|
||||
from skimage.filters.rank import median, maximum
|
||||
|
||||
|
||||
def exec_and_timeit(func):
|
||||
|
||||
@@ -11,7 +11,7 @@ gradient of the image intensity function.
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage.data import camera
|
||||
from skimage.filter import roberts, sobel
|
||||
from skimage.filters import roberts, sobel
|
||||
|
||||
|
||||
image = camera()
|
||||
|
||||
@@ -10,7 +10,7 @@ coded in an image.
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.filter.rank import entropy
|
||||
from skimage.filters.rank import entropy
|
||||
from skimage.morphology import disk
|
||||
from skimage.util import img_as_ubyte
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ from scipy import ndimage as nd
|
||||
|
||||
from skimage import data
|
||||
from skimage.util import img_as_float
|
||||
from skimage.filter import gabor_kernel
|
||||
from skimage.filters import gabor_kernel
|
||||
|
||||
|
||||
def compute_feats(image, kernels):
|
||||
|
||||
@@ -14,7 +14,7 @@ import numpy as np
|
||||
from scipy import ndimage as nd
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage.filter import sobel
|
||||
from skimage.filters import sobel
|
||||
from skimage.segmentation import slic, join_segmentations
|
||||
from skimage.morphology import watershed
|
||||
from skimage.color import label2rgb
|
||||
|
||||
@@ -17,7 +17,7 @@ import matplotlib.pyplot as plt
|
||||
import matplotlib.patches as mpatches
|
||||
|
||||
from skimage import data
|
||||
from skimage.filter import threshold_otsu
|
||||
from skimage.filters import threshold_otsu
|
||||
from skimage.segmentation import clear_border
|
||||
from skimage.morphology import label, closing, square
|
||||
from skimage.measure import regionprops
|
||||
|
||||
@@ -28,7 +28,7 @@ from skimage.util.dtype import dtype_range
|
||||
from skimage.util import img_as_ubyte
|
||||
from skimage import exposure
|
||||
from skimage.morphology import disk
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
|
||||
matplotlib.rcParams['font.size'] = 9
|
||||
|
||||
@@ -20,7 +20,7 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.morphology import disk
|
||||
from skimage.filter import threshold_otsu, rank
|
||||
from skimage.filters import threshold_otsu, rank
|
||||
from skimage.util import img_as_ubyte
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from skimage.morphology import watershed, disk
|
||||
from skimage import data
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
from skimage.util import img_as_ubyte
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import matplotlib
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage.data import camera
|
||||
from skimage.filter import threshold_otsu
|
||||
from skimage.filters import threshold_otsu
|
||||
|
||||
|
||||
matplotlib.rcParams['font.size'] = 9
|
||||
|
||||
@@ -23,7 +23,7 @@ import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.morphology import disk
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
|
||||
image = (data.coins()).astype(np.uint16) * 16
|
||||
|
||||
@@ -18,7 +18,7 @@ local neighborhood minus an offset value.
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage.filter import threshold_otsu, threshold_adaptive
|
||||
from skimage.filters import threshold_otsu, threshold_adaptive
|
||||
|
||||
|
||||
image = data.page()
|
||||
|
||||
@@ -116,7 +116,7 @@ thresholding. In practice, you might want to define a region for tinting based
|
||||
on segmentation results or blob detection methods.
|
||||
"""
|
||||
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
# Square regions defined as slices over the first two dimensions.
|
||||
top_left = (slice(100),) * 2
|
||||
|
||||
@@ -13,7 +13,7 @@ extracted and a histogram of its greyscale values is computed.
|
||||
|
||||
Next, for each pixel in the test image, a histogram of the greyscale values in
|
||||
a region of the image surrounding the pixel is computed.
|
||||
`skimage.filter.rank.windowed_histogram` is used for this task, as it employs
|
||||
`skimage.filters.rank.windowed_histogram` is used for this task, as it employs
|
||||
an efficient sliding window based algorithm that is able to compute these
|
||||
histograms quickly [2]_. The local histogram for the region surrounding each
|
||||
pixel in the image is compared to that of the single coin, with a similarity
|
||||
@@ -42,7 +42,7 @@ import matplotlib.pyplot as plt
|
||||
from skimage import data, transform
|
||||
from skimage.util import img_as_ubyte
|
||||
from skimage.morphology import disk
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
|
||||
matplotlib.rcParams['font.size'] = 9
|
||||
|
||||
@@ -20,7 +20,7 @@ import skimage.io as sio
|
||||
from skimage import img_as_float
|
||||
from skimage.color import gray2rgb, rgb2gray
|
||||
from skimage.exposure import rescale_intensity
|
||||
from skimage.filter import sobel
|
||||
from skimage.filters import sobel
|
||||
|
||||
import scipy_logo
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Version 0.11
|
||||
------------
|
||||
- The ``skimage.filter`` subpackage has been renamed to ``skimage.filters``.
|
||||
- Some edge detectors returned values greater than 1--their results are now
|
||||
appropriately scaled with a factor of ``sqrt(2)``.
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ The choice of the elevation map is critical for good segmentation.
|
||||
Here, the amplitude of the gradient provides a good elevation map. We
|
||||
use the Sobel operator for computing the amplitude of the gradient::
|
||||
|
||||
>>> from skimage.filter import sobel
|
||||
>>> from skimage.filters import sobel
|
||||
>>> elevation_map = sobel(coins)
|
||||
|
||||
From the 3-D surface plot shown below, we see that high barriers effectively
|
||||
|
||||
@@ -51,7 +51,7 @@ call the total-variation denoising function, ``denoise_tv_bregman``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from skimage.filter import denoise_tv_bregman
|
||||
from skimage.filters import denoise_tv_bregman
|
||||
from skimage.viewer.plugins.base import Plugin
|
||||
|
||||
denoise_plugin = Plugin(image_filter=denoise_tv_bregman)
|
||||
|
||||
@@ -51,6 +51,7 @@ if __name__ == '__main__':
|
||||
docwriter = ApiDocWriter(package)
|
||||
docwriter.package_skip_patterns += [r'\.fixes$',
|
||||
r'\.externals$',
|
||||
r'filter$',
|
||||
]
|
||||
docwriter.write_api_docs(outdir)
|
||||
docwriter.write_index(outdir, 'api', relative_to='source/api')
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ exposure
|
||||
Image intensity adjustment, e.g., histogram equalization, etc.
|
||||
feature
|
||||
Feature detection and extraction, e.g., texture analysis corners, etc.
|
||||
filter
|
||||
filters
|
||||
Sharpening, edge finding, rank filters, thresholding, etc.
|
||||
graph
|
||||
Graph-theoretic operations, e.g., shortest paths.
|
||||
|
||||
@@ -109,7 +109,7 @@ def canny(image, sigma=1., low_threshold=None, high_threshold=None, mask=None):
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import filter
|
||||
>>> from skimage import filters
|
||||
>>> # Generate noisy image of a square
|
||||
>>> im = np.zeros((256, 256))
|
||||
>>> im[64:-64, 64:-64] = 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import numpy as np
|
||||
import scipy.ndimage as ndi
|
||||
from ..filter import rank_order
|
||||
from ..filters import rank_order
|
||||
|
||||
|
||||
def peak_local_max(image, min_distance=10, threshold_abs=0, threshold_rel=0.1,
|
||||
|
||||
+10
-52
@@ -1,56 +1,14 @@
|
||||
from .lpi_filter import inverse, wiener, LPIFilter2D
|
||||
from ._gaussian import gaussian_filter
|
||||
from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt,
|
||||
hprewitt, vprewitt, roberts, roberts_positive_diagonal,
|
||||
roberts_negative_diagonal)
|
||||
from ._rank_order import rank_order
|
||||
from ._gabor import gabor_kernel, gabor_filter
|
||||
from .thresholding import (threshold_adaptive, threshold_otsu, threshold_yen,
|
||||
threshold_isodata)
|
||||
from . import rank
|
||||
from skimage._shared.utils import skimage_deprecation
|
||||
from warnings import warn
|
||||
|
||||
from skimage._shared.utils import deprecated
|
||||
from skimage import restoration
|
||||
denoise_bilateral = deprecated('skimage.restoration.denoise_bilateral')\
|
||||
(restoration.denoise_bilateral)
|
||||
denoise_tv_bregman = deprecated('skimage.restoration.denoise_tv_bregman')\
|
||||
(restoration.denoise_tv_bregman)
|
||||
denoise_tv_chambolle = deprecated('skimage.restoration.denoise_tv_chambolle')\
|
||||
(restoration.denoise_tv_chambolle)
|
||||
global _import_warned
|
||||
|
||||
# Backward compatibility v<0.11
|
||||
@deprecated('skimage.feature.canny')
|
||||
def canny(*args, **kwargs):
|
||||
# Hack to avoid circular import
|
||||
from skimage.feature._canny import canny as canny_
|
||||
return canny_(*args, **kwargs)
|
||||
warn(skimage_deprecation('The `skimage.filter` module has been renamed '
|
||||
'to `skimage.filters`. This placeholder module '
|
||||
'will be removed in v0.13.'))
|
||||
_import_warned = True
|
||||
|
||||
del warn
|
||||
del skimage_deprecation
|
||||
|
||||
__all__ = ['inverse',
|
||||
'wiener',
|
||||
'LPIFilter2D',
|
||||
'gaussian_filter',
|
||||
'canny',
|
||||
'sobel',
|
||||
'hsobel',
|
||||
'vsobel',
|
||||
'scharr',
|
||||
'hscharr',
|
||||
'vscharr',
|
||||
'prewitt',
|
||||
'hprewitt',
|
||||
'vprewitt',
|
||||
'roberts',
|
||||
'roberts_positive_diagonal',
|
||||
'roberts_negative_diagonal',
|
||||
'denoise_tv_chambolle',
|
||||
'denoise_bilateral',
|
||||
'denoise_tv_bregman',
|
||||
'rank_order',
|
||||
'gabor_kernel',
|
||||
'gabor_filter',
|
||||
'threshold_adaptive',
|
||||
'threshold_otsu',
|
||||
'threshold_yen',
|
||||
'threshold_isodata',
|
||||
'rank']
|
||||
from ..filters import *
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
from .lpi_filter import inverse, wiener, LPIFilter2D
|
||||
from ._gaussian import gaussian_filter
|
||||
from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt,
|
||||
hprewitt, vprewitt, roberts, roberts_positive_diagonal,
|
||||
roberts_negative_diagonal)
|
||||
from ._rank_order import rank_order
|
||||
from ._gabor import gabor_kernel, gabor_filter
|
||||
from .thresholding import (threshold_adaptive, threshold_otsu, threshold_yen,
|
||||
threshold_isodata)
|
||||
from . import rank
|
||||
|
||||
from skimage._shared.utils import deprecated
|
||||
from skimage import restoration
|
||||
denoise_bilateral = deprecated('skimage.restoration.denoise_bilateral')\
|
||||
(restoration.denoise_bilateral)
|
||||
denoise_tv_bregman = deprecated('skimage.restoration.denoise_tv_bregman')\
|
||||
(restoration.denoise_tv_bregman)
|
||||
denoise_tv_chambolle = deprecated('skimage.restoration.denoise_tv_chambolle')\
|
||||
(restoration.denoise_tv_chambolle)
|
||||
|
||||
# Backward compatibility v<0.11
|
||||
@deprecated
|
||||
def canny(*args, **kwargs):
|
||||
# Hack to avoid circular import
|
||||
from skimage.feature._canny import canny as canny_
|
||||
return canny_(*args, **kwargs)
|
||||
|
||||
|
||||
__all__ = ['inverse',
|
||||
'wiener',
|
||||
'LPIFilter2D',
|
||||
'gaussian_filter',
|
||||
'canny',
|
||||
'sobel',
|
||||
'hsobel',
|
||||
'vsobel',
|
||||
'scharr',
|
||||
'hscharr',
|
||||
'vscharr',
|
||||
'prewitt',
|
||||
'hprewitt',
|
||||
'vprewitt',
|
||||
'roberts',
|
||||
'roberts_positive_diagonal',
|
||||
'roberts_negative_diagonal',
|
||||
'denoise_tv_chambolle',
|
||||
'denoise_bilateral',
|
||||
'denoise_tv_bregman',
|
||||
'rank_order',
|
||||
'gabor_kernel',
|
||||
'gabor_filter',
|
||||
'threshold_adaptive',
|
||||
'threshold_otsu',
|
||||
'threshold_yen',
|
||||
'threshold_isodata',
|
||||
'rank']
|
||||
@@ -66,9 +66,9 @@ class LPIFilter2D(object):
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Gaussian filter: Use a 1-D gaussian in each direction without
|
||||
normalization coefficients.
|
||||
|
||||
>>> def filt_func(r, c, sigma = 1):
|
||||
... return np.exp(-np.hypot(r, c)/sigma)
|
||||
>>> filter = LPIFilter2D(filt_func)
|
||||
@@ -89,13 +89,13 @@ def mean_bilateral(image, selem, out=None, mask=None, shift_x=False,
|
||||
|
||||
See also
|
||||
--------
|
||||
skimage.filter.denoise_bilateral for a Gaussian bilateral filter.
|
||||
skimage.filters.denoise_bilateral for a Gaussian bilateral filter.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import mean_bilateral
|
||||
>>> from skimage.filters.rank import mean_bilateral
|
||||
>>> img = data.camera().astype(np.uint16)
|
||||
>>> bilat_img = mean_bilateral(img, disk(20), s0=10,s1=10)
|
||||
|
||||
@@ -142,7 +142,7 @@ def pop_bilateral(image, selem, out=None, mask=None, shift_x=False,
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.morphology import square
|
||||
>>> import skimage.filter.rank as rank
|
||||
>>> import skimage.filters.rank as rank
|
||||
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
@@ -206,13 +206,13 @@ def sum_bilateral(image, selem, out=None, mask=None, shift_x=False,
|
||||
|
||||
See also
|
||||
--------
|
||||
skimage.filter.denoise_bilateral for a Gaussian bilateral filter.
|
||||
skimage.filters.denoise_bilateral for a Gaussian bilateral filter.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import sum_bilateral
|
||||
>>> from skimage.filters.rank import sum_bilateral
|
||||
>>> img = data.camera().astype(np.uint16)
|
||||
>>> bilat_img = sum_bilateral(img, disk(10), s0=10, s1=10)
|
||||
|
||||
@@ -126,7 +126,7 @@ def autolevel(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import autolevel
|
||||
>>> from skimage.filters.rank import autolevel
|
||||
>>> img = data.camera()
|
||||
>>> auto = autolevel(img, disk(5))
|
||||
|
||||
@@ -168,7 +168,7 @@ def bottomhat(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import bottomhat
|
||||
>>> from skimage.filters.rank import bottomhat
|
||||
>>> img = data.camera()
|
||||
>>> out = bottomhat(img, disk(5))
|
||||
|
||||
@@ -207,7 +207,7 @@ def equalize(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import equalize
|
||||
>>> from skimage.filters.rank import equalize
|
||||
>>> img = data.camera()
|
||||
>>> equ = equalize(img, disk(5))
|
||||
|
||||
@@ -246,7 +246,7 @@ def gradient(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import gradient
|
||||
>>> from skimage.filters.rank import gradient
|
||||
>>> img = data.camera()
|
||||
>>> out = gradient(img, disk(5))
|
||||
|
||||
@@ -287,14 +287,14 @@ def maximum(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
|
||||
Notes
|
||||
-----
|
||||
The lower algorithm complexity makes the `skimage.filter.rank.maximum`
|
||||
The lower algorithm complexity makes `skimage.filters.rank.maximum`
|
||||
more efficient for larger images and structuring elements.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import maximum
|
||||
>>> from skimage.filters.rank import maximum
|
||||
>>> img = data.camera()
|
||||
>>> out = maximum(img, disk(5))
|
||||
|
||||
@@ -333,7 +333,7 @@ def mean(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import mean
|
||||
>>> from skimage.filters.rank import mean
|
||||
>>> img = data.camera()
|
||||
>>> avg = mean(img, disk(5))
|
||||
|
||||
@@ -372,7 +372,7 @@ def subtract_mean(image, selem, out=None, mask=None, shift_x=False,
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import subtract_mean
|
||||
>>> from skimage.filters.rank import subtract_mean
|
||||
>>> img = data.camera()
|
||||
>>> out = subtract_mean(img, disk(5))
|
||||
|
||||
@@ -411,7 +411,7 @@ def median(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import median
|
||||
>>> from skimage.filters.rank import median
|
||||
>>> img = data.camera()
|
||||
>>> med = median(img, disk(5))
|
||||
|
||||
@@ -452,14 +452,14 @@ def minimum(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
|
||||
Notes
|
||||
-----
|
||||
The lower algorithm complexity makes the `skimage.filter.rank.minimum` more
|
||||
The lower algorithm complexity makes `skimage.filters.rank.minimum` more
|
||||
efficient for larger images and structuring elements.
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import minimum
|
||||
>>> from skimage.filters.rank import minimum
|
||||
>>> img = data.camera()
|
||||
>>> out = minimum(img, disk(5))
|
||||
|
||||
@@ -500,7 +500,7 @@ def modal(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import modal
|
||||
>>> from skimage.filters.rank import modal
|
||||
>>> img = data.camera()
|
||||
>>> out = modal(img, disk(5))
|
||||
|
||||
@@ -544,7 +544,7 @@ def enhance_contrast(image, selem, out=None, mask=None, shift_x=False,
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import enhance_contrast
|
||||
>>> from skimage.filters.rank import enhance_contrast
|
||||
>>> img = data.camera()
|
||||
>>> out = enhance_contrast(img, disk(5))
|
||||
|
||||
@@ -585,7 +585,7 @@ def pop(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.morphology import square
|
||||
>>> import skimage.filter.rank as rank
|
||||
>>> import skimage.filters.rank as rank
|
||||
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
@@ -635,7 +635,7 @@ def sum(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.morphology import square
|
||||
>>> import skimage.filter.rank as rank
|
||||
>>> import skimage.filters.rank as rank
|
||||
>>> img = np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
@@ -685,7 +685,7 @@ def threshold(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage.morphology import square
|
||||
>>> from skimage.filter.rank import threshold
|
||||
>>> from skimage.filters.rank import threshold
|
||||
>>> img = 255 * np.array([[0, 0, 0, 0, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
... [0, 1, 1, 1, 0],
|
||||
@@ -736,7 +736,7 @@ def tophat(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import tophat
|
||||
>>> from skimage.filters.rank import tophat
|
||||
>>> img = data.camera()
|
||||
>>> out = tophat(img, disk(5))
|
||||
|
||||
@@ -781,7 +781,7 @@ def noise_filter(image, selem, out=None, mask=None, shift_x=False,
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.morphology import disk
|
||||
>>> from skimage.filter.rank import noise_filter
|
||||
>>> from skimage.filters.rank import noise_filter
|
||||
>>> img = data.camera()
|
||||
>>> out = noise_filter(img, disk(5))
|
||||
|
||||
@@ -833,7 +833,7 @@ def entropy(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.filter.rank import entropy
|
||||
>>> from skimage.filters.rank import entropy
|
||||
>>> from skimage.morphology import disk
|
||||
>>> img = data.camera()
|
||||
>>> ent = entropy(img, disk(5))
|
||||
@@ -877,7 +877,7 @@ def otsu(image, selem, out=None, mask=None, shift_x=False, shift_y=False):
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.filter.rank import otsu
|
||||
>>> from skimage.filters.rank import otsu
|
||||
>>> from skimage.morphology import disk
|
||||
>>> img = data.camera()
|
||||
>>> local_otsu = otsu(img, disk(5))
|
||||
@@ -926,7 +926,7 @@ def windowed_histogram(image, selem, out=None, mask=None,
|
||||
Examples
|
||||
--------
|
||||
>>> from skimage import data
|
||||
>>> from skimage.filter.rank import windowed_histogram
|
||||
>>> from skimage.filters.rank import windowed_histogram
|
||||
>>> from skimage.morphology import disk
|
||||
>>> img = data.camera()
|
||||
>>> hist_img = windowed_histogram(img, disk(5))
|
||||
@@ -4,7 +4,7 @@ from numpy.testing import run_module_suite, assert_array_equal, assert_raises
|
||||
from skimage import img_as_ubyte, img_as_uint, img_as_float
|
||||
from skimage import data, util
|
||||
from skimage.morphology import cmorph, disk
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
|
||||
np.random.seed(0)
|
||||
|
||||
@@ -9,7 +9,7 @@ base_path = os.path.abspath(os.path.dirname(__file__))
|
||||
def configuration(parent_package='', top_path=None):
|
||||
from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
|
||||
|
||||
config = Configuration('filter', parent_package, top_path)
|
||||
config = Configuration('filters', parent_package, top_path)
|
||||
config.add_data_dir('tests')
|
||||
config.add_data_dir('rank/tests')
|
||||
|
||||
@@ -2,13 +2,13 @@ import numpy as np
|
||||
from numpy.testing import (assert_array_almost_equal as assert_close,
|
||||
assert_, assert_allclose)
|
||||
|
||||
import skimage.filter as F
|
||||
from skimage.filter.edges import _mask_filter_result
|
||||
from skimage import filters
|
||||
from skimage.filters.edges import _mask_filter_result
|
||||
|
||||
|
||||
def test_roberts_zeros():
|
||||
"""Roberts' filter on an array of all zeros."""
|
||||
result = F.roberts(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.roberts(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert (np.all(result == 0))
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ def test_roberts_diagonal1():
|
||||
expected = ~(np.tri(10, 10, -1).astype(bool) |
|
||||
np.tri(10, 10, -2).astype(bool).transpose())
|
||||
expected = _mask_filter_result(expected, None)
|
||||
result = F.roberts(image).astype(bool)
|
||||
result = filters.roberts(image).astype(bool)
|
||||
assert_close(result, expected)
|
||||
|
||||
|
||||
@@ -28,21 +28,21 @@ def test_roberts_diagonal2():
|
||||
expected = ~np.rot90(np.tri(10, 10, -1).astype(bool) |
|
||||
np.tri(10, 10, -2).astype(bool).transpose())
|
||||
expected = _mask_filter_result(expected, None)
|
||||
result = F.roberts(image).astype(bool)
|
||||
result = filters.roberts(image).astype(bool)
|
||||
assert_close(result, expected)
|
||||
|
||||
|
||||
def test_sobel_zeros():
|
||||
"""Sobel on an array of all zeros."""
|
||||
result = F.sobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.sobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert (np.all(result == 0))
|
||||
|
||||
|
||||
def test_sobel_mask():
|
||||
"""Sobel on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.sobel(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.sobel(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert (np.all(result == 0))
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ def test_sobel_horizontal():
|
||||
"""Sobel on a horizontal edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.sobel(image) * np.sqrt(2)
|
||||
result = filters.sobel(image) * np.sqrt(2)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert_allclose(result[i == 0], 1)
|
||||
@@ -61,7 +61,7 @@ def test_sobel_vertical():
|
||||
"""Sobel on a vertical edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.sobel(image) * np.sqrt(2)
|
||||
result = filters.sobel(image) * np.sqrt(2)
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert (np.all(result[j == 0] == 1))
|
||||
assert (np.all(result[np.abs(j) > 1] == 0))
|
||||
@@ -69,15 +69,15 @@ def test_sobel_vertical():
|
||||
|
||||
def test_hsobel_zeros():
|
||||
"""Horizontal sobel on an array of all zeros."""
|
||||
result = F.hsobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.hsobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert (np.all(result == 0))
|
||||
|
||||
|
||||
def test_hsobel_mask():
|
||||
"""Horizontal Sobel on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.hsobel(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.hsobel(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert (np.all(result == 0))
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ def test_hsobel_horizontal():
|
||||
"""Horizontal Sobel on an edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.hsobel(image)
|
||||
result = filters.hsobel(image)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert (np.all(result[i == 0] == 1))
|
||||
@@ -96,20 +96,20 @@ def test_hsobel_vertical():
|
||||
"""Horizontal Sobel on a vertical edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float) * np.sqrt(2)
|
||||
result = F.hsobel(image)
|
||||
result = filters.hsobel(image)
|
||||
assert_allclose(result, 0, atol=1e-10)
|
||||
|
||||
|
||||
def test_vsobel_zeros():
|
||||
"""Vertical sobel on an array of all zeros."""
|
||||
result = F.vsobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.vsobel(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_vsobel_mask():
|
||||
"""Vertical Sobel on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.vsobel(np.random.uniform(size=(10, 10)),
|
||||
result = filters.vsobel(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
@@ -118,7 +118,7 @@ def test_vsobel_vertical():
|
||||
"""Vertical Sobel on an edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.vsobel(image)
|
||||
result = filters.vsobel(image)
|
||||
# Fudge the eroded points
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert (np.all(result[j == 0] == 1))
|
||||
@@ -129,21 +129,21 @@ def test_vsobel_horizontal():
|
||||
"""vertical Sobel on a horizontal edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.vsobel(image)
|
||||
result = filters.vsobel(image)
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_scharr_zeros():
|
||||
"""Scharr on an array of all zeros."""
|
||||
result = F.scharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.scharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert (np.all(result < 1e-16))
|
||||
|
||||
|
||||
def test_scharr_mask():
|
||||
"""Scharr on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.scharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.scharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ def test_scharr_horizontal():
|
||||
"""Scharr on an edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.scharr(image) * np.sqrt(2)
|
||||
result = filters.scharr(image) * np.sqrt(2)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert_allclose(result[i == 0], 1)
|
||||
@@ -162,7 +162,7 @@ def test_scharr_vertical():
|
||||
"""Scharr on a vertical edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.scharr(image) * np.sqrt(2)
|
||||
result = filters.scharr(image) * np.sqrt(2)
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert_allclose(result[j == 0], 1)
|
||||
assert (np.all(result[np.abs(j) > 1] == 0))
|
||||
@@ -170,15 +170,15 @@ def test_scharr_vertical():
|
||||
|
||||
def test_hscharr_zeros():
|
||||
"""Horizontal Scharr on an array of all zeros."""
|
||||
result = F.hscharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.hscharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_hscharr_mask():
|
||||
"""Horizontal Scharr on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.hscharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.hscharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ def test_hscharr_horizontal():
|
||||
"""Horizontal Scharr on an edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.hscharr(image)
|
||||
result = filters.hscharr(image)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert (np.all(result[i == 0] == 1))
|
||||
@@ -197,21 +197,21 @@ def test_hscharr_vertical():
|
||||
"""Horizontal Scharr on a vertical edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.hscharr(image)
|
||||
result = filters.hscharr(image)
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_vscharr_zeros():
|
||||
"""Vertical Scharr on an array of all zeros."""
|
||||
result = F.vscharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.vscharr(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_vscharr_mask():
|
||||
"""Vertical Scharr on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.vscharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.vscharr(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ def test_vscharr_vertical():
|
||||
"""Vertical Scharr on an edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.vscharr(image)
|
||||
result = filters.vscharr(image)
|
||||
# Fudge the eroded points
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert (np.all(result[j == 0] == 1))
|
||||
@@ -230,21 +230,21 @@ def test_vscharr_horizontal():
|
||||
"""vertical Scharr on a horizontal edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.vscharr(image)
|
||||
result = filters.vscharr(image)
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_prewitt_zeros():
|
||||
"""Prewitt on an array of all zeros."""
|
||||
result = F.prewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.prewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_prewitt_mask():
|
||||
"""Prewitt on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.prewitt(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.prewitt(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(np.abs(result), 0)
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ def test_prewitt_horizontal():
|
||||
"""Prewitt on an edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.prewitt(image) * np.sqrt(2)
|
||||
result = filters.prewitt(image) * np.sqrt(2)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert (np.all(result[i == 0] == 1))
|
||||
@@ -263,7 +263,7 @@ def test_prewitt_vertical():
|
||||
"""Prewitt on a vertical edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.prewitt(image) * np.sqrt(2)
|
||||
result = filters.prewitt(image) * np.sqrt(2)
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert_allclose(result[j == 0], 1)
|
||||
assert_allclose(result[np.abs(j) > 1], 0, atol=1e-10)
|
||||
@@ -271,14 +271,14 @@ def test_prewitt_vertical():
|
||||
|
||||
def test_hprewitt_zeros():
|
||||
"""Horizontal prewitt on an array of all zeros."""
|
||||
result = F.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.hprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_hprewitt_mask():
|
||||
"""Horizontal prewitt on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.hprewitt(np.random.uniform(size=(10, 10)),
|
||||
result = filters.hprewitt(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
@@ -287,7 +287,7 @@ def test_hprewitt_horizontal():
|
||||
"""Horizontal prewitt on an edge should be a horizontal line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.hprewitt(image)
|
||||
result = filters.hprewitt(image)
|
||||
# Fudge the eroded points
|
||||
i[np.abs(j) == 5] = 10000
|
||||
assert (np.all(result[i == 0] == 1))
|
||||
@@ -298,21 +298,21 @@ def test_hprewitt_vertical():
|
||||
"""Horizontal prewitt on a vertical edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.hprewitt(image)
|
||||
result = filters.hprewitt(image)
|
||||
assert_allclose(result, 0, atol=1e-10)
|
||||
|
||||
|
||||
def test_vprewitt_zeros():
|
||||
"""Vertical prewitt on an array of all zeros."""
|
||||
result = F.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
result = filters.vprewitt(np.zeros((10, 10)), np.ones((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
def test_vprewitt_mask():
|
||||
"""Vertical prewitt on a masked array should be zero."""
|
||||
np.random.seed(0)
|
||||
result = F.vprewitt(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
result = filters.vprewitt(np.random.uniform(size=(10, 10)),
|
||||
np.zeros((10, 10), bool))
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ def test_vprewitt_vertical():
|
||||
"""Vertical prewitt on an edge should be a vertical line."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (j >= 0).astype(float)
|
||||
result = F.vprewitt(image)
|
||||
result = filters.vprewitt(image)
|
||||
# Fudge the eroded points
|
||||
j[np.abs(i) == 5] = 10000
|
||||
assert (np.all(result[j == 0] == 1))
|
||||
@@ -331,7 +331,7 @@ def test_vprewitt_horizontal():
|
||||
"""Vertical prewitt on a horizontal edge should be zero."""
|
||||
i, j = np.mgrid[-5:6, -5:6]
|
||||
image = (i >= 0).astype(float)
|
||||
result = F.vprewitt(image)
|
||||
result = filters.vprewitt(image)
|
||||
assert_allclose(result, 0)
|
||||
|
||||
|
||||
@@ -347,7 +347,7 @@ def test_horizontal_mask_line():
|
||||
expected[1:-1, 1:-1] = 0.2 # constant gradient for most of image,
|
||||
expected[4:7, 1:-1] = 0 # but line and neighbors masked
|
||||
|
||||
for grad_func in (F.hprewitt, F.hsobel, F.hscharr):
|
||||
for grad_func in (filters.hprewitt, filters.hsobel, filters.hscharr):
|
||||
result = grad_func(vgrad, mask)
|
||||
yield assert_close, result, expected
|
||||
|
||||
@@ -364,7 +364,7 @@ def test_vertical_mask_line():
|
||||
expected[1:-1, 1:-1] = 0.2 # constant gradient for most of image,
|
||||
expected[1:-1, 4:7] = 0 # but line and neighbors masked
|
||||
|
||||
for grad_func in (F.vprewitt, F.vsobel, F.vscharr):
|
||||
for grad_func in (filters.vprewitt, filters.vsobel, filters.vscharr):
|
||||
result = grad_func(hgrad, mask)
|
||||
yield assert_close, result, expected
|
||||
|
||||
@@ -372,7 +372,8 @@ def test_vertical_mask_line():
|
||||
def test_range():
|
||||
"""Output of edge detection should be in [0, 1]"""
|
||||
image = np.random.random((100, 100))
|
||||
for detector in (F.sobel, F.scharr, F.prewitt, F.roberts):
|
||||
for detector in (filters.sobel, filters.scharr,
|
||||
filters.prewitt, filters.roberts):
|
||||
out = detector(image)
|
||||
assert_(out.min() >= 0,
|
||||
"Minimum of `{0}` is smaller than zero".format(
|
||||
@@ -0,0 +1,10 @@
|
||||
from warnings import catch_warnings, simplefilter
|
||||
|
||||
|
||||
def test_filter_import():
|
||||
with catch_warnings():
|
||||
simplefilter('ignore')
|
||||
from skimage import filter as F
|
||||
|
||||
assert('sobel' in dir(F))
|
||||
assert F._import_warned
|
||||
@@ -2,7 +2,7 @@ import numpy as np
|
||||
from numpy.testing import (assert_equal, assert_almost_equal,
|
||||
assert_array_almost_equal)
|
||||
|
||||
from skimage.filter._gabor import gabor_kernel, gabor_filter, _sigma_prefactor
|
||||
from skimage.filters._gabor import gabor_kernel, gabor_filter, _sigma_prefactor
|
||||
|
||||
|
||||
def test_gabor_kernel_size():
|
||||
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from skimage.filter._gaussian import gaussian_filter
|
||||
from skimage.filters._gaussian import gaussian_filter
|
||||
|
||||
|
||||
def test_null_sigma():
|
||||
+10
-14
@@ -1,17 +1,13 @@
|
||||
import os.path
|
||||
|
||||
import numpy as np
|
||||
from numpy.testing import *
|
||||
from numpy.testing import (assert_raises, assert_, assert_equal,
|
||||
run_module_suite)
|
||||
|
||||
from skimage import data_dir
|
||||
from skimage.io import *
|
||||
from skimage.filter import *
|
||||
from skimage import data
|
||||
from skimage.filters import LPIFilter2D, inverse, wiener
|
||||
|
||||
|
||||
class TestLPIFilter2D(object):
|
||||
|
||||
img = imread(os.path.join(data_dir, 'camera.png'),
|
||||
flatten=True)[:50, :50]
|
||||
img = data.camera()[:50, :50]
|
||||
|
||||
def filt_func(self, r, c):
|
||||
return np.exp(-np.hypot(r, c) / 1)
|
||||
@@ -36,14 +32,14 @@ class TestLPIFilter2D(object):
|
||||
assert_equal(g.shape, self.img.shape)
|
||||
|
||||
g1 = inverse(F[::-1, ::-1], predefined_filter=self.f)
|
||||
assert ((g - g1[::-1, ::-1]).sum() < 55)
|
||||
assert_((g - g1[::-1, ::-1]).sum() < 55)
|
||||
|
||||
# test cache
|
||||
g1 = inverse(F[::-1, ::-1], predefined_filter=self.f)
|
||||
assert ((g - g1[::-1, ::-1]).sum() < 55)
|
||||
assert_((g - g1[::-1, ::-1]).sum() < 55)
|
||||
|
||||
g1 = inverse(F[::-1, ::-1], self.filt_func)
|
||||
assert ((g - g1[::-1, ::-1]).sum() < 55)
|
||||
assert_((g - g1[::-1, ::-1]).sum() < 55)
|
||||
|
||||
def test_wiener(self):
|
||||
F = self.f(self.img)
|
||||
@@ -51,10 +47,10 @@ class TestLPIFilter2D(object):
|
||||
assert_equal(g.shape, self.img.shape)
|
||||
|
||||
g1 = wiener(F[::-1, ::-1], predefined_filter=self.f)
|
||||
assert ((g - g1[::-1, ::-1]).sum() < 1)
|
||||
assert_((g - g1[::-1, ::-1]).sum() < 1)
|
||||
|
||||
g1 = wiener(F[::-1, ::-1], self.filt_func)
|
||||
assert ((g - g1[::-1, ::-1]).sum() < 1)
|
||||
assert_((g - g1[::-1, ::-1]).sum() < 1)
|
||||
|
||||
def test_non_callable(self):
|
||||
assert_raises(ValueError, LPIFilter2D, None)
|
||||
+4
-4
@@ -3,10 +3,10 @@ from numpy.testing import assert_equal, assert_almost_equal
|
||||
|
||||
import skimage
|
||||
from skimage import data
|
||||
from skimage.filter.thresholding import (threshold_adaptive,
|
||||
threshold_otsu,
|
||||
threshold_yen,
|
||||
threshold_isodata)
|
||||
from skimage.filters.thresholding import (threshold_adaptive,
|
||||
threshold_otsu,
|
||||
threshold_yen,
|
||||
threshold_isodata)
|
||||
|
||||
|
||||
class TestSimpleImage():
|
||||
@@ -11,7 +11,7 @@ Original author: Lee Kamentsky
|
||||
"""
|
||||
import numpy as np
|
||||
|
||||
from skimage.filter._rank_order import rank_order
|
||||
from skimage.filters._rank_order import rank_order
|
||||
|
||||
|
||||
def reconstruction(seed, mask, method='dilation', selem=None, offset=None):
|
||||
|
||||
@@ -27,7 +27,7 @@ Original author: Lee Kamentsky
|
||||
from _heapq import heappush, heappop
|
||||
import numpy as np
|
||||
import scipy.ndimage
|
||||
from ..filter import rank_order
|
||||
from ..filters import rank_order
|
||||
from .._shared.utils import deprecated
|
||||
|
||||
from . import _watershed
|
||||
|
||||
@@ -39,7 +39,7 @@ except ImportError:
|
||||
amg_loaded = False
|
||||
from scipy.sparse.linalg import cg
|
||||
from ..util import img_as_float
|
||||
from ..filter import rank_order
|
||||
from ..filters import rank_order
|
||||
|
||||
#-----------Laplacian--------------------
|
||||
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ def configuration(parent_package='', top_path=None):
|
||||
config.add_subpackage('exposure')
|
||||
config.add_subpackage('feature')
|
||||
config.add_subpackage('restoration')
|
||||
config.add_subpackage('filter')
|
||||
config.add_subpackage('filters')
|
||||
config.add_subpackage('graph')
|
||||
config.add_subpackage('io')
|
||||
config.add_subpackage('measure')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import numpy as np
|
||||
import skimage
|
||||
import skimage.data as data
|
||||
from skimage.filter.rank import median
|
||||
from skimage.filters.rank import median
|
||||
from skimage.morphology import disk
|
||||
from skimage.viewer import ImageViewer, viewer_available
|
||||
from numpy.testing import assert_equal, assert_allclose, assert_almost_equal
|
||||
|
||||
@@ -4,7 +4,7 @@ from skimage.viewer.qt import QtGui, QtCore
|
||||
from skimage.viewer import ImageViewer, CollectionViewer, viewer_available
|
||||
from skimage.transform import pyramid_gaussian
|
||||
from skimage.viewer.plugins import OverlayPlugin
|
||||
from skimage.filter import sobel
|
||||
from skimage.filters import sobel
|
||||
from numpy.testing import assert_equal
|
||||
from numpy.testing.decorators import skipif
|
||||
from skimage._shared.version_requirements import is_installed
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from skimage import data
|
||||
from skimage.filter import canny
|
||||
from skimage.filters import canny
|
||||
|
||||
from skimage.viewer import ImageViewer
|
||||
from skimage.viewer.widgets import Slider
|
||||
|
||||
@@ -8,7 +8,7 @@ Demo of a CollectionViewer for viewing collections of images with the
|
||||
|
||||
"""
|
||||
from skimage import data
|
||||
from skimage.filter import rank
|
||||
from skimage.filters import rank
|
||||
from skimage.morphology import disk
|
||||
|
||||
from skimage.viewer import CollectionViewer
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from skimage import data
|
||||
from skimage.filter.rank import median
|
||||
from skimage.filters.rank import median
|
||||
from skimage.morphology import disk
|
||||
|
||||
from skimage.viewer import ImageViewer
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from skimage import data
|
||||
from skimage import filter
|
||||
from skimage import filters
|
||||
from skimage import morphology
|
||||
from skimage.viewer import ImageViewer
|
||||
from skimage.viewer.widgets import history
|
||||
|
||||
Reference in New Issue
Block a user