diff --git a/lectures/00_images_are_arrays.ipynb b/lectures/00_images_are_arrays.ipynb index 9b6fc33..fb08bcb 100644 --- a/lectures/00_images_are_arrays.ipynb +++ b/lectures/00_images_are_arrays.ipynb @@ -511,13 +511,13 @@ "green = np.zeros((300, 300))\n", "blue = np.zeros((300, 300))\n", "\n", - "r, c = draw.circle(100, 100, 100)\n", + "r, c = draw.disk(center=(100, 100), radius=100)\n", "red[r, c] = 1\n", "\n", - "r, c = draw.circle(100, 200, 100)\n", + "r, c = draw.disk(center=(100, 200), radius=100)\n", "green[r, c] = 1\n", "\n", - "r, c = draw.circle(200, 150, 100)\n", + "r, c = draw.disk(center=(200, 150), radius=100)\n", "blue[r, c] = 1\n", "\n", "f, axes = plt.subplots(1, 3)\n", diff --git a/lectures/3_morphological_operations.ipynb b/lectures/3_morphological_operations.ipynb index 763ad14..ca71db4 100644 --- a/lectures/3_morphological_operations.ipynb +++ b/lectures/3_morphological_operations.ipynb @@ -86,7 +86,7 @@ "metadata": {}, "outputs": [], "source": [ - "skdemo.imshow_all(image, morphology.erosion(image, sq), shape=(1, 2))" + "skdemo.imshow_all(image, morphology.erosion(image, sq))" ] }, { diff --git a/lectures/4_segmentation.ipynb b/lectures/4_segmentation.ipynb index 4eefa4a..54f3150 100644 --- a/lectures/4_segmentation.ipynb +++ b/lectures/4_segmentation.ipynb @@ -338,7 +338,7 @@ "indices = draw.circle_perimeter(100, 220, 25)\n", "\n", "astronaut_labels[indices] = 1\n", - "astronaut_labels[points[:, 1].astype(np.int), points[:, 0].astype(np.int)] = 2\n", + "astronaut_labels[points[:, 1].astype(int), points[:, 0].astype(int)] = 2\n", "\n", "image_show(astronaut_labels);" ] diff --git a/lectures/5_tophat_filters.ipynb b/lectures/5_tophat_filters.ipynb index df0e21e..a1f42ca 100644 --- a/lectures/5_tophat_filters.ipynb +++ b/lectures/5_tophat_filters.ipynb @@ -173,7 +173,7 @@ } ], "source": [ - "image_show(morph.closing(text, selem=morph.rectangle(3,3)))" + "image_show(morph.closing(text, footprint=morph.rectangle(3,3)))" ] }, { @@ -218,7 +218,7 @@ } ], "source": [ - "image_show(morph.closing(text, selem=morph.rectangle(31,31)))" + "image_show(morph.closing(text, footprint=morph.rectangle(31,31)))" ] }, { @@ -263,7 +263,7 @@ } ], "source": [ - "bth = morph.black_tophat(text, selem=morph.rectangle(31,31))\n", + "bth = morph.black_tophat(text, footprint=morph.rectangle(31,31))\n", "image_show(bth)" ] }, @@ -366,7 +366,7 @@ "elapsed = list()\n", "for sz in [3, 11, 31]:\n", " tic=time.perf_counter()\n", - " a = morph.closing(text, selem=morph.rectangle(sz,sz))\n", + " a = morph.closing(text, footprint=morph.rectangle(sz,sz))\n", " elapsed.append(time.perf_counter()-tic)\n", "\n", "print(elapsed)" @@ -392,7 +392,7 @@ "elapsed = list()\n", "for sz in [3, 11, 31]:\n", " tic=time.perf_counter()\n", - " a = morph.closing(text, selem=morph.disk(sz))\n", + " a = morph.closing(text, footprint=morph.disk(sz))\n", " elapsed.append(time.perf_counter()-tic)\n", "\n", "print(elapsed)\n", diff --git a/lectures/6_watershed_tricks.ipynb b/lectures/6_watershed_tricks.ipynb index 0844091..dc23bd6 100644 --- a/lectures/6_watershed_tricks.ipynb +++ b/lectures/6_watershed_tricks.ipynb @@ -174,7 +174,7 @@ "peak_mask = np.zeros_like(smoothed, dtype=bool)\n", "peak_mask[tuple(peak_idx.T)] = True\n", "# dilate them and label\n", - "peak_mask = skimage.morphology.dilation(peak_mask, selem=skimage.morphology.square(11))\n", + "peak_mask = skimage.morphology.dilation(peak_mask, footprint=skimage.morphology.square(11))\n", "# display\n", "peak_overlay = skimage.color.label2rgb(peak_mask, image=smoothed, bg_label=0)\n", "a=image_show(peak_overlay)" diff --git a/lectures/skdemo/_skdemo.py b/lectures/skdemo/_skdemo.py index 7b1a4e9..f6642f6 100644 --- a/lectures/skdemo/_skdemo.py +++ b/lectures/skdemo/_skdemo.py @@ -42,30 +42,39 @@ def imshow_rgb_shifted(rgb_image, shift=100, ax=None): ax.set_axis_off() -def imshow_all(*images, **kwargs): +def imshow_all( + *images, limits='image', titles=None, shape=None, size=5, **kwargs +): """ Plot a series of images side-by-side. Convert all images to float so that images have a common intensity range. Parameters ---------- - limits : str + images : tuple + The images to plot. + limits : 'image' or 'dtype', optional Control the intensity limits. By default, 'image' is used set the min/max intensities to the min/max of all images. Setting `limits` to 'dtype' can also be used if you want to preserve the image exposure. titles : list of str Titles for subplots. If the length of titles is less than the number of images, empty strings are appended. + shape : tuple, optional + A two-element tuple that defines the shape of the subfigure grid as + (rows, columns). If not given, all `ìmages` are shown in a single row. + size : int, optional + Width and height of each subplot in inches. kwargs : dict Additional keyword-arguments passed to `imshow`. """ images = [img_as_float(img) for img in images] - titles = kwargs.pop('titles', []) + if titles is None: + titles = [] if len(titles) != len(images): titles = list(titles) + [''] * (len(images) - len(titles)) - limits = kwargs.pop('limits', 'image') if limits == 'image': kwargs.setdefault('vmin', min(img.min() for img in images)) kwargs.setdefault('vmax', max(img.max() for img in images)) @@ -74,13 +83,13 @@ def imshow_all(*images, **kwargs): kwargs.setdefault('vmin', vmin) kwargs.setdefault('vmax', vmax) - nrows, ncols = kwargs.get('shape', (1, len(images))) + if shape is None: + shape = (1, len(images)) + nrows, ncols = shape - size = nrows * kwargs.pop('size', 5) - width = size * len(images) - if nrows > 1: - width /= nrows * 1.33 - fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(width, size)) + height = nrows * size + width = ncols * size + fig, axes = plt.subplots(nrows=nrows, ncols=ncols, figsize=(width, height)) for ax, img, label in zip(axes.ravel(), images, titles): ax.imshow(img, **kwargs) ax.set_title(label) diff --git a/lectures/solutions/00_images_are_arrays.ipynb b/lectures/solutions/00_images_are_arrays.ipynb index 24a57f9..7588bef 100644 --- a/lectures/solutions/00_images_are_arrays.ipynb +++ b/lectures/solutions/00_images_are_arrays.ipynb @@ -133,13 +133,13 @@ "green = np.zeros((300, 300))\n", "blue = np.zeros((300, 300))\n", "\n", - "r, c = draw.circle(100, 100, 100)\n", + "r, c = draw.disk(center=(100, 100), radius=100)\n", "red[r, c] = 1\n", "\n", - "r, c = draw.circle(100, 200, 100)\n", + "r, c = draw.disk(center=(100, 200), radius=100)\n", "green[r, c] = 1\n", "\n", - "r, c = draw.circle(200, 150, 100)\n", + "r, c = draw.disk(center=(200, 150), radius=100)\n", "blue[r, c] = 1\n", "\n", "f, axes = plt.subplots(1, 3)\n", diff --git a/lectures/solutions/1_image_filters.ipynb b/lectures/solutions/1_image_filters.ipynb index 17603ee..987f24c 100644 --- a/lectures/solutions/1_image_filters.ipynb +++ b/lectures/solutions/1_image_filters.ipynb @@ -2526,7 +2526,7 @@ "* [Rank filters example](http://scikit-image.org/docs/dev/auto_examples/applications/plot_rank_filters.html)\n", "* [Restoration API](http://scikit-image.org/docs/stable/api/skimage.restoration.html)\n", "\n", - "Take a look at this [neat feature](https://github.com/scikit-image/scikit-image/pull/2647) merged last year:\n", + "Take a look at this [neat feature](https://github.com/scikit-image/scikit-image/pull/2647):\n", "\n", "![cycle spinning](../images/cycle_spin.png)" ] diff --git a/requirements.txt b/requirements.txt index ea8af47..c90dbac 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -scikit-image[data] >= 0.18 +scikit-image[data] >= 0.19 numpy >= 1.12 scipy >= 1.0 matplotlib >= 2.1