From 7efb010051dbf505d73eea6184348997ee0d1767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 15 Jul 2013 22:00:05 +0200 Subject: [PATCH] Add short doc string example --- skimage/measure/block.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/skimage/measure/block.py b/skimage/measure/block.py index 7bef1220..fad5668c 100644 --- a/skimage/measure/block.py +++ b/skimage/measure/block.py @@ -24,6 +24,34 @@ def block_reduce(image, block_size, func=np.sum, cval=0): image : ndarray Down-sampled image with same number of dimensions as input image. + Examples + -------- + >>> from skimage.measure import block_reduce + >>> image = np.arange(3*3*4).reshape(3, 3, 4) + >>> image + array([[[ 0, 1, 2, 3], + [ 4, 5, 6, 7], + [ 8, 9, 10, 11]], + + [[12, 13, 14, 15], + [16, 17, 18, 19], + [20, 21, 22, 23]], + + [[24, 25, 26, 27], + [28, 29, 30, 31], + [32, 33, 34, 35]]]) + >>> block_reduce(image, block_size=(3, 3, 1), func=np.mean) + array([[[ 16., 17., 18., 19.]]]) + >>> block_reduce(image, block_size=(1, 3, 4), func=np.max) + array([[[11]], + + [[23]], + + [[35]]]) + >>> block_reduce(image, block_size=(3, 1, 4), func=np.max) + array([[[27], + [31], + [35]]]) """ if len(block_size) != image.ndim: