Difference between revisions of "Image Intensity Processing"

Line 151: Line 151:
=== Gamma ===
=== Gamma ===
<nowiki>This can be though of as a non-linear histogram adjustment. Faint objects can be made more intense without saturating bright objects (gamma <1). Similarly, medium-intensity objects can be made fainter without dimming the bright objects (gamma > 1). The intensity of each pixel is “raised to the power” of the gamma value and then scaled to 8-bits or the min and max of 16-bit images.</nowiki>
<nowiki>Gamma performs a non-linear histogram adjustment. Faint objects become more intense while bright objects do not (gamma <1). Also, medium-intensity objects become fainter while bright objects do not (gamma > 1). The intensity of each pixel is “raised to the power” of the gamma value and then scaled to 8-bits or the min and max of 16-bit images.</nowiki>
For 8 bit images; New intensity = 255 ×&nbsp;''<nowiki>[(old intensity÷255)</nowiki>&nbsp;gamma'']
For 8 bit images; New intensity = 255 ×&nbsp;''<nowiki>[(old intensity÷255)</nowiki>&nbsp;gamma'']

Revision as of 14:48, 18 December 2013

Intensity vs Time analysis

Brightness and Contrast

Brightness contrast pic.png

Brightness is the visual perception of reflected light. Increased brightness refers to an image's increased luminance.

Contrast is the separation of the lightest and darkest parts of an image. An increase in contrast will darken shadows and lighten highlights. Increasing contrast is generally used to make objects in an image more distinguishable.

Adjust the brightness and contrast with “Image/Adjust/Brightness/Contrast...” to make visualization of the image easier.

Press the “Auto”  button to apply an intelligent contrast stretch to the the image display. Brightness and contrast is adjusted by taking into account the image's histogram. If pressed repeatedly, the button increases the percentage of saturated pixels.

The Reset button makes the “maximum” 0 and the “minimum” 255 in 8-bit images and the "maximum" and "minimum" equal to the smallest and largest pixel values in the image’s histogram for 16-bit images.

If the Auto  button does not produce a desirable result, use the region-of-interest (ROI) tool to select part of the cell and some background, then hit the “Auto” button again. The stretch will then be based on the intensities of the ROI.

Pressing the Apply button permanently changes the actual grey values of the image. If just analyzing image intensity do not press this button.

If you prefer the image to be displayed as “black on white” rather than “white on black”, then use the “inverted” command: “Image/Lookup Tables/Invert LUT”. The command “Edit/Invert” inverts the pixel values themselves permanently.

Getting intensity values from single ROI

If working with a stack, the ROI selected can be analyzed with the command: “Image/Stacks/Plot Z Axis Profile”. This generates a single column of numbers - one slice intensity per row.

The top 6 rows of the column are details of the ROI. This makes sure the same ROI is not analyzed twice and allows you to save any interesting ROIs. The details are comprised of area, x-coordinate, y-coordinate, AR, roundness, and solidity of the ROI. If the ROI is a polyline/freehand ROI rather than a square/oval, it acts as if the ROI is an oval/square. The (oval) ROI can be restored by entering the details prompted by the “Edit/Selection/Restore Selection” (hotkey: “Ctrl + Shift + E”) command.

The results are displayed in a plot-window with the ROI details in the plot window title. The plot contains the buttons List, Save, Copy. The Copy button puts the data in the clipboard so it can be pasted into an Excel sheet. The settings for the copy button can be found under “Edit/Options/Profile Plot Options”. Recommended settings include: Do not save x-values (prevents slice number data being pasted into Excel) and Autoclose  so that you don't have to close the analyzed plot each time.

Dynamic intensity vs Time analysis

The plugin “Plot Z Axis Profile" (this is the Z Profiler from Kevin (Gali) Baler (gliblr at yahoo.com) and Wayne Rasband simply renamed)  will monitor the intensity of a moving ROI using a particle tracking tool. This tool can be either manual or automatic. Use the “Image/Stacks/Plot Z Axis Profile”  command.

Getting intensity values from multiple ROIs

You can analyze multiple ROIs at once with Bob Dougherty’s “Multi Measure” plugin. The native “ROI manager” function does a similar job except doesn't generate the results in sorted columns. Check Bob’s website for updates: http://www.optinav.com/imagej.html

The Multi Measure plugin that comes with the installation is v3.2.

1. Open confocal-series and remove the background (See Background correction)

2. Generate a reference stack for the addition of ROIs. Use the “Image/Stacks/Z-project” function and select the “Average”.

3. Rename this image something memorable.

4. Open the “ROI Manager” plugin (“Analyze/Tools/Roi Manager ” or toolbar icon ).

5. Select ROIs and "Add" to the ROI manager. Click the "Show All" button to help avoid analyzing the same cell twice.

6. After selecting ROIs to be analyzed in the reference image, you can draw them to the reference image by clicking the "More>>" button and selecting Draw. Save the reference image to the experiment’s data folder and then click on the stack to be analyzed.

7. Click the "More>>" button in the ROI manager and select the “Multi Measure” button to measure all the ROIs. Click “Ok”. This will put values from each slice in to a single row with multiple columns per slice. Clicking on "Measure all 50 slices" will put all values from all slices and each ROI in a  single column.

8. Go to the “Results” window and select the menu item “Edit/Select All…”. Then “Edit/Copy”.

9. Go to Excel and paste in the data. Check that everything was pasted in correctly

Roi select all.jpg

10. To copy ROI coordinates into the Excel spreadsheet, there needs to be an empty row above the intensity data. Use the Multi Measure dialog and click the “Copy list” button.

14. In Excel, click the empty cell above the first data column and paste in the ROI coordinates. Save the ROIs with the Multi Measure button “Save”. Put them in the experimental data folder. The ROIs can be opened later either individually with the button “Open” or all at once with the button “Open All”.

Oval and rectangular ROIs can be restored individually from x, y, l, h values with the “Plugins/ROI/SpecifyROI…” command.

Ratio Analysis

Intensity ratio analysis.jpg

Ratiometric imaging compares the recordings of two different signals to see if there are any similarities between them. It is done by dividing one channel by another channel to produce a third ratiometric channel. This technique is useful because it corrects for dye leakage, unequal dye loading, and photo-bleaching. An example application would be measuring intracellular ion, pH, and voltage dynamics in real time.

Background subtraction is needed before analysis of dual-channel ratio images. See section  1.11 Background correction. The Ratio_Profiler plugin will perform ratiometric analysis of a single ROI on a dual-channel interleaved stack. The odd-slices are channel 1 images and the even slices are channel 2 images. If your two channels are opened as separate stacks, such as Zeiss, the two channels can be interleaved (mixed together by alternating between them) with the menu command "Plugins/Stacks - Shuffling/Stack Interleaver".

The plugin will generate a green-plot of the ratio values. Ch1÷Ch2 is the default and you can get Ch2÷Ch1 if the plugin is run with the Alt-key down. It will also generate a second plot of the intensities of the individual channels, Ch1 and Ch2, as well as a results table.

The first row of the results table contains values for the x, y, width and height of the ROI.

From the second row downward, the first column is the time (slice number), the second column is the Ch1 mean intensity, and the third channel is the Ch2 mean intensity and the ratio value. The stack must have its frame interval calibrated in order for the "Time" value to be in seconds. Otherwise, it is "Slices". The frame interval can be set for the stack via the menu command "Image/Properties" .

This table can be copied to the clipboard and pasted elsewhere with the "Edit/Copy All" menu command.


 Ratio Analysis Using ROI manager

1.Subtract the background from the image.

2. Open ROI manager (Analyze/Tools/ROI manager...) and click the "Show All" button.

3. Select the cells to be analyzed and add them to the ROI manager ("Add" button or keyboard 't' key).

4. Run the plugin.

The results window contains the mean  of ch1 and ch2 and their ratio. Each row is a timepoint (slice). The first row contains the ROI details.

To generate a reference image:

1. Flatten the stack with the menu command(Image/Stacks/Zproject" with "Projection type: Maximum"),

2. Adjust the brightness and contrast if necessary.

3. Select the new image and click the "More" button in the ROI manager. After that select "Label".



Obtaining timestamp data

Zeiss LSM

The LSM_Toolbox is a project aiming at the integration of common useful functions around the Zeiss LSM file format, that should enhance usability of confocal LSM files kept in their native format, thus preserving all available metadata.

In Fiji, corresponding commands are: "File/Import/Show LSMToolbox" which displays the toolbox, from which all commands can be called and "Help/About Plugins/LSMToolbox..." which displays information about the plugin.


Noran movies can be opened in several ways: File>Import>Noran movie opens entire movie as an image stack. File>Import>Noran Selection… allows you to specify a range of frames to be opened as a stack. The Noran SGI plugins are not bundled with the Fiji package. To receive them, please contact tonyc@uhnresearch.ca or their author, Greg Joss, so he can keep track of users. Greg Joss gjoss@bio.mq.edu.au is in the Dept. of Biology, Macquarie University, Sydney, Australia.


This reading can be found by using the menu command “Image/Show Info…”. Scroll down to get the time each slice was acquired. Select this time, copy it into Excel, and find the time number obtained by using the Excel menu command “Edit/Replace”. This will leave only the time data. The “elapsed” time can then be calculated by subtracting row 1 from all subsequent rows.


Linescanning involves acquiring a single line, one pixel in width, from a common confocal microscope instead of a standard 2D image. This is usually a faster way to take an image. All the single pixel-wide images are then stacked to recreate the 2D image.

A pseudo-linescan generation of a 3-D (x, y, t) image. It is useful for displaying 3-D data in 2 dimensions.

A line of interest is drawn followed by the command: “Image/Stacks/Reslice” or with the keyboard button “/”. It will ask you for the line width that you wish to be averaged. It will generate a pseudo-linescan “stack” with each slice representing the pseudo-linescan of a single-pixel wide line along the line of interest. Average the pseudo-linescan “stack” by selecting “Image/Stacks/Z-Project…” and use the Average command. A poly-line can be utilized, but this will only generate a single pixel slice.

 Fiji's default settings assume that stacks are z-series rather than t-series. This means that many functions related to the third-dimension of an image stack are referred to with a “z-” . Just keep this in mind.

FRAP (Fluorescence Recovery After Photobleaching) Analysis

The FRAP profiler plugin will analyze the intensity of a bleached ROI over time and normalize it against the intensity of the whole cell. After that it will find the minimum intensity in the bleached ROI and fit the recovery with this point in mind.

To use:

1. Open the ROI manager.

2. Draw around the bleached ROI and add it to the ROI manager.

3. Draw around the whole cell and add that to the ROI manager. The normalization corrects for the bleaching that occurs during image acquisition and assumes the whole cell is in the field of view.

The plugin assumes the larger of the two ROIs in the ROI manager is the whole cell ROI and that the smaller ROI is the bleached part.

4. Run the FRAP profiler plugin.

5. The plugin will return the intensity vs time plot, the normalized intensity vs time plot of the bleached area, and the curve fit.

Non-linear contrast stretching


You can have more control over brightness and contrast adjustments with the“Process/Enhance contrast” menu command. With a stack, it analyzes the each slice’s histogram to make the adjustment.

The “Equalize contrast” command applies a non-linear stretch of the histogram based on the square root of its intensity.

Equalize histrogram.jpg


Gamma performs a non-linear histogram adjustment. Faint objects become more intense while bright objects do not (gamma <1). Also, medium-intensity objects become fainter while bright objects do not (gamma > 1). The intensity of each pixel is “raised to the power” of the gamma value and then scaled to 8-bits or the min and max of 16-bit images.

For 8 bit images; New intensity = 255 × [(old intensity÷255) gamma]

Gamma can be adjusted via the “Process/Math/Gamma” command. It will allow you to adjust the gamma with the scroll bar. Click on “Ok” when you are finished. You can use the Scroll-bar to determine the desired gamma value on one slice of your stack  . There is also an option to preview the results .

Gamma pic.jpg


See the online reference: http://www.dai.ed.ac.uk/HIPR2/filtops.htm for a simple explanation of digital filtering.

Filters can be found under the menu item “Process/Filters.... Typically use a “Radius (pixels)” of 1 which equates to a 3×3 “kernel” – see online reference.

Mean filter: the pixel is replaced with the average of it and its neighbours within the radius. The menu item “Process/Smooth” is a 3×3 mean filter.

Gaussian filter: The is similar to smoothing but replaces the pixel with a pixel of value proportional to a normal distribution of it’s neighbours – not explained well, I know, but you’ve probably skipped the online reference and you need to read that to understand the way the filter works properly.

Median filter: The pixel is replaced with the median of it and its adjacent neighbours. This removes noise and preserves boundaries better than simple mean filtering, but can look odd. (The menu item “Process/Noise/Despeckle” is a 3×3 median filter).

"Convolve filter": This allows two arrays of numbers to be multiplied together. The arrays can be different sizes but must be of the same dimension. In image analysis this process is generally used to produce an output image where the pixel values are linear combinations of certain input values.

"Minimum": This filter, also known as an erosion filter, is a morphological filter that considers the neighborhood around each pixel and, from this list of neighbors, determines the minimum value. Each pixel in the image is then replaced with the resulting value generated by each neighborhood.

"Maximum": This filter, also known as a dilation filter, is a morphological filter that considers the neighborhood around each pixel and, from this list of neighbors, determines the maximum value. Each pixel in the image is then replaced with the resulting value generated by each neighborhood.

Sigma filter: A modification on the standard mean filter but preserves edges better – can be though of as a “gentle smooth”. This filter will have to be downloaded. The user specifies the kernel size, the Sigma width and the minimum number of pixels to include. A Sigma value for the kernel is calculated (based on the variance and mean of the intensities) and only pixels within this Sigma range (= Sigma × the user defined Sigma Width scaling factor) are used to calculate the mean. If there are too few pixels (exact number set in the user dialog:Minimum number of pixels) in the kernel that are within the Sigma range then the central pixel which is assumed to be spuriously low or high and the mean of the rest of the kernel is taken. Increasing theSigma width and the minimum number of pixels results in increased smoothing and loss of edges.

Kalman filter: This filter, also known as the Linear Quadratic Estimation, recursively operates on noisy inputs to compute a statistically optimal estimate of the underlying system state.

Anisotropic Diffusion. This is an edge preserving smoothing filter. It will have to be downloaded.

Anisotropic diffusion filter.jpg 

Background correction

Background correction can be done in several ways and is facilitated if the grey image has the “Image/Lookup Tables/HiLo” LUT loaded. This displays the zero values blue and the 255 white values red.

If the background is relatively even across the image, it is most simply remove with the Brightness/Contrast command – slowly raise the Minimum value until most of the background is displayed blue. The press the Apply button to change the grey-values and remove the background.

Rolling-Ball background correction

For uneven background the menu command “Process/Subtract background” can be used. This menu command removes uneven background from images using a “rolling ball” algorithm. The radius should be set to at least the size of the largest object that is not part of the background. It can also be used to remove background from gels where the background is white. Running the command several times may produce better results. The user can choose whether or not to have a light background, create a background (no subtraction), have a sliding paraboloid, disable smoothing, or preview the results. The default value for the rolling ball radius is 50 pixels.

 RAW   Process/Subtract Background…”
Raw rolling ball back corr.jpg Rolling ball back corr.jpg Processed rolling ball back corr.jpg


Once the background has been evened, final adjustments can be made with the Brightness/Contrast control.


Bright contr roll ball.jpg Histogram roll ball.jpg

Bright contr control roll ball.jpg

ROI background correction

The rolling-ball algorithm is time consuming. If the background is even across the field of view it is possible to select a background region of interest and subtract the mean value of this area for each slice from each slice. Use the selection tools to select an area of background and run the menu command “Process/Subtract Background”. This macro will subtract the mean of the ROI from the image plus an additional value equal to the standard deviation of the ROI multiplied by the scaling factor you enter (3 by default).

i.e. it subtracts [mean + (sd×scalingfactor)]

This macro also works with stacks and so can be used with time-courses with varying background.


Before correction
 Background intensity over time
After “ROI_BG_Correction
Roi back corr before.gif Roi back corr during.gif Roi back corr after.gif


Flat-field correction

Proper correction

This technique is applied to brightfield images. Uneven illumination, dirt/dust on lenses can result in a poor quality image. This can be corrected by acquiring a “flat-field” reference image with the same intensity illumination as the experiment. The flat field image should, ideally, be a field of view of the coverslip without any cells/debris. This is often not possible with the experimental coverslip, so a fresh coverslip may be used with approximately the same amount of buffer as the experiment. With fixed-specimens try removing the slide completely

Flat field correction.gif

1. Open both experimental image and flat-field image.

2. “Select all” of the flat-field image (hotkey: A) and measure the average intensity (hotkey: M). This value will appear in the results window and represents your k1 value below.

3. Use the “Image Calculator plus” plugin (“Analyse/Tools/Calculator plus” ).

4. i1 = experimental image; i2 = flat-field image; k1 = mean flat-field intensity; k2 = 0. Select the "Divide" operation.

This can also be done using the “Process/Image Calculator”function and ensuring the “32-bit Result” option is checked. You will then need to adjust the brightness and contrast and change the image to 8-bit.

Calculator plus flat field.jpg




Often it is not possible to obtain a flat-field reference image. However, it is still possible to correct for illumination intensity (although not small defects such as dust) by making a “pseudo-flat field” image by performing a large-kernel filter on the image to be corrected. This is particularly useful for DIC images where there is an intrinsic, and distracting, gradient in illumination.

This can be accomplished simply by subtracting the Gaussian-blurred image version of the image.

This can also be used with stacks for brightfield time-courses that vary in intensity with time. This is time consuming though.

PseudoCorrRawCorrected.gif The first RAW image (top) pseudo-flat field corrected. Here the pseudo-flat field corrects for the uneven illumination but does not correct the dust specks. Compare this with the result of a proper flat-field correction above.


FFT background correction

We sometimes see uneven illumination and also horizontal "scan lines" in transmitted light images acquired with confocal microscopes. This background can be corrected using the native FFT bandpass function (Process/FFT/Bandpass Filter...).

Experiment with the settings to optimize the filtering. The user can choose to filter structures down to a certain number of pixels. The default value is 40 pixels. He or she can filter small structures up to a certain value. The default value is 3 pixels. The user can choose from a drop down menu whether to suppress stripes with None, Horizontal, or Vertical. The tolerance of direction can be chosen. The default is 5%. Finally, the user can choose whether to allow autoscale after filtering, saturation of the image when autoscaling, whether or not to display the filter, and whether or not to process an entire stack.


Masking unwanted regions

Simple masking

Draw around the area you want with one of the ROI tools then use: “Edit/Clear outsideThis will change the area outside the selected region to the background value.


Complex masking

A more sophisticated masking can be done by “thresholding” the image and subtracting this new binary image from the original.

1. Duplicate the image (if it’s a stack it’s worthwhile generating a “average projection” of a few frames).

2. Threshold this image using the menu command “Image/Adjust/Threshold”.

3. Hit the Auto button and then adjust the sliders until cells are all highlighted red.

4. Then click “Apply”. Check the tick box: “black foreground, white background”. You should now have a white and black image with your cells black and background white. If you have white cells and black background, invert the image with “Edit/Invert”.

5. This can be smoothed (“Process/Smooth”) and the black area enlarged slightly with “Process/Binary/Dilate” to give a better mask

6. Using the regular Image calculator “Process/Image calculator” subtract this black and white “mask” image from your original image/stack.