# Image Preprocessing Methods

MIA_Toolbox adds several extra preprocessing methods to the standard set available in the Analysis window's Preprocessing choices. These image-specific preprocessing methods are aware of the 2-D image nature of the data and are applied two-dimensionally.

## Image Preprocessing Methods

These image preprocessing methods are available from the Analysis menu by selecting "Preprocessing" -> "X-block" and choosing "Custom" (More about using the custom preprocessing window) which presents the available preprocessing methods. These image preprocessing methods are listed under "Image Filters"

This preprocessing methods window allows you to add selected methods to the applied preprocessing (shown in the panel on the right.) You can configure available parameters for any of these chosen methods by selecting a method on the right, and then clicking the "Settings" button which opens a new "Settings" window.

## Available Methods

The image analysis preprocessing methods are:

• Smooth: Spatial smoothing for images.
• Background Subtraction (Flatfield): Rolling-ball background subtraction for images.
• Close (Dilate+Erode): Perform dilation followed by erosion on a binary image.
• Dilate: Perform dilation on a binary image.
• Erode: Perform erosion on a binary image.
• Max: Max value over neighboring pixels.
• Median: Median value over neighboring pixels.
• Mean: Mean value over neighboring pixels.
• Min: Min value over neighboring pixels.
• Open (Erode+Dilate): Perform erosion followed by dilation on a binary image.
• Trimmed Mean: Trimmed mean value over neighboring pixels.
• Trimmed Median: Trimmed median value over neighboring pixels.

## Method Descriptions

The methods and their configurable parameters are described here:

### Smooth

Smoothing of grayscale image by applying convolution with the Gaussian function ${\displaystyle f(x)=1/(sqrt(2*pi)*window)*exp(-x^{2}/(2*window^{2}))}$

Parameters:

Window: an odd positive integer controlling the width of the Gaussian. Default = 7. Larger values increase smoothing.

### Background Subtraction (Flatfield)

Background subtraction removes a low-frequency 2D background from each slab of an image using the rolling-ball method. The method involves considering the 2-D grayscale image as a 3-D surface, where height is given by pixel intensity. The surface mapped by the center of a ball as it rolls over the 3-D surface identifies a smoother background surface (after adjusting its height by the ball radius) which ignores features which are narrower than the ball's radius. These narrow features are left after subtraction of the background.

If the 'Light Background' option is not checked (implying a dark background,) then the ball rolls along the underside of the 3-D surface and positive-going narrow features are left in the image after subtraction. If 'Light Background' is enabled the ball would roll along the upper side of the 3-D surface and negative-going narrow features are left in the image.

The method is based on the concept of the rolling ball algorithm described in Stanley Sternberg's article, "Biomedical Image Processing", IEEE Computer, January 1983 and as implemented in ImageJ's Subtract Background command. Also see http://imagejdocu.tudor.lu/doku.php?id=gui:process:subtract_background for further details.

Parameters:

Light Background: A checkbox, disabled by default. Enabled indicates the image has a light background (features of interest are decreased signal)
Radius: Specifies the radius of the rolling ball in units of pixels.

### Dilate

Dilation of a binary (0/1, 'off'/'on') image expands contiguous regions of 'on' pixels in an image. It examines the neighboring pixels within a 'Window' around each pixel. If more than the specified fraction ('Threshold') of neighboring pixels are 'on' then dilation turns the pixel 'on'. Pixels which are 'on' already are never altered.

Parameters:

Window: an odd positive integer indicating the size of square window to use. Default = 5. Larger values increase dilation
Threshold: fraction of an 'off' pixel's neighbors (within window) which must be 'on' to turn that pixel 'on'. Default = 0.1. Increased values inhibit dilation.

### Erode

Erosion of a binary (0/1, 'off'/'on') image contracts contiguous regions of 'on' pixels in an image. It examines the neighboring pixels within a specified 'Window'. If more than the specified fraction ('Threshold') of neighboring pixels are 'off' then erosion turns the pixel 'off'. Pixels which are 'off' already are never altered.

Parameters:

Window: an odd positive integer indicating the size of square window to use. Default = 5. Larger values increase erosion.
Threshold: fraction of an 'on' pixel's neighbors (within window) which must be 'off' to turn that pixel 'off'. Default = 0.1. Increased values inhibit erosion.

### Close (Dilate+Erode)

Perform dilation followed by erosion. This has the effect of smoothing shapes (clusters of 'on' pixels) in the binary image and filling small holes within shapes.

Parameters:

Window: an odd positive integer indicating the size of square window to use. Default = 5.
Threshold: fraction of pixel's neighbors (within window) used in the Dilate and Erode operations. Default = 0.1.

### Open (Erode+Dilate)

Perform erosion followed by dilation. This has the effect of smoothing shapes (clusters of 'on' pixels) in the binary image and removing small shapes or isolated pixels.

Parameters:

Window: an odd positive integer indicating the size of square window to use. Default = 5.
Threshold: fraction of pixel's neighbors (within window) used in the Dilate and Erode operations. Default = 0.1.

### Max, Min, Median and Mean

These methods give the max, min, median or mean value over neighboring pixels within a box with sides Window pixels long.

Parameters:

Window: an odd positive integer indicating the size in pixels of square box to use. Default = 5.

### Trimmed Median and Trimmed Mean

These methods give the median or mean value within the Window box where the 5% smallest and 5% largest values are excluded before taking the median or mean.

Parameters:

Window: an odd positive integer indicating the size in pixels of square box to use. Default = 5.