NB2121 Practical 4 Exercises
NB2121 Practical 4 Exercises
Practical 4: Segmentation
Learning Goals
After this practical you should know by heart how to:
Use the particle analyzer of ImageJ with exlude/include options.
Threshold an image manually and with automatic methods.
Select the best thresholding method for a given image.
Apply binary watershed segmentation and when to use it.
Install a new plugin to extend the functionality of ImageJ.
Apply the gray-scale watershed segmentation plugin.
Work with the interactive neuron tracing plugin NeuronJ.
Split the color channels of a multichannel image.
Restore the ROI selection of one image into another.
Write a macro for multichannel image segmentation.
Particle Analysis
In the previous practical you have learned about binary morphology operations to
remove objects from the boundary and to fill holes after segmentation. Actually these
operations are already implemented in ImageJ (but now you know how they work ).
Question
Open Images / Morphology / CHO PCNA-GFP 1.tif from the previous practical,
duplicate the image, perform Gaussian blurring on the duplicate using σ =2, and
make the image binary (as before). Now run the command Analyze > Analyze
Particles… and use the same settings as in the previous practical, but also select
the options Exclude on edges and Include holes. Copy the ROIs back to the
original image and measure again the area and mean of the cell nuclei. Do you get
the exact same values as in the previous practical?
Answer
1
Intensity Thresholding
As we have learned in today’s lecture there are many different thresholding methods.
The ImageJ command for specifying an intensity threshold for an image is Image >
Adjust > Threshold... With this command you can manually select a threshold or let
ImageJ compute an automatic threshold using different methods.
Question
Run Image > Adjust > Threshold... on the Gaussian blurred version of image CHO
PCNA-GFP 1.tif from the previous exercise. The two sliders in the Threshold
window together specify an intensity range (a lower threshold and a higher
threshold). Move the sliders to see if you can find a range that includes all relevant
objects without any holes. What are the best threshold values?
Answer
The Threshold window also allows you to pick an automatic thresholding method. In
fact, the command Process > Binary > Make Binary that you used in the previous
practical, uses the Default thresholding method.
Question
Try all possible automatic thresholding methods one by one in the Threshold window
(do not press any of the window buttons but just select the methods) to see if there
is any method that finds the same threshold values as you did above. Which of the
methods comes closest? Explain why this method works well.
Hints: 1) From the name of the best method you will see it is one of the methods we
discussed in today’s lecture. 2) Look at the histogram of the image.
Answer
2
In this exercise you have learned how to select a threshold range, either by adjusting
the sliders in the Threshold window or by picking an automatic thresholding method
from the pull-down list, but you have not actually applied it.
If you really need to apply a selected threshold range, you can press the Apply
button (make sure to select the Dark background option so that objects are white
and the background is black in the resulting binary image).
However, some plugins in ImageJ do not require to explicitly make an image binary
first, but they will implicitly use the selected threshold range.
Question
Answer
Question
Open Images / Segmentation / Many Cell Nuclei 1.tif. The image contains a large
number of fluorescently labeled cell nuclei and many of them are touching. There are
also some small spots in the image that are not really nuclei. Apply thresholding, the
binary watershed method, and the particle analyzer to get the ROIs of all true nuclei
3
within the image (not at the boundary). How many nuclei do you find in total?
Answer
If you cannot find this menu command, it means the plugin is not installed in your
ImageJ version. In that case you first need to install it. Go to the Practicals / Plugins
section on Brightspace and download the file Watershed_.jar. Close ImageJ and put
the downloaded file in the plugins subfolder of your ImageJ folder (on your hard
disk) and restart ImageJ. The Plugins menu should now have the above command.
Manually installing plugins in ImageJ is really that simple.
Check today’s lecture to see how gray-scale watershed segmentation works. The
image is considered as a landscape, which is flooded from below, and dams are built
to prevent merging of basins. In order to have our objects of interest as the basins,
we should make sure they are dark against a bright background. So we need to
invert the image first. The ImageJ command is Edit > Invert.
Reopen Images / Segmentation / Many Cell Nuclei 1.tif and invert it. Then run
Plugins > Watershed > Watershed Segmentation to open the window below and
start with the exact same settings as shown.
4
Now click the button Start Watershed to see the results of the gray-scale watershed
segmentation method. As you will see, using the given settings, the method produces
a large number of false objects. This is called oversegmentation (conversely, if a
method produces too few objects, it is called undersegmentation).
To count how many objects were found by the watershed method, go to the Display
field in the Watershed window, select option Object/Background binary, and click
the Show button. The result is a binary image, from which (after inversion) you can
count the number of cells by using the particle analyzer (as before).
To get better results, you need to play around with the parameter settings of the
watershed method. The most important parameters are the following:
Gaussian blurring: Clicking the Smooth button will result in a Gaussian blurred
version of the original image that contains less local minima and maxima. The
watershed method can then be applied to that image.
Min level: The minimum intensity level from where the flooding process starts.
Connected pixels with lower intensity are considered as one object.
Max level: The maximum intensity level for the flooding process. All pixels above
this level are considered background.
5
Question
Repeat the gray-scale watershed segmentation for image Many Cell Nuclei 1.tif
using different parameter values. Which values of the parameters Gaussian
blurring, Min level, and Max level produce the best segmentation result? Do you
indeed get a better separation of touching objects than you were able to get with the
binary watershed segmentation? Measure the number of cell nuclei and compare
with what you found in the previous exercise.
Answer
For the next exercise we will use the plugin Plugins > NeuronJ. That plugin was
developed specifically for interactive tracing of dendrites and axons (together often
called “neurites”). If you cannot find the plugin in the menu, it means that it is not yet
installed, so you need to install it first. It is part of the ImageScience update site (see
the section in Practical 1 that explains how to install an update site).
Now run Plugins > NeuronJ. The plugin has its own tool buttons that temporarily
replace the tool buttons of ImageJ until the plugin is closed. Move the mouse pointer
over the tool buttons of NeuronJ to read about their function.
Press the tool button corresponding to the text "Load image/tracings" and open the
file Images / Segmentation / Neuron Image 1.tif.
6
Press the tool button corresponding to "Add tracings". Upon pressing this button, the
plugin does some quick image filtering operations (you may see a progress bar for a
second or so) to figure out where the neurites (linear image structures) are located in
the image and what their local orientations are.
When you move the mouse pointer over the image window you will see that the
cursor has now changed to a crosshair cursor (in white) with a smaller crosshair
cursor (in red) beneath it. That second cursor snaps to prominent local image
structures and helps to make point selection more accurate.
Click a point on the longest neurite near the soma (cell body) of the neuron and then
move the cursor around. You will see that a red line is drawn from the selected point
to the current position of the cursor, which tries to follow linear image structures as
best as possible. Move the cursor as far as possible along the longest neurite, just
before the plugin starts to make errors, and click again. Repeat this process until you
have traced the entire neurite (double-click to add the last point).
Press the tool button corresponding to "Measure tracings" and deselect everything
except for Display tracing measurements. Upon pressing Run, basic statistics of
the traced neurite are computed, which are shown in a new results window.
Question
What is the total length of the longest neurite in image Neuron Image 1.tif?
Answer
Press the tool button corresponding to "Quit NeuronJ" (the right-most button) to quit
the plugin and restore the tool buttons of Fiji.
7
And in order to make a correct image segmentation of one of the channels, we often
need information from the other channel.
Open Images / Segmentation / DNA RNA Levels.tif. The image has two channels:
Channel 1 (red) primarily shows the level of RNA (labeled with propidium iodide) in
the nucleus and in the cytoplasm of the cell; Channel 2 (blue) shows the level of DNA
(labeled with Hoechst) in the nucleus.
Challenge
Make a macro that fully automatically measures the total intensity (called integrated
density in the ImageJ) of the RNA in the nucleus (not in the cytoplasm).
Hints: 1) It is best to first split the channels into separate images, using command
Image > Color > Split Channels. 2) A selection (outline) made in one image can be
copied to another image by activating that image and running the command Edit >
Selection > Restore Selection.
Solution