Skip to content
Snippets Groups Projects
Commit 7bc2f7e6 authored by Marvin Albert's avatar Marvin Albert
Browse files

Updated notebooks

parent 92ffc19a
No related branches found
No related tags found
No related merge requests found
Pipeline #141148 passed
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "f52c8e1379eb48e99c05110456f215fd", "model_id": "990f8cb6ddfe4bc7a2457cb97f9ed4f7",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -106,32 +106,7 @@ ...@@ -106,32 +106,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 12,
"metadata": {
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'ndimage' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[4], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mndimage\u001b[49m\u001b[38;5;241m.\u001b[39mpercentile_filter\n",
"\u001b[0;31mNameError\u001b[0m: name 'ndimage' is not defined"
]
}
],
"source": [
"ndimage.percentile_filter"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "-" "slide_type": "-"
...@@ -140,10 +115,9 @@ ...@@ -140,10 +115,9 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"from skimage import filters\n", "from skimage import filters\n",
"from scipy import ndimage\n",
"def preprocess(im):\n", "def preprocess(im):\n",
" f = im.astype('float')\n", " f = im\n",
" f = f - ndimage.minimum_filter(f, 200)\n", " f = f.astype(float) - filters.rank.minimum(f, footprint=np.ones((200,200), dtype='bool'))\n",
" f = f * (f > 0)\n", " f = f * (f > 0)\n",
" f = f / filters.gaussian(f, sigma=50)\n", " f = f / filters.gaussian(f, sigma=50)\n",
" f = np.clip(f, 0, 4)\n", " f = np.clip(f, 0, 4)\n",
...@@ -154,7 +128,7 @@ ...@@ -154,7 +128,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 13,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "-" "slide_type": "-"
...@@ -171,7 +145,7 @@ ...@@ -171,7 +145,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "30f4409a841140089dba9bea9361d735", "model_id": "1117a357a7b845b0ae6c44a62e999bb5",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -179,7 +153,7 @@ ...@@ -179,7 +153,7 @@
"HBox(children=(VBox(children=(VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=512, width=680),…" "HBox(children=(VBox(children=(VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=512, width=680),…"
] ]
}, },
"execution_count": 5, "execution_count": 13,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -191,7 +165,7 @@ ...@@ -191,7 +165,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 14,
"metadata": { "metadata": {
"slideshow": { "slideshow": {
"slide_type": "-" "slide_type": "-"
...@@ -208,7 +182,7 @@ ...@@ -208,7 +182,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "e6e7077d82b148a2ac9dd35fde18366a", "model_id": "873cc103c35d4037b7f59b8b43d47665",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 0
}, },
...@@ -216,7 +190,7 @@ ...@@ -216,7 +190,7 @@
"HBox(children=(VBox(children=(VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=512, width=680),…" "HBox(children=(VBox(children=(VBox(children=(HBox(children=(VBox(children=(ImageWidget(height=512, width=680),…"
] ]
}, },
"execution_count": 6, "execution_count": 14,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -235,15 +209,15 @@ ...@@ -235,15 +209,15 @@
} }
}, },
"source": [ "source": [
"## Image denoising\n", "## Image filtering\n",
"\n", "\n",
"What's image denoising? It's the process of removing noise from an image. Noise is random variation of brightness or color information in images, which usually originates in the sensor / camera.\n", "Example application: **Denoising** (removing noise from an image)\n",
"\n", "\n",
"Consider the following image:\n", "Noise is random variation of brightness or color information in images, which usually originates in the sensor / camera.\n",
"\n", "\n",
"<img src=\"illustrations/noisy_nuclei.png\" alt=\"drawing\" width=\"60%\" class=\"center\"/>\n", "Consider the following image:\n",
"\n", "\n",
"How to remove the noise from this image? One way is to use filters, which we'll discuss in this notebook." "<img src=\"illustrations/noisy_nuclei.png\" alt=\"drawing\" width=\"50%\" class=\"center\"/>"
] ]
}, },
{ {
...@@ -919,6 +893,24 @@ ...@@ -919,6 +893,24 @@
"Image filtering is of course a **vast** topic, and you should read more about it if you need it in your work. This example just illustrates how to use filters in Python using scikit-image." "Image filtering is of course a **vast** topic, and you should read more about it if you need it in your work. This example just illustrates how to use filters in Python using scikit-image."
] ]
}, },
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Filters can enhance features\n",
"\n",
"Example: Edge detection using the Sobel filter"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Convolutional filters are used in deep learning\n",
"\n",
"Convolutional filters are at the core of deep learning. They are used to extract features from images. The idea is to learn the values of the filter that are best at extracting the features that are important for the task at hand."
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
...@@ -1600,7 +1592,7 @@ ...@@ -1600,7 +1592,7 @@
"metadata": { "metadata": {
"celltoolbar": "Slideshow", "celltoolbar": "Slideshow",
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "remote_course",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
...@@ -1614,7 +1606,7 @@ ...@@ -1614,7 +1606,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.9.20" "version": "3.10.15"
}, },
"rise": { "rise": {
"scroll": true "scroll": true
This diff is collapsed.
This diff is collapsed.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
# Exercise 3: Filtering and denoising # Exercise 3: Image segmentation
%% Cell type:code id: tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
import skimage
import skimage.morphology
image_stack = skimage.io.imread('https://cildata.crbs.ucsd.edu/media/images/13585/13585.tif')
image_nuclei = image_stack[0:100,0:100,2]
```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
1. Using the skimage documentation (Google it), try to find the Sobel filter. Try it out on ```image_nuclei``` and by plotting it, try to understand what it does WIP
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
2. Using the Otsu method, make a mask of the filtered image and plot it 1. Exercise: Can you separate objects using morphological operations?
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
3. Threy to erode the image. Use influence regions of different sizes and observe the effect: 2. Exercise: Perform watershed segmentation using nuclei instances as markers.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
4. Choose an erosion level that leaves at least one of the circles complete. Use the skeletonize filter on your resulting eroded mask 3. Exercise: use `skimage.segmentation.mark_boundaries` to visualize the segmentation results.
......
notebooks/illustrations/semantic_instance.png

216 KiB

notebooks/illustrations/watershed_blobs.gif

415 KiB

notebooks/illustrations/watershed_mpl.gif

897 KiB

notebooks/illustrations/watershed_seeded.png

292 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment