Difference between revisions of "Image Intensity Processing"

(Simple masking)
(Rolling-Ball background correction)
Line 228: Line 228:
| style="border:none;padding:0.0194in;"| [[File:bright_contr_roll_ball.jpg]]
| style="border:none;padding:0.0194in;"| [[File:bright_contr_roll_ball.jpg]]
| style="border:none;padding:0.0194in;"| [[File:histogram_roll_ball.jpg]]
| style="border:none;padding:0.0194in;"| [[File:histogram_roll_ball.jpg]]
| style="border:none;padding:0.0194in;"| [[File:bright_contr_control_roll_ball.jpg]]
| style="border:none;padding:0.0194in;"|  

Revision as of 13:17, 23 October 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.

To improve the visualization of the image, the displayed brightness and contrast can be adjusted with “Image/Adjust/Brightness/Contrast...”.

The “Auto”  button applies an intelligent contrast stretch to the way in which the image is displayed. The brightness and contrast is adjusted based on an analysis of the image's (or selection’s) histogram. If pressed repeatedly, it allows an increasing percentage of pixels to become saturated.

Reset changes the “maximum” and “minimum” back to 0 and 255 for 8-bit images and back to the maximum and minimum of the image’s histogram for 16-bit images.

If the Auto  button does not produce a desirable result, select a region of the cell plus some background with a region-of-interest (ROI) tool, then hit the “Auto” button again. It will then do a stretch based on the intensities within the ROI.

Pressing the Apply button permanently changes the actual grey values of the image. Don’t press this button while analyzing image intensity!

If you prefer the image to be displayed as “black on white” rather than “white on black”, the image display can be “inverted” by the command “Image/Lookup Tables/Invert LUT”. The command “Edit/Invert” inverts the pixel values not just the way the image is displayed.

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 is useful to ensure the same ROI isn’t analyzed twice and allows relocation of 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, the details are given as if the ROI was 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 copies the data to the clipboard where it can be pasted into a waiting 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 (prevents you having 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

Multiple ROIs can be analyzed at once using Bob Dougherty’s “Multi Measure” plugin. There is a native “ROI manager” function that does a similar job except the results generated are not sorted into 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. Remove background (See Background correction)

2. It’s worthwhile generating a reference stack to add the ROIs to. Use the “Image/Stacks/Z-project” function. Select the “Average” option.

3. Rename this image “Ref expt name” or something memorable.

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

5. Select ROIs and "Add" to ROI manager. Clicking "Show All" helps avoid analysing the same cell twice.

6. Once finished selecting ROIs to be analysed 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 select the stack to be analysed by clicking on it.

7. Click "More>>" button in the ROI manager and select “Multi Measure” button to measure all the ROIs. Click “Ok”. This will put values from each slice in to a single row (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 “Results” window. Select menu item “Edit/Select All…”. Then “Edit/Copy”.

9. Go to Excel and paste data. With large data sets this can take some time so check you’re pasting new data in and not the last dataset copied from Multi Measure.

Roi select all.jpg

10. To copy ROI co-ordinates in to the Excel spreadsheet, ensure there is an empty row above the intensity data. Got to Multi Measure dialog and click “Copy list” button.

14. Go to Excel, select the empty cell above the first data column and then paste the ROI co-ordinates.

The ROIs can be stored and re-opened later using the Multi Measure dialog button “Save”. Save them in the experimental data folder. The ROIs can be opened later either individually (Multi Measure dialog button “Open”) or all at once (Multi Measure dialog button “Open All”) which opens all the ROIs in a folder.

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

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.

Analysis of dual-channel ratio images requires careful background subtraction prior to analysis. See section  1.11 Background correction. The Ratio_Profiler plugin will perform ratiometric analysis of a single ROI on a dual-channel interleaved stack, i.e. the odd-slices are channel 1 images, the even slices channel 2. Perkin Elmer Ultraview and Leica SP dual channel experiments can be directly imported as an interleaved stack using the menu command "File/Import/Image Sequence". If your two channels are opened as separate stacks, e.g. 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 by default; Ch2÷Ch1 if the plugin is run with the Alt-key down); a second plot of the intensities of the individual channels (Ch1 and Ch2); and a results table.

The first row of the results table is the x, y, width and height of the ROI.

From the second row downward, the first column is the time or slice number; the second column the Ch1 mean intensity, Ch2 mean intensity and the ratio value. If the stack has its frame interval calibrated, the "Time" value will be in seconds otherwise it is "Slices". The frame interval can be set for the stack via the menu command "Image/Properties" dialog.

This table can be copied to the clipboard for pasting to another program by using the "Edit/Copy All" menu command.


 Ratio Analysis Using ROI manager

1. BG subtract 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 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 (Image/Stacks/Zproject" "Projection type: Maximimum"),

2. Adjust the brightness and contrast if required.

3. Ensure the new image is selected and click the "More" button in the ROI manager then 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 can be accessed via the menu command “Image/Show Info…”. Scroll down and it should give the time at which each slice was acquired. This can be selected, copied in to Excel and the time number obtained by searching and replacing (Excel menu command “Edit/Replace”) the text, leaving only the time data. The “elapsed” time can then be calculated by subtracting row 1 from all subsequent rows.


“Linescanning” is a mode of acquisition common to many confocal microscopes where a single pixel wide line is acquired over a period of time instead of the norma1 2-D, x-y image. Usually this allows faster acquisition. The single pixel wide images over the time course are stacked from left to right to generate a 2-D image (i,e, x-t).

A “pseudo-linescan” is the generation of a linescan-type x-t plot from a 3-D (x, y, t) timecourse and can be useful in displaying 3-D data (x, y, t) in 2 dimensions.

A line of interest must be drawn followed by the command: “Image/Stacks/Reslice” or keyboard “/”. It will prompt for the line width. Enter the width of line you wish to be averaged. A pseudo-linescan “stack” will be generated, each slice representing the pseudo-linescan of a single-pixel wide line along the line of interest. To average the pseudo-linescan “stack”, select “Image/Stacks/Z-Project…” and select the Average command. A polyline can be used although this will only allow a single pixel slice to be made.

This example shows the elementary calcium events preceding a calcium wave. HeLa cell loaded with the calcium-sensitive fluorophore, Fluo-3 and imaged whilst responding to application of histamine. (A). Frame taken from time-course at the peak of the calcium-release response. (B) The line of pixels along X-Y was taken and stacked side by side from right-to left to generate a "pseudo-line scan". This allows visualisation of the progression of the wave from its initiation site.

 Fiji assumes stacks to be z-series rather than t-series so many functions related to the third-dimension of an image stack are called “z-” something – e.g. “z-axis profile” is intensity over time plot.

FRAP (Fluorescence Recovery After Photobleaching) Analysis

The FRAP profiler plugin will analyse the intensity of a bleached ROI over time and normalise this against the intensity of the whole cell. It will then find the minimum intensity in the bleached ROI and fit the recovery  from this point.

To use:

1. Open the ROI manager.

2. Draw around the bleached ROI and Add to the ROI manager.

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

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

4. Run the FRAP profiler plugin.

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

The normalisation corrects for the bleaching dues to image acquisition and assumes the whole cell is in the field of view.

normalised intensity at time t = It = (Ibt ÷ Ibmax)  ÷ (Ict ÷ Icmax)

Ibt= intensity of bleached ROI at time t.

Ict= intensity of whole cell at time t.

Non-linear contrast stretching


More control of the brightness and contrast adjustment can be achieved with the“Process/Enhance contrast” menu command. Here, when applied to a stack, it applies the adjustment based on each slice’s histogram, not just the one currently displayed as is done with the Brightness and Contrast window.

“Equalize contrast” applies a non-linear stretch of the histogram based on the square root of the intensity (see online guide to image processing: http://www.dai.ed.ac.uk/HIPR2/histeq.htm).

Equalize histrogram.jpg


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.

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.