You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
General clarifications, simplifications and figure corrections. Using imshow from matplotlib instead of skimage (deprecated). Setting default colormap.
(Note that as of skimage 0.25.0, the `square` function has been deprecated in
49
-
favour of a new function, [footprint_rectangle](https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.footprint_rectangle).)
48
+
Note that as of skimage 0.25.0, the `square` function has been deprecated in
49
+
favour of a new function, [footprint_rectangle](https://scikit-image.org/docs/stable/api/skimage.morphology.html#skimage.morphology.footprint_rectangle):
50
+
51
+
```python
52
+
from skimage.morphology import footprint_rectangle
53
+
kernel = square((3, 3)) # also a 3x3 square kernel
54
+
```
50
55
51
56
::::::::::::::::::::::::::::::::::::: challenge
52
57
## Exercise 6: Applying filters
53
58
54
-
Look at the documentation pages for the mean and Gaussian filters above. Load the second channel
55
-
of the 30th frame of the test image [skimage.data.cells3d()](https://scikit-image.org/docs/stable/api/skimage.data.html#skimage.data.cells3d):
59
+
Look at the documentation pages for the mean and Gaussian filters above. Load a frame from the second channel
60
+
of the test image [skimage.data.cells3d](https://scikit-image.org/docs/stable/api/skimage.data.html#skimage.data.cells3d):
56
61
57
62
```python
58
63
from skimage.data import cells3d
@@ -75,30 +80,30 @@ How do the different methods compare?
75
80
from skimage.data import cells3d
76
81
from skimage.filters import gaussian
77
82
from skimage.filters.rank import mean
78
-
from skimage.morphology import square
83
+
from skimage.morphology.footprintsimport square
79
84
80
85
image = cells3d()[30, 1, :, :]
81
-
matplotlib.pyplot.figure(figsize=(10, 12))
86
+
plt.figure(figsize=(10, 12))
82
87
83
-
matplotlib.pyplot.subplot(3, 2, 1)
84
-
imshow(image)
85
-
matplotlib.pyplot.title('Original')
88
+
plt.subplot(3, 2, 1)
89
+
plt.imshow(image)
90
+
plt.title('Original')
86
91
87
-
matplotlib.pyplot.subplot(3, 2, 2)
88
-
imshow(mean(image, footprint=square(3)))
89
-
matplotlib.pyplot.title('3x3 mean filter')
92
+
plt.subplot(3, 2, 2)
93
+
plt.imshow(mean(image, footprint=square(3)))
94
+
plt.title('3x3 mean filter')
90
95
91
-
matplotlib.pyplot.subplot(3, 2, 3)
92
-
imshow(mean(image, footprint=square(9)))
93
-
matplotlib.pyplot.title('9x9 mean filter')
96
+
plt.subplot(3, 2, 3)
97
+
plt.imshow(mean(image, footprint=square(9)))
98
+
plt.title('9x9 mean filter')
94
99
95
-
matplotlib.pyplot.subplot(3, 2, 4)
96
-
imshow(gaussian(image, sigma=1))
97
-
matplotlib.pyplot.title('Gaussian blur, σ=1')
100
+
plt.subplot(3, 2, 4)
101
+
plt.imshow(gaussian(image, sigma=1))
102
+
plt.title('Gaussian blur, σ=1')
98
103
99
-
matplotlib.pyplot.subplot(3, 2, 5)
100
-
imshow(gaussian(image, sigma=5))
101
-
matplotlib.pyplot.title('Gaussian blur, σ=5')
104
+
plt.subplot(3, 2, 5)
105
+
plt.imshow(gaussian(image, sigma=5))
106
+
plt.title('Gaussian blur, σ=5')
102
107
```
103
108
104
109
{alt='Filters'}
@@ -131,46 +136,34 @@ and display:
131
136
- image with a rolling ball of radius 50 applied
132
137
- the image with the radius=50 rolling ball subtracted from it
133
138
134
-
How long does it take to compute?
135
-
136
139
:::::::::::::::::::::::: solution
137
140
138
141
Compute time can be found using Python's datetime library:
0 commit comments