Skip to content

Commit

Permalink
Merge cd41f4f into d91aff4
Browse files Browse the repository at this point in the history
  • Loading branch information
ahojnnes committed Jan 31, 2016
2 parents d91aff4 + cd41f4f commit ecb392c
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 57 deletions.
6 changes: 4 additions & 2 deletions doc/examples/color_exposure/plot_adapt_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def sobel_hsv(image):

fig = plt.figure(figsize=(14, 7))
ax_each = fig.add_subplot(121, adjustable='box-forced')
ax_hsv = fig.add_subplot(122, sharex=ax_each, sharey=ax_each, adjustable='box-forced')
ax_hsv = fig.add_subplot(122, sharex=ax_each, sharey=ax_each,
adjustable='box-forced')

# We use 1 - sobel_each(image)
# but this will not work if image is not normalized
Expand Down Expand Up @@ -107,7 +108,8 @@ def sobel_gray(image):
return filters.sobel(image)

fig = plt.figure(figsize=(7, 7))
ax = fig.add_subplot(111, sharex=ax_each, sharey=ax_each, adjustable='box-forced')
ax = fig.add_subplot(111, sharex=ax_each, sharey=ax_each,
adjustable='box-forced')

# We use 1 - sobel_gray(image)
# but this will not work if image is not normalized
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/edges/plot_active_contours.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import matplotlib.pyplot as plt
from skimage.color import rgb2gray
from skimage import data
from skimage.filters import gaussian_filter
from skimage.filters import gaussian
from skimage.segmentation import active_contour

# Test scipy version, since active contour is only possible
Expand All @@ -52,7 +52,7 @@
'0.14.0 and above.')

if new_scipy:
snake = active_contour(gaussian_filter(img, 3),
snake = active_contour(gaussian(img, 3),
init, alpha=0.015, beta=10, gamma=0.001)

fig = plt.figure(figsize=(7, 7))
Expand Down Expand Up @@ -80,7 +80,7 @@
init = np.array([x, y]).T

if new_scipy:
snake = active_contour(gaussian_filter(img, 1), init, bc='fixed',
snake = active_contour(gaussian(img, 1), init, bc='fixed',
alpha=0.1, beta=1.0, w_line=-5, w_edge=0, gamma=0.1)

fig = plt.figure(figsize=(9, 5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@
edges = color.gray2rgb(edges)
edges[cy, cx] = (250, 0, 0)

fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})
fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True,
sharey=True,
subplot_kw={'adjustable':'box-forced'})

ax1.set_title('Original picture')
ax1.imshow(image_rgb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
patch_shape = 8, 8
n_filters = 49

astro = color.rgb2gray(data.astronaut())
astro = np.ascontiguousarray(color.rgb2gray(data.astronaut()))

# -- filterbank1 on original image
patches1 = view_as_windows(astro, patch_shape)
Expand Down
3 changes: 1 addition & 2 deletions doc/examples/filters/plot_rank_mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from skimage.filters import rank


image = (data.coins()).astype(np.uint16) * 16
image = data.coins()
selem = disk(20)

percentile_result = rank.mean_percentile(image, selem=selem, p0=.1, p1=.9)
Expand All @@ -46,5 +46,4 @@
ax[n].set_adjustable('box-forced')
ax[n].axis('off')


plt.show()
2 changes: 1 addition & 1 deletion doc/examples/numpy_operations/plot_view_as_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


# -- get `astronaut` from skimage.data in grayscale
l = color.rgb2gray(data.astronaut())
l = np.ascontiguousarray(color.rgb2gray(data.astronaut()))

# -- size of blocks
block_shape = (4, 4)
Expand Down
6 changes: 3 additions & 3 deletions doc/examples/transform/plot_ransac.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
from matplotlib import pyplot as plt

from skimage.measure import LineModel, ransac
from skimage.measure import LineModelND, ransac


np.random.seed(seed=1)
Expand All @@ -32,11 +32,11 @@
data[::4] += 20 * noise[::4]

# fit line using all data
model = LineModel()
model = LineModelND()
model.estimate(data)

# robustly fit line only using inlier data with RANSAC algorithm
model_robust, inliers = ransac(data, LineModel, min_samples=2,
model_robust, inliers = ransac(data, LineModelND, min_samples=2,
residual_threshold=1, max_trials=1000)
outliers = inliers == False

Expand Down
5 changes: 3 additions & 2 deletions doc/examples/transform/plot_swirl.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ def shift_left(xy):


image = data.checkerboard()
swirled = swirl(image, rotation=0, strength=10, radius=120, order=2)
swirled = swirl(image, rotation=0, strength=10, radius=120)

fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})
fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True,
subplot_kw={'adjustable':'box-forced'})

ax0.imshow(image, cmap=plt.cm.gray, interpolation='none')
ax0.axis('off')
Expand Down
40 changes: 21 additions & 19 deletions doc/examples/xx_applications/plot_morphology.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
functions only work on gray-scale or binary images, so we set ``as_grey=True``.
"""

import os
import matplotlib.pyplot as plt
from skimage.data import data_dir
from skimage.util import img_as_ubyte
from skimage import io

phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True))
orig_phantom = img_as_ubyte(io.imread(os.path.join(data_dir, "phantom.png"),
as_grey=True))
fig, ax = plt.subplots()
ax.imshow(phantom, cmap=plt.cm.gray)
ax.imshow(orig_phantom, cmap=plt.cm.gray)

"""
.. image:: PLOT2RST.current_figure
Expand All @@ -42,7 +44,8 @@

def plot_comparison(original, filtered, filter_name):

fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4), sharex=True, sharey=True)
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4), sharex=True,
sharey=True)
ax1.imshow(original, cmap=plt.cm.gray)
ax1.set_title('original')
ax1.axis('off')
Expand All @@ -68,8 +71,8 @@ def plot_comparison(original, filtered, filter_name):
from skimage.morphology import disk

selem = disk(6)
eroded = erosion(phantom, selem)
plot_comparison(phantom, eroded, 'erosion')
eroded = erosion(orig_phantom, selem)
plot_comparison(orig_phantom, eroded, 'erosion')

"""
.. image:: PLOT2RST.current_figure
Expand All @@ -88,8 +91,8 @@ def plot_comparison(original, filtered, filter_name):
regions and shrinks dark regions.
"""

dilated = dilation(phantom, selem)
plot_comparison(phantom, dilated, 'dilation')
dilated = dilation(orig_phantom, selem)
plot_comparison(orig_phantom, dilated, 'dilation')

"""
.. image:: PLOT2RST.current_figure
Expand All @@ -108,8 +111,8 @@ def plot_comparison(original, filtered, filter_name):
small dark cracks.
"""

opened = opening(phantom, selem)
plot_comparison(phantom, opened, 'opening')
opened = opening(orig_phantom, selem)
plot_comparison(orig_phantom, opened, 'opening')

"""
.. image:: PLOT2RST.current_figure
Expand All @@ -134,7 +137,7 @@ def plot_comparison(original, filtered, filter_name):
To illustrate this more clearly, let's add a small crack to the white border:
"""

phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True))
phantom = orig_phantom.copy()
phantom[10:30, 200:210] = 0

closed = closing(phantom, selem)
Expand All @@ -161,7 +164,7 @@ def plot_comparison(original, filtered, filter_name):
To make things interesting, we'll add bright and dark spots to the image:
"""

phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True))
phantom = orig_phantom.copy()
phantom[340:350, 200:210] = 255
phantom[100:110, 200:210] = 0

Expand Down Expand Up @@ -215,10 +218,9 @@ def plot_comparison(original, filtered, filter_name):
"""

from skimage import img_as_bool
horse = ~img_as_bool(io.imread(data_dir+'/horse.png', as_grey=True))
horse = io.imread(os.path.join(data_dir, "horse.png"), as_grey=True)

sk = skeletonize(horse)
sk = skeletonize(horse == 0)
plot_comparison(horse, sk, 'skeletonize')

"""
Expand All @@ -237,7 +239,7 @@ def plot_comparison(original, filtered, filter_name):
"""

hull1 = convex_hull_image(horse)
hull1 = convex_hull_image(horse == 0)
plot_comparison(horse, hull1, 'convex hull')

"""
Expand All @@ -252,11 +254,11 @@ def plot_comparison(original, filtered, filter_name):

import numpy as np

horse2 = np.copy(horse)
horse2[45:50, 75:80] = 1
horse_mask = horse == 0
horse_mask[45:50, 75:80] = 1

hull2 = convex_hull_image(horse2)
plot_comparison(horse2, hull2, 'convex hull')
hull2 = convex_hull_image(horse_mask)
plot_comparison(horse_mask, hull2, 'convex hull')

"""
.. image:: PLOT2RST.current_figure
Expand Down
4 changes: 2 additions & 2 deletions skimage/_shared/version_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def is_installed(name, version=None):
out : bool
True if `name` is installed matching the optional version.
Note
----
Notes
-----
Original Copyright (C) 2009-2011 Pierre Raybaut
Licensed under the terms of the MIT License.
"""
Expand Down
6 changes: 4 additions & 2 deletions skimage/exposure/_adapthist.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@adapt_rgb(hsv_value)
def equalize_adapthist(image, ntiles_x=8, ntiles_y=8, clip_limit=0.01,
def equalize_adapthist(image, ntiles_x=None, ntiles_y=None, clip_limit=0.01,
nbins=256, kernel_size=None):
"""Contrast Limited Adaptive Histogram Equalization (CLAHE).
Expand Down Expand Up @@ -76,10 +76,12 @@ def equalize_adapthist(image, ntiles_x=8, ntiles_y=8, clip_limit=0.01,
image = img_as_uint(image)
image = rescale_intensity(image, out_range=(0, NR_OF_GREY - 1))

if kernel_size is None:
if ntiles_x is not None or ntiles_y is not None:
warn('`ntiles_*` have been deprecated in favor of '
'`kernel_size`. The `ntiles_*` keyword arguments '
'will be removed in v0.14', skimage_deprecation)

if kernel_size is None:
ntiles_x = ntiles_x or 8
ntiles_y = ntiles_y or 8
kernel_size = (np.round(image.shape[0] / ntiles_y),
Expand Down
10 changes: 6 additions & 4 deletions skimage/exposure/tests/test_exposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,13 @@ def test_adapthist_grayscale():
img = skimage.img_as_float(data.astronaut())
img = rgb2gray(img)
img = np.dstack((img, img, img))
with expected_warnings(['precision loss|non-contiguous input',
with expected_warnings(['precision loss|non-contiguous input',
'deprecated']):
adapted_old = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.001,
nbins=128)
adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51), clip_limit=0.01, nbins=128)
with expected_warnings(['precision loss|non-contiguous input']):
adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51),
clip_limit=0.01, nbins=128)
assert img.shape == adapted.shape
assert_almost_equal(peak_snr(img, adapted), 102.078, 3)
assert_almost_equal(norm_brightness_err(img, adapted), 0.0529, 3)
Expand All @@ -230,7 +232,7 @@ def test_adapthist_color():
warnings.simplefilter('always')
hist, bin_centers = exposure.histogram(img)
assert len(w) > 0
with expected_warnings(['precision loss', 'deprecated']):
with expected_warnings(['precision loss']):
adapted = exposure.equalize_adapthist(img, clip_limit=0.01)

assert_almost_equal = np.testing.assert_almost_equal
Expand All @@ -249,7 +251,7 @@ def test_adapthist_alpha():
img = skimage.img_as_float(data.astronaut())
alpha = np.ones((img.shape[0], img.shape[1]), dtype=float)
img = np.dstack((img, alpha))
with expected_warnings(['precision loss', 'deprecated']):
with expected_warnings(['precision loss']):
adapted = exposure.equalize_adapthist(img)
assert adapted.shape != img.shape
img = img[:, :, :3]
Expand Down
6 changes: 3 additions & 3 deletions skimage/external/tifffile/tifffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2208,7 +2208,7 @@ class TiffSequence(object):
The data shape and dtype of all files must match.
Properties
Attributes
----------
files : list
List of file names.
Expand Down Expand Up @@ -3104,8 +3104,8 @@ def _replace_by(module_function, package=None, warn=False):
func : function
Wrapped function, hopefully calling a function in another module.
Example
-------
Examples
--------
>>> @_replace_by('_tifffile.decodepackbits')
... def decodepackbits(encoded):
... raise NotImplementedError
Expand Down
4 changes: 2 additions & 2 deletions skimage/novice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
instead of row, column.
Example
-------
Examples
--------
We can create a Picture object open opening an image file:
>>> from skimage import novice
Expand Down
4 changes: 2 additions & 2 deletions skimage/restoration/_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1,
----------
.. [1] http://users.soe.ucsc.edu/~manduchi/Papers/ICCV98.pdf
Example
-------
Examples
--------
>>> from skimage import data, img_as_float
>>> astro = img_as_float(data.astronaut())
>>> astro = astro[220:300, 220:320]
Expand Down
8 changes: 4 additions & 4 deletions skimage/restoration/inpaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def inpaint_biharmonic(img, mask, multichannel=False):
out : (M[, N[, ..., P]][, C]) ndarray
Input image with masked pixels inpainted.
Example
-------
Examples
--------
>>> img = np.tile(np.square(np.linspace(0, 1, 5)), (5, 1))
>>> mask = np.zeros_like(img)
>>> mask[2, 2:] = 1
Expand All @@ -111,11 +111,11 @@ def inpaint_biharmonic(img, mask, multichannel=False):

if img.ndim < 1:
raise ValueError('Input array has to be at least 1D')

img_baseshape = img.shape[:-1] if multichannel else img.shape
if img_baseshape != mask.shape:
raise ValueError('Input arrays have to be the same shape')

if np.ma.isMaskedArray(img):
raise TypeError('Masked arrays are not supported')

Expand Down
4 changes: 2 additions & 2 deletions skimage/transform/_warps.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True,
Whether to keep the original range of values. Otherwise, the input
image is converted according to the conventions of `img_as_float`.
Note
----
Notes
-----
Modes 'reflect' and 'symmetric' are similar, but differ in whether the edge
pixels are duplicated during the reflection. As an example, if an array
has values [0, 1, 2] and was padded to the right by four values using
Expand Down
Loading

0 comments on commit ecb392c

Please sign in to comment.