Commit ca77b9dc authored by Daniele Picone's avatar Daniele Picone
Browse files

2022 version of the notebook

parent c2e0cec5
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Laboratory session for the course of Image Analysis\n",
"## BE 1\n",
"### Duration: 2h\n",
"\n",
"\n",
"**Instructions:** Submit a **report** for each group (binome) of the session in a unique **notebook**, name it **LabX_Name1_Name2**, with X the number of the lab session and **Name1,2** your surnames. Upload it in the folder corresponding to your group and lab in **git**.\n",
"\n",
"**Deadline submission:** The material report should be submitted within a week from the lab work. The preparation has to be done individually as you will be evaluated on the spot at the **beginning** of the lab.\n",
"\n",
"**Objectives** The objectives of this lab work are:\n",
"- to understand how to resample an image using filtering and interpolation\n",
"- to understand how to manipulate the contrast and colors for enhancing the aspect of an image\n",
"- to observe some properties of the 2-D Discrete Fourier Transform (DFT)\n",
"- to use the 2D DFT for filtering"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Preparation\n",
"\n",
"**Resampling**\n",
"\n",
"- We want to reduce an image by a factor of two, that is, to transform an image of size $N \\times N$ to a smaller image of size $N/2 \\times N/2$ pixels. Briefly explain what are the different intuitive methods that you could apply.\n",
"\n",
"- Let us consider in this work the simple operation of subsampling by a certain factor. For a subsample by a factor of 2, e.g., this is equivalent take every second line and every second column. Consider the image Barbara (see below), what kind of artifacts could appear? Why? How could you improve the results?\n",
"\n",
"**Color space**\n",
"- We consider the basis transformation of a RGB image $\\mathbf{I}$ (whose red, green and blue channels are denoted, respectively with $\\mathbf{I}_R$, $\\mathbf{I}_G$ and $\\mathbf{I}_B$) to another color space, which is expressed in terms of luminance, yellow-blue chrominance and red-green chrominance (denoted, respectively, with $\\mathbf{I}_L$, $\\mathbf{I}_{C_1}$ and $I_{C_2}$). The transformation is expressed as follows:\n",
"\n",
"\n",
"$$\n",
"\\begin{align}\n",
" \\mathbf{I}_L&=\\frac{1}{\\sqrt{3}}\\left(\\mathbf{I}_R+\\mathbf{I}_G+\\mathbf{I}_B\\right)\\;,\\\\\n",
" \\mathbf{I}_{C_1}&=\\frac{1}{\\sqrt{6}}\\left(\\mathbf{I}_R+\\mathbf{I}_G-2\\mathbf{I}_B\\right)\\;,\\\\\n",
" \\mathbf{I}_{C_2}&=\\frac{1}{\\sqrt{2}}\\left(\\mathbf{I}_R-\\mathbf{I}_G\\right)\\;.\n",
"\\end{align}\n",
"$$\n",
"\n",
"- What is the initial color space and the final one?\n",
"- Show how to reconstruct $\\mathbf{I}$ from $\\mathbf{I}_L$, $\\mathbf{I}_{C_1}$ and $\\mathbf{I}_{C_2}$.\n",
"Hint: The matrix $\\mathbf{P}$ define the transformation matrix to the new color space is orthogonal, or in other words, its inverse $\\mathbf{P}^{-1}$ is equal to its transpose $\\mathbf{P}^*$. Specifically, $\\mathbf{P}$ is defined as:\n",
"\n",
"$$\n",
"\\mathbf{P}=\\begin{pmatrix}\n",
" \\frac{1}{\\sqrt{3}} & \\frac{1}{\\sqrt{3}} & \\frac{1}{\\sqrt{3}} \\\\\n",
" \\frac{1}{\\sqrt{6}} & \\frac{1}{\\sqrt{6}} & -\\frac{2}{\\sqrt{6}} \\\\\n",
" \\frac{1}{\\sqrt{2}} & -\\frac{1}{\\sqrt{2}} & 0 \n",
"\\end{pmatrix}\\;.\n",
"$$\n",
"\n",
"**Histograms**\n",
"\n",
"In the context of real imaging sensors, acquisitions are provided as quantization of physical parameters, such as luminance, which may have wildly different dynamics in the probability distribution of intensity values. Additionally, we may focus on just considering a subset of the intensity range. \n",
"\n",
"- Think about how to estimate these probability distributions with a frequentist approach. How may different clusters of intensities be grouped?\n",
"- Think about strategies on how to stretch such distributions to cover the whole range of intensity for visualization. \n",
"- What are the advantages and disadvantages of a linear transformation for such stretching?\n",
"\n",
"**Fourier transform**\n",
"\n",
"- Explain how do we extend, mathematically, the concept of monodimensional Fourier transform to two dimensions.\n",
"- Explain why the Fourier spectrum is well suited to describe the directionality of textures.\n",
"- Explain why is it useful to filter images.\n"
]
}
],
"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.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:markdown id: tags:
# Laboratory session for the course of Image Analysis
## BE 1
### Duration: 2h
**Instructions:** Submit a **report** for each group (binome) of the session in a unique **notebook**, name it **LabX_Name1_Name2**, with X the number of the lab session and **Name1,2** your surnames. Upload it in the folder corresponding to your group and lab in **git**.
**Deadline submission:** The material report should be submitted within a week from the lab work. The preparation has to be done individually as you will be evaluated on the spot at the **beginning** of the lab.
**Objectives** The objectives of this lab work are:
- to understand how to resample an image using filtering and interpolation
- to understand how to manipulate the contrast and colors for enhancing the aspect of an image
- to observe some properties of the 2-D Discrete Fourier Transform (DFT)
- to use the 2D DFT for filtering
%% Cell type:markdown id: tags:
## Preparation
**Resampling**
- We want to reduce an image by a factor of two, that is, to transform an image of size $N \times N$ to a smaller image of size $N/2 \times N/2$ pixels. Briefly explain what are the different intuitive methods that you could apply.
- Let us consider in this work the simple operation of subsampling by a certain factor. For a subsample by a factor of 2, e.g., this is equivalent take every second line and every second column. Consider the image Barbara (see below), what kind of artifacts could appear? Why? How could you improve the results?
**Color space**
- We consider the basis transformation of a RGB image $\mathbf{I}$ (whose red, green and blue channels are denoted, respectively with $\mathbf{I}_R$, $\mathbf{I}_G$ and $\mathbf{I}_B$) to another color space, which is expressed in terms of luminance, yellow-blue chrominance and red-green chrominance (denoted, respectively, with $\mathbf{I}_L$, $\mathbf{I}_{C_1}$ and $I_{C_2}$). The transformation is expressed as follows:
$$
\begin{align}
\mathbf{I}_L&=\frac{1}{\sqrt{3}}\left(\mathbf{I}_R+\mathbf{I}_G+\mathbf{I}_B\right)\;,\\
\mathbf{I}_{C_1}&=\frac{1}{\sqrt{6}}\left(\mathbf{I}_R+\mathbf{I}_G-2\mathbf{I}_B\right)\;,\\
\mathbf{I}_{C_2}&=\frac{1}{\sqrt{2}}\left(\mathbf{I}_R-\mathbf{I}_G\right)\;.
\end{align}
$$
- What is the initial color space and the final one?
- Show how to reconstruct $\mathbf{I}$ from $\mathbf{I}_L$, $\mathbf{I}_{C_1}$ and $\mathbf{I}_{C_2}$.
Hint: The matrix $\mathbf{P}$ define the transformation matrix to the new color space is orthogonal, or in other words, its inverse $\mathbf{P}^{-1}$ is equal to its transpose $\mathbf{P}^*$. Specifically, $\mathbf{P}$ is defined as:
$$
\mathbf{P}=\begin{pmatrix}
\frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} \\
\frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}} & -\frac{2}{\sqrt{6}} \\
\frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} & 0
\end{pmatrix}\;.
$$
**Histograms**
In the context of real imaging sensors, acquisitions are provided as quantization of physical parameters, such as luminance, which may have wildly different dynamics in the probability distribution of intensity values. Additionally, we may focus on just considering a subset of the intensity range.
- Think about how to estimate these probability distributions with a frequentist approach. How may different clusters of intensities be grouped?
- Think about strategies on how to stretch such distributions to cover the whole range of intensity for visualization.
- What are the advantages and disadvantages of a linear transformation for such stretching?
**Fourier transform**
- Explain how do we extend, mathematically, the concept of monodimensional Fourier transform to two dimensions.
- Explain why the Fourier spectrum is well suited to describe the directionality of textures.
- Explain why is it useful to filter images.
This diff is collapsed.
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment