From 6d884906572b277202f439f161a94e6b3f4f1ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Sep 2012 10:40:52 +0200 Subject: [PATCH 1/4] Rename pyramid functions --- doc/examples/plot_pyramid.py | 4 ++-- skimage/transform/__init__.py | 2 +- skimage/transform/pyramids.py | 8 ++++---- skimage/transform/tests/test_pyramids.py | 6 +++--- viewer_examples/viewers/collection_viewer.py | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/examples/plot_pyramid.py b/doc/examples/plot_pyramid.py index 60067549..47ac1e16 100644 --- a/doc/examples/plot_pyramid.py +++ b/doc/examples/plot_pyramid.py @@ -13,12 +13,12 @@ import numpy as np import matplotlib.pyplot as plt from skimage import data -from skimage.transform import build_gaussian_pyramid +from skimage.transform import pyramid_gaussian image = data.lena() rows, cols, dim = image.shape -pyramid = tuple(build_gaussian_pyramid(image, downscale=2)) +pyramid = tuple(pyramid_gaussian(image, downscale=2)) composite_image = np.zeros((rows, cols + cols / 2, 3), dtype=np.double) diff --git a/skimage/transform/__init__.py b/skimage/transform/__init__.py index fc2b12ef..a55d5df4 100644 --- a/skimage/transform/__init__.py +++ b/skimage/transform/__init__.py @@ -8,4 +8,4 @@ from ._geometric import (warp, warp_coords, estimate_transform, PiecewiseAffineTransform) from ._warps import swirl, homography, resize, rotate from .pyramids import (pyramid_reduce, pyramid_expand, - build_gaussian_pyramid, build_laplacian_pyramid) + pyramid_gaussian, pyramid_laplacian) diff --git a/skimage/transform/pyramids.py b/skimage/transform/pyramids.py index f07fb1c5..a7492043 100644 --- a/skimage/transform/pyramids.py +++ b/skimage/transform/pyramids.py @@ -135,8 +135,8 @@ def pyramid_expand(image, upscale=2, sigma=None, order=1, return out -def build_gaussian_pyramid(image, max_layer=-1, downscale=2, sigma=None, - order=1, mode='reflect', cval=0): +def pyramid_gaussian(image, max_layer=-1, downscale=2, sigma=None, order=1, + mode='reflect', cval=0): """Yield images of the gaussian pyramid formed by the input image. Recursively applies the `pyramid_reduce` function to the image, and yields @@ -209,8 +209,8 @@ def build_gaussian_pyramid(image, max_layer=-1, downscale=2, sigma=None, yield layer_image -def build_laplacian_pyramid(image, max_layer=-1, downscale=2, sigma=None, - order=1, mode='reflect', cval=0): +def pyramid_laplacian(image, max_layer=-1, downscale=2, sigma=None, order=1, + mode='reflect', cval=0): """Yield images of the laplacian pyramid formed by the input image. Each layer contains the difference between the downsampled and the diff --git a/skimage/transform/tests/test_pyramids.py b/skimage/transform/tests/test_pyramids.py index 9aa236ff..611ecdec 100644 --- a/skimage/transform/tests/test_pyramids.py +++ b/skimage/transform/tests/test_pyramids.py @@ -1,7 +1,7 @@ from numpy.testing import assert_array_equal, run_module_suite from skimage import data from skimage.transform import (pyramid_reduce, pyramid_expand, - build_gaussian_pyramid, build_laplacian_pyramid) + pyramid_gaussian, pyramid_laplacian) image = data.lena() @@ -21,7 +21,7 @@ def test_pyramid_expand(): def test_build_gaussian_pyramid(): rows, cols, dim = image.shape - pyramid = build_gaussian_pyramid(image, downscale=2) + pyramid = pyramid_gaussian(image, downscale=2) for layer, out in enumerate(pyramid): layer_shape = (rows / 2 ** layer, cols / 2 ** layer, dim) @@ -30,7 +30,7 @@ def test_build_gaussian_pyramid(): def test_build_laplacian_pyramid(): rows, cols, dim = image.shape - pyramid = build_laplacian_pyramid(image, downscale=2) + pyramid = pyramid_laplacian(image, downscale=2) for layer, out in enumerate(pyramid): layer_shape = (rows / 2 ** layer, cols / 2 ** layer, dim) diff --git a/viewer_examples/viewers/collection_viewer.py b/viewer_examples/viewers/collection_viewer.py index 24c97ab0..62cdbb26 100644 --- a/viewer_examples/viewers/collection_viewer.py +++ b/viewer_examples/viewers/collection_viewer.py @@ -21,11 +21,11 @@ home/end keys import numpy as np from skimage import data from skimage.viewer import CollectionViewer -from skimage.transform import build_gaussian_pyramid +from skimage.transform import pyramid_gaussian img = data.lena() -img_collection = tuple(build_gaussian_pyramid(img)) +img_collection = tuple(pyramid_gaussian(img)) view = CollectionViewer(img_collection) view.show() From bfcc144699573c131e5554a75e0e497299ed71ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Sep 2012 10:41:08 +0200 Subject: [PATCH 2/4] Fix typo --- doc/examples/plot_pyramid.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/plot_pyramid.py b/doc/examples/plot_pyramid.py index 47ac1e16..8752af68 100644 --- a/doc/examples/plot_pyramid.py +++ b/doc/examples/plot_pyramid.py @@ -3,7 +3,7 @@ Build image pyramids ==================== -The `build_gauassian_pyramid` function takes an image and yields successive +The `build_gaussian_pyramid` function takes an image and yields successive images shrunk by a constant scale factor. Image pyramids are often used, e.g., to implement algorithms for denoising, texture discrimination, and scale- invariant detection. From be7476b44f0b840cc5c47cb4ba3861fa66d04940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Sep 2012 10:58:28 +0200 Subject: [PATCH 3/4] Add more detailed description for pyramid functions --- skimage/transform/pyramids.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/skimage/transform/pyramids.py b/skimage/transform/pyramids.py index a7492043..dd274834 100644 --- a/skimage/transform/pyramids.py +++ b/skimage/transform/pyramids.py @@ -140,8 +140,12 @@ def pyramid_gaussian(image, max_layer=-1, downscale=2, sigma=None, order=1, """Yield images of the gaussian pyramid formed by the input image. Recursively applies the `pyramid_reduce` function to the image, and yields - the downscaled images. Note that the first image of the pyramid will be the - original, unscaled image. + the downscaled images. + + Note that the first image of the pyramid will be the original, unscaled + image. The total number of images is `max_layer + 1`. In case all layers are + computed, the last image is either a one-pixel image or the image where the + reduction does not change its shape. Parameters ---------- @@ -214,7 +218,15 @@ def pyramid_laplacian(image, max_layer=-1, downscale=2, sigma=None, order=1, """Yield images of the laplacian pyramid formed by the input image. Each layer contains the difference between the downsampled and the - downsampled plus smoothed image. + downsampled, smoothed image:: + + layer = resize(prev_layer) - smooth(resize(prev_layer)) + + Note that the first image of the pyramid will be the difference between the + original, unscaled image and its smoothed version. The total number of + images is `max_layer + 1`. In case all layers are computed, the last image + is either a one-pixel image or the image where the reduction does not change + its shape. Parameters ---------- From bada6787aa111feac1df32952a8732400632f81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 15 Sep 2012 17:44:24 +0200 Subject: [PATCH 4/4] Update name of pyramid function in pyramid example description --- doc/examples/plot_pyramid.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/examples/plot_pyramid.py b/doc/examples/plot_pyramid.py index 8752af68..eb3896f4 100644 --- a/doc/examples/plot_pyramid.py +++ b/doc/examples/plot_pyramid.py @@ -3,10 +3,11 @@ Build image pyramids ==================== -The `build_gaussian_pyramid` function takes an image and yields successive -images shrunk by a constant scale factor. Image pyramids are often used, e.g., -to implement algorithms for denoising, texture discrimination, and scale- -invariant detection. +The `pyramid_gaussian` function takes an image and yields successive images +shrunk by a constant scale factor. Image pyramids are often used, e.g., to +implement algorithms for denoising, texture discrimination, and scale- invariant +detection. + """ import numpy as np