Skip to content

Commit

Permalink
correlation notebook and start of formatting of slides
Browse files Browse the repository at this point in the history
  • Loading branch information
bellonet committed Sep 23, 2024
1 parent 5ecbb99 commit 7aba51e
Show file tree
Hide file tree
Showing 15 changed files with 469 additions and 53 deletions.
6 changes: 4 additions & 2 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ baseURL = "https://bellonet.github.io/image-registration-workshop/"
languageCode = "en-us"
title = "Image Registration Workshop"

[markup.goldmark.renderer]
unsafe = true
[markup]
[markup.goldmark]
[markup.goldmark.renderer]
unsafe = true
95 changes: 59 additions & 36 deletions content/_index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
title: "Image Registration Workshop"
date: 2024-09-20
date: 2024-09-23
draft: false
layout: workshop
author: Ella Bahry
cover: img/registration.png
---

## What is Image Registration?
Expand All @@ -11,92 +13,113 @@ layout: workshop
In this workshop, we will explore fundamental concepts and practical techniques for image registration, focusing on applications in microscopy, material science, and earth science.
{{</ notes >}}

{{< horizontal >}}

<span style="font-size: 24px; color: white;">♡</span>
<span style="font-size: 24px; color: white;">♡</span>

<img src="img/registration.png" alt="MRI CT registration" style="width: 700px;" />

<span style="font-size: 24px; color: white;">♡</span>
<span style="font-size: 24px; color: white;">♡</span>

{{</ horizontal >}}
![](img/registration_big.png)

<h4>Spatial alignment of two or more images.</h4>

- In science, it's an essential step for comparing or integrating data

{{< notes >}}
Image registration is the process of transforming different sets of data into one coordinate system.
{{</ notes >}}

---

## Applications in Various Fields

{{< notes >}}
Image registration is widely used across multiple disciplines.
Image registration is the process of aligning multiple datasets into a common coordinate system, enabling accurate comparison and analysis.
{{</ notes >}}

- **Microscopy**: Aligning slices in a 3D stack, channels, runs, tiles, modalities, or time points.
- **Medical Imaging**: Viewpoints, stacks, normalization to an atlas, co-registering images from different modalities (e.g., MRI, CT).
- **Material Science**: Comparing material properties under varying conditions.
- **Earth Science**: Aligning satellite images for change detection, georeferencing, integration from different sensors.

---

## Common needs in research

{{< horizontal >}}

Multimodal:
![](img/multimodal.jpg)

Stitching:
![](img/stitching.jpg)

Stack:
![](img/slice_to_slice.jpg)

Viewpoint:
![](img/coregistration.jpg)

Stitching:
![](img/stitching.jpg)

Temporal:
![](img/timesteps.jpg)

{{</ horizontal >}}

- Essential for comparing or integrating data
---

## Applications in Various Fields

{{< notes >}}
Image registration is widely used across multiple disciplines.
{{</ notes >}}

- **Microscopy**: Aligning slices in a 3D stack, channels, runs, time points, tiles (stitching), and modalities.
<br><br>
- **Medical Imaging**: Viewpoints, stacks, normalization to an atlas, co-registering images from different modalities (e.g., MRI, CT).
<br><br>
- **Material Science**: Comparing material properties under varying conditions.
<br><br>
- **Earth Science**: Georeferencing, integration from different sensors, aligning satellite images for change detection.

---

## Integrated Techniques: One-Step Registration

{{< notes >}}
Introducing registration methods that integrate detection and transformation into a single process.
Introducing registration methods that combine both matching and transformation into one smooth process, simplifying image alignment.
{{</ notes >}}

- **Intensity-Based Registration**
- Iterative - Optimize pixel intensity similarities directly to align images
- Iterative process that optimizes aligned pixel intensity similarities (e.g. **correlation coefficient** or **MSE**).
- **Mutual Information-Based Registration**
- Iterative - Use statistical dependence to align multimodal images
- Iteratively aligns multimodal images by maximizing the statistical relationship between them.
- **Frequency Domain Methods**
- Compute transformations using Fourier transforms in the frequency domain.
- Transforms images into the Fourier space to compute alignment transformations.
- **Deep Learning-Based Registration**
- Neural networks predict transformations directly from image data
- Uses neural networks to predict transformations from image data, learning complex patterns.

---

## Example Technique: Correlation Coefficient

![](img/correlation_r45_s1.5.png)
![](img/correlation_r10_s1.1.png)
![](img/correlation_r2_s1.png)
![](img/correlation_r0_s1.png)

{{< notes >}}
[https://github.com/bellonet/image-registration-workshop/blob/main/example_notebooks/correlation_example.ipynb
](https://github.com/bellonet/image-registration-workshop/blob/main/example_notebooks/correlation_example.ipynb
)
{{</ notes >}}

---

## Example Technique: Mutual Information

{{< horizontal >}}

<img src="img/joint_histogram_iterative.gif" alt="Mutual Information iterations"/>

![](img/mutual_information_equation.png)

{{</ horizontal >}}

- Looking at the equation, the more structure we have in the joint histogram, the lower its entropy, and thus the mutual information is higher.

{{< notes >}}
Entropy is maximized when there is maximum uncertainty or randomness in the pixel intensities.
Meaning that an image with a single pixel intensity value will have minimum entropy, and an image with a uniform distribution of pixel intensities will have maximum entropy.
{{</ notes >}}

- [https://github.com/bellonet/image-registration-workshop/blob/main/example_notebooks/mutual_information.ipynb
](https://github.com/bellonet/image-registration-workshop/blob/main/example_notebooks/mutual_information.ipynb
)

---

## 2 Step Techniques - Feature Detection & Transformation
<h2>2 Step Techniques - Feature Detection & Transformation</h2>

{{< notes >}}
An overview of common methods used in image registration, highlighting the two main steps involved.
Expand Down
278 changes: 278 additions & 0 deletions example_notebooks/correlation_example.ipynb

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions layouts/page/solutions.html

This file was deleted.

2 changes: 1 addition & 1 deletion static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ section .horizontal > figure figcaption {

section .presentation-title {
flex: 1;
width: 50%;
width: 30%;
display: flex;
flex-direction: column;
justify-content: space-evenly;
Expand Down
Binary file added static/img/correlation_r0_s1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/correlation_r10_s1.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/correlation_r2_s1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/correlation_r45_s1.5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions static/img/edit_img.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 9,
"id": "7f71970e-f2f7-48ac-b9f1-507dcc677c5c",
"metadata": {},
"outputs": [],
"source": [
"from PIL import Image, ImageOps\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "23c64cd7-1ee0-4eef-b1a8-30e83e8384ef",
"metadata": {},
"outputs": [],
"source": [
"def save_img_copy(im_path):\n",
" # Open the image\n",
" img = Image.open(im_path)\n",
"\n",
" # Save the original image as f'{im_path}1'\n",
" base, ext = os.path.splitext(im_path)\n",
" original_save_path = f'{base}1{ext}'\n",
" img.save(original_save_path)\n",
" return img"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "9f5e11b0-5a4c-4760-98f0-05cabafd33ef",
"metadata": {},
"outputs": [],
"source": [
"def resize_image(im_path, resizing_factor):\n",
"\n",
" img = save_img_copy(im_path)\n",
"\n",
" new_size = (int(img.width * resizing_factor), int(img.height * resizing_factor))\n",
"\n",
" if resizing_factor < 1.0:\n",
" # Resize with antialias filter when downsampling\n",
" resized_img = img.resize(new_size, Image.ANTIALIAS)\n",
" else:\n",
" # Just copy the image if upsampling or maintaining size\n",
" resized_img = img.resize(new_size)\n",
"\n",
" # Save the resized image to the original path\n",
" resized_img.save(im_path)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "7b151e2c-5d7a-43fb-992c-ac6ad2e85091",
"metadata": {},
"outputs": [],
"source": [
"def pad_image(im_path, padding):\n",
"\n",
" img = save_img_copy(im_path)\n",
" \n",
" # Apply the padding (black padding by default)\n",
" padded_img = ImageOps.expand(img, border=padding, fill=(0, 0, 0)) # black fill\n",
" \n",
" # Save the padded image to the specified path\n",
" padded_img.save(im_path)\n"
]
},
{
"cell_type": "code",
"execution_count": 23,
"id": "5b517f7e-99ba-4c03-9f5f-acb9cebfe86a",
"metadata": {},
"outputs": [],
"source": [
"pad_image('registration.png', 100)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "c1c37b68-a636-4442-a877-a714f169eacc",
"metadata": {},
"outputs": [],
"source": [
"resize_image('registration_big.png', 1.5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1e3fffdb-1355-4790-940f-56e84abd0f5f",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Binary file added static/img/mutual_information_equation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/img/registration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/img/registration_big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed static/img/transformation_nb.png
Binary file not shown.
2 changes: 2 additions & 0 deletions static/reveal/dist/theme/white-hi.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ section.has-dark-background, section.has-dark-background h1, section.has-dark-ba
.reveal .slides {
display: flex;
text-align: left;
flex: 1;
}

.reveal .slides section,
Expand Down Expand Up @@ -116,6 +117,7 @@ section.subsection h1, section.subsection h2 {

.reveal .toc {
flex: 1;
font-size: 2vh;
}

.reveal .qr-code-slides {
Expand Down

0 comments on commit 7aba51e

Please sign in to comment.