|
9 | 9 | "# Install dependencies for this example\n",
|
10 | 10 | "# Note: This does not include itkwidgets, itself\n",
|
11 | 11 | "import sys\n",
|
12 |
| - "!{sys.executable} -m pip install -U itk itk-totalvariation scikit-image" |
| 12 | + "!{sys.executable} -m pip install -U itk scikit-image" |
13 | 13 | ]
|
14 | 14 | },
|
15 | 15 | {
|
16 | 16 | "cell_type": "code",
|
17 |
| - "execution_count": 1, |
| 17 | + "execution_count": null, |
18 | 18 | "metadata": {},
|
19 | 19 | "outputs": [],
|
20 | 20 | "source": [
|
|
31 | 31 | },
|
32 | 32 | {
|
33 | 33 | "cell_type": "code",
|
34 |
| - "execution_count": 2, |
| 34 | + "execution_count": null, |
35 | 35 | "metadata": {},
|
36 | 36 | "outputs": [],
|
37 | 37 | "source": [
|
|
45 | 45 | },
|
46 | 46 | {
|
47 | 47 | "cell_type": "code",
|
48 |
| - "execution_count": 3, |
| 48 | + "execution_count": null, |
49 | 49 | "metadata": {},
|
50 |
| - "outputs": [ |
51 |
| - { |
52 |
| - "data": { |
53 |
| - "application/vnd.jupyter.widget-view+json": { |
54 |
| - "model_id": "436f06a0454f4e0abee8cbf15573015e", |
55 |
| - "version_major": 2, |
56 |
| - "version_minor": 0 |
57 |
| - }, |
58 |
| - "text/plain": [ |
59 |
| - "Viewer(annotations=False, cmap=['BrBG'], geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<…" |
60 |
| - ] |
61 |
| - }, |
62 |
| - "metadata": {}, |
63 |
| - "output_type": "display_data" |
64 |
| - } |
65 |
| - ], |
| 50 | + "outputs": [], |
66 | 51 | "source": [
|
67 |
| - "image = itk.imread(file_name, itk.F)\n", |
| 52 | + "image = itk.imread(file_name)\n", |
68 | 53 | "\n",
|
69 | 54 | "view(image, cmap=itkwidgets.cm.BrBG, annotations=False, vmax=800, ui_collapsed=True)"
|
70 | 55 | ]
|
|
76 | 61 | "outputs": [],
|
77 | 62 | "source": [
|
78 | 63 | "# Segment the cells\n",
|
79 |
| - "smoothed = itk.prox_tv_image_filter(image, weights=50, maximum_number_of_iterations=3)\n", |
| 64 | + "smoothed = itk.smoothing_recursive_gaussian_image_filter(image)\n", |
80 | 65 | "\n",
|
81 |
| - "LabelMapType = itk.Image[itk.UC, 3]\n", |
| 66 | + "thresholded = itk.moments_threshold_image_filter(smoothed,\n", |
| 67 | + " inside_value=0,\n", |
| 68 | + " outside_value=1)\n", |
82 | 69 | "\n",
|
83 |
| - "threshold_filter = itk.MomentsThresholdImageFilter[type(smoothed), LabelMapType].New(smoothed)\n", |
84 |
| - "threshold_filter.SetInsideValue(0)\n", |
85 |
| - "threshold_filter.SetOutsideValue(1)\n", |
86 |
| - "threshold_filter.Update()\n", |
87 |
| - "threshold = threshold_filter.GetThreshold()\n", |
88 |
| - "thresholded = threshold_filter.GetOutput()" |
| 70 | + "connected_components = itk.connected_component_image_filter(thresholded)" |
89 | 71 | ]
|
90 | 72 | },
|
91 | 73 | {
|
92 | 74 | "cell_type": "code",
|
93 |
| - "execution_count": 19, |
94 |
| - "metadata": {}, |
95 |
| - "outputs": [ |
96 |
| - { |
97 |
| - "data": { |
98 |
| - "application/vnd.jupyter.widget-view+json": { |
99 |
| - "model_id": "69dfe9c8df3d41a889e9c7b63f114284", |
100 |
| - "version_major": 2, |
101 |
| - "version_minor": 0 |
102 |
| - }, |
103 |
| - "text/plain": [ |
104 |
| - "Viewer(geometries=[], gradient_opacity=0.22, interpolation=False, point_sets=[], rendered_label_image=<itk.itkIm…" |
105 |
| - ] |
106 |
| - }, |
107 |
| - "metadata": {}, |
108 |
| - "output_type": "display_data" |
109 |
| - } |
110 |
| - ], |
111 |
| - "source": [ |
112 |
| - "view(label_image=thresholded)" |
113 |
| - ] |
114 |
| - }, |
115 |
| - { |
116 |
| - "cell_type": "code", |
117 |
| - "execution_count": 20, |
| 75 | + "execution_count": null, |
118 | 76 | "metadata": {},
|
119 |
| - "outputs": [ |
120 |
| - { |
121 |
| - "data": { |
122 |
| - "application/vnd.jupyter.widget-view+json": { |
123 |
| - "model_id": "33c0cb1ad92241a49728735b67d1f83f", |
124 |
| - "version_major": 2, |
125 |
| - "version_minor": 0 |
126 |
| - }, |
127 |
| - "text/plain": [ |
128 |
| - "Viewer(geometries=[], gradient_opacity=0.22, interpolation=False, point_sets=[], rendered_label_image=<itk.itkIm…" |
129 |
| - ] |
130 |
| - }, |
131 |
| - "metadata": {}, |
132 |
| - "output_type": "display_data" |
133 |
| - } |
134 |
| - ], |
| 77 | + "outputs": [], |
135 | 78 | "source": [
|
136 |
| - "connected_components = itk.connected_component_image_filter(thresholded)\n", |
137 |
| - "\n", |
138 | 79 | "view(label_image=connected_components)"
|
139 | 80 | ]
|
140 | 81 | },
|
141 | 82 | {
|
142 | 83 | "cell_type": "code",
|
143 |
| - "execution_count": 22, |
| 84 | + "execution_count": null, |
144 | 85 | "metadata": {
|
145 | 86 | "scrolled": true
|
146 | 87 | },
|
147 |
| - "outputs": [ |
148 |
| - { |
149 |
| - "data": { |
150 |
| - "application/vnd.jupyter.widget-view+json": { |
151 |
| - "model_id": "94c8055aff1a4cb89923c78072fa305b", |
152 |
| - "version_major": 2, |
153 |
| - "version_minor": 0 |
154 |
| - }, |
155 |
| - "text/plain": [ |
156 |
| - "Viewer(geometries=[], gradient_opacity=0.5, interpolation=False, label_image_names=[(0, 'Background'), (1, 'Firs…" |
157 |
| - ] |
158 |
| - }, |
159 |
| - "metadata": {}, |
160 |
| - "output_type": "display_data" |
161 |
| - } |
162 |
| - ], |
| 88 | + "outputs": [], |
163 | 89 | "source": [
|
164 | 90 | "# We can combine the label map with the intensity image, add names for the labels, etc.\n",
|
165 | 91 | "names = [(0, 'Background'), (1, 'First cell'), (2, 'Second cell')]\n",
|
|
183 | 109 | },
|
184 | 110 | {
|
185 | 111 | "cell_type": "code",
|
186 |
| - "execution_count": 27, |
| 112 | + "execution_count": null, |
187 | 113 | "metadata": {},
|
188 | 114 | "outputs": [],
|
189 | 115 | "source": [
|
|
203 | 129 | },
|
204 | 130 | {
|
205 | 131 | "cell_type": "code",
|
206 |
| - "execution_count": 3, |
| 132 | + "execution_count": null, |
207 | 133 | "metadata": {},
|
208 |
| - "outputs": [ |
209 |
| - { |
210 |
| - "data": { |
211 |
| - "application/vnd.jupyter.widget-view+json": { |
212 |
| - "model_id": "8327687db5c64422a16af110bb597b76", |
213 |
| - "version_major": 2, |
214 |
| - "version_minor": 0 |
215 |
| - }, |
216 |
| - "text/plain": [ |
217 |
| - "Viewer(annotations=False, cmap=['BrBG'], geometries=[], gradient_opacity=0.22, point_sets=[], rendered_image=<…" |
218 |
| - ] |
219 |
| - }, |
220 |
| - "metadata": {}, |
221 |
| - "output_type": "display_data" |
222 |
| - } |
223 |
| - ], |
| 134 | + "outputs": [], |
224 | 135 | "source": [
|
225 | 136 | "image = skimage.io.imread(file_name)\n",
|
226 | 137 | "\n",
|
|
229 | 140 | },
|
230 | 141 | {
|
231 | 142 | "cell_type": "code",
|
232 |
| - "execution_count": 4, |
| 143 | + "execution_count": null, |
233 | 144 | "metadata": {},
|
234 | 145 | "outputs": [],
|
235 | 146 | "source": [
|
|
244 | 155 | },
|
245 | 156 | {
|
246 | 157 | "cell_type": "code",
|
247 |
| - "execution_count": 5, |
| 158 | + "execution_count": null, |
248 | 159 | "metadata": {},
|
249 |
| - "outputs": [ |
250 |
| - { |
251 |
| - "data": { |
252 |
| - "application/vnd.jupyter.widget-view+json": { |
253 |
| - "model_id": "cdc8480801bc4792b2053812febdf00f", |
254 |
| - "version_major": 2, |
255 |
| - "version_minor": 0 |
256 |
| - }, |
257 |
| - "text/plain": [ |
258 |
| - "Viewer(geometries=[], gradient_opacity=0.22, interpolation=False, point_sets=[], rendered_label_image=<itk.itk…" |
259 |
| - ] |
260 |
| - }, |
261 |
| - "metadata": {}, |
262 |
| - "output_type": "display_data" |
263 |
| - } |
264 |
| - ], |
| 160 | + "outputs": [], |
265 | 161 | "source": [
|
266 | 162 | "view(label_image=connected_components)"
|
267 | 163 | ]
|
|
0 commit comments