"**How to choose the correct value of $\\sigma$?**\n",
"\n",
"This depends a lot on your images, in particular on the pixel size. In general, the chosen $\\sigma$ should be large enough to blur out noise but small enough so the \"structures of interest\" do not get blurred too much. Usually, the best value for $\\sigma$ is simply found by trying out some different options and looking at the result. \n"
"This depends a lot on your images, in particular on the pixel size. In general, the chosen $\\sigma$ should be large enough to blur out noise but small enough so the \"structures of interest\" do not get blurred too much. Usually, the best value for $\\sigma$ is simply found by trying out some different options and looking at the result.\n",
"s.set_title(f\"filtered image with $\\sigma$ = {sigma}\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
...
...
%% Cell type:markdown id: tags:
# Preprocessing, Filters
The presented material is based on material prepared by *Jonas Hartmann (Gilmour group, EMBL Heidelberg)*
%% Cell type:markdown id: tags:
## Table of Contents
1.[Background](#Background)
1.[Convolutional Filters](#Convolutional-Filters)
1.[Rank Filters]()
%% Cell type:markdown id: tags:
## Background
The goal of image preprocessing is to prepare or optimize the images to make further analysis easier. Usually, this boils down to increasing the signal-to-noise ratio by removing noise and background and by enhancing structures of interest.
The specific preprocessing steps used in a pipeline depend on the type of sample, the microscopy technique used, the image quality, and the desired downstream analysis.
The most common operations include:
- Deconvolution
- Image reconstruction based on information about the PSF of the microscope
- These days deconvolution is often included with microscope software
-*Our example images are not deconvolved, but will do just fine regardless*
- Conversion to 8-bit images to save memory / computational time
-*Our example images are already 8-bit*
- Cropping of images to an interesting region
-*The field of view in our example images is fine as it is*
- Smoothing of technical noise
- This is a very common step and usually helps to improve almost any type of downstream analysis
- Commonly used filters are the `Gaussian filter` and the `median filter`
-*Here we will be using a Gaussian filter.*
- Corrections of technical artifacts
- Common examples are uneven illumination and multi-channel bleed-through
-*Here we will deal with uneven signal by adaptive/local thresholding*
- Background subtraction
- There are various ways of sutracting background signal from an image
- Two different types are commonly distinguished:
-`uniform background subtraction` treats all regions of the image the same
-`adaptive or local background subtraction` automatically accounts for differences between regions of the image
-*Here we will do something similar to adaptive background subtraction when we do adaptive thresholding*
A Gaussian filter smoothens an image by convolving it with a Gaussian-shaped kernel. In the case of a 2D image, the Gaussian kernel is also 2D and will look something like this:
How much the image is smoothed by a Gaussian kernel is determined by the standard deviation of the Gaussian distribution, usually referred to as **sigma** ($\sigma$). A higher $\sigma$ means a broader distribution and thus more smoothing.
**How to choose the correct value of $\sigma$?**
This depends a lot on your images, in particular on the pixel size. In general, the chosen $\sigma$ should be large enough to blur out noise but small enough so the "structures of interest" do not get blurred too much. Usually, the best value for $\sigma$ is simply found by trying out some different options and looking at the result.