7. Image Analysis
7.2. Image Segmentation
7.2.1. Thresholding
7.2.1.1. Basic Way to Threshold an Image
Specifying correct threshold limits is a crucial procedure of the automated image analysis. The point is to determine which pixels will and which will not be included in the binary layer and thereby distinguish objects to be analyzed from background. Thresholding can be performed in the following modes:
2) Run the View > Analysis Controls > Thresholding command to display theThresholdingpanel:
Figure 7.3. Thresholding panel
3) In the top toolbar, select the color mode which will be used for thresholding. According to the type of image opened, the following modes could be available:RGB,HSI,IntensityandMCH. See 7.2.1.2. Color Modes.
4) Select one of the pixel-picking tools (e.g. ) and start clicking on objects in the image you want
to detect. Color values of each of the clicked pixel(s) are used to adjust the low and the high threshold values so that the clicked pixel would stay inside the thresholded interval.
Apart from this “clicking” method, the thresholds can be adjusted directly within the histogram by dragging the vertical lines which highlight the thresholded interval.
5) All pixels having their numeric values inside the thresholded interval become a part of the resulting binary layer.
6) Very often, also other binary objects appear in the image which you did not intend to detect, for example dust particles with intensity similar to the specimen, etc. To eliminate these mis-detected object, use one or more tools available at the bottom of the panel. You can either apply some morphology functions to the binary layer or apply size or circularity restrictions to detected objects. See 7.2.1.3. Tips and Tricks.
7.2.1.2. Color Modes
RGBTheRGBthresholding mode is available only if an RGB image is opened. There are two ways how to define the threshold limits, by choosing reference points within the image, or by defining the limit values for each color channel.
HSITheHSIthresholding mode is available only if an RGB image is opened. The thresholding procedure works the same way as in the RGB mode except that the pixel values are displayed in the HSI (Hue, Saturation, Intensity) color space and that theSaturationandIntensitychannels can be switched OFF. Therefore you can threshold over theH,HS, orHIchannels only. Switch the channel off by deselecting the check box in the top-left corner of the channel histogram.
Per channelThis mode is dedicated to perform threshold on multichannel images, but can be applied to RGB images as well. It is not available when working with a monochromatic (single channel) image.
Note
If there are too many channels, only one channel histogram is displayed. Switch between the channels by selecting their names from the bottom pull-down menu.
IntensityThe thresholding procedure works the same way as in the RGB mode except that it is performed on the intensity pixel values.
7.2.1.3. Tips and Tricks
Threshold Adjustments
Thresholding parameters can be adjusted very precisely in the following way:
• Threshold limits of each channel can be adjusted by rewriting the values in the top-left/top-right corner of each channel histogram.
• Threshold range of each channel (the colored stripe) can be shifted by mouse. Place the cursor in the middle of the range (a circle appears) and drag it left or right.
• Threshold limits of each channel can be adjusted by mouse. Place the cursor on the edge of the thresholding range and drag it left or right.
The two last behaviors can be further modified by pressing additional keys:
• Move the threshold using the right mouse button - the binary layer in the image is not updated con- tinuously, but is updated only once after the mouse button is released. Such operation saves some computing and therefore is quicker.
• Hold Shift while moving the threshold limits - the threshold adjustment is performed on all channels together (RGB images only).
• Hold Ctrl while moving the threshold limits - both the low and the high threshold limits move in opposite directions.
Binary Operations
Four basic operations can be performed on the binary layer before it is displayed on screen. To turn the operation on, click on the up arrow button in order to define the number of its iterations:
CleanRemoves small objects from binary image.
SmoothSmooths the binary image contours.
Fill HolesFills holes within binary objects.
SeparateSeparates objects.
Restrictions
SizeDefine size range using min/max value in the edit boxes or using the slider.
CircularityDefine circularity range using min/max value in the edit boxes or using the slider.
Thresholding Large Images
If thresholding images larger than 5000 x 5000 pixels, a new check box calledPreview on selected area onlyis displayed. This feature enables to display the threshold preview just on a limited area to speed up the thresholding adjustment.
Changing Appearance of the Binary Layer
To change the color or transparency of the layer, right-click the Overlaybutton in the right image toolbar. A contextual menu appears, where you can select one of the predefined transparency levels, or run theColorize Binary Objectscommand. This command displays the binary objects in several dif- ferent colors. The algorithm ensures that two neighboring objects are never colored by similar colors. See 7.3.4. Mathematical Morphology Basics.
7.2.2. Spot Detection
This function opens the Spot Detection dialog window. It is used mainly for detecting circular objects with similar sizes. Bright spot and dark spot detection methods are split into individual dialog windows.
Figure 7.4. A typical, suitable sample for Spot Detection.
ChannelSelect a channel on which you want to detect objects. If multichannel file is opened, spectral group selection is available.
MethodForBright Spotsdetection choose Bright, Clustereddetection method if you want to detect clustered bright objects on a dark background or Bright, Different Sizesfor detecting differently sized bright objects on a dark background.
ForDark Spotsdetection choose Dark, Clustereddetection method if your clustered objects are dark and their background is light or Dark, Different Sizesmethod if your objects have dif- ferent sizes and your background is light.
OutputBinary output defines in which form the detected objects will be saved.Circular Areasaves one circle for each detected spot whereasSpotsaves a center point with a defined pixel size.
GrowingTheGrowingcheck box can be used to save grown regions with borders between adjacent spots. The function itself finds local threshold values for each of the spots detected. Therefore it matches the exact shape of the object. The numeric value represents image intensity degrees. Pick intensity
function can be used to get a reference pixel intensity from the picture by a single mouse click. Use the slider to adjust theGrowingvalue.
Typical DiameterAdjust the typical size of your objects using the slider or edit box.
ContrastAdjust the contrast value of your spots using the slider or edit box.
Object symmetry: detect ... objects.Can be used to add yet undetected/remove already detected spots based on their symmetry.
Remove Dark ObjectsCheck this option and adjust the position of the slider to exclude dark objects. The more left you move the slider, the more objects appear.
OKUses the actual settings for performing Spot Detection.
CloseCloses the Spot Detection window.
HelpOpens this help file.
PreviewShows the changes directly on the actual frame of your opened image. Previewing progress is shown below this check box.
How to detect Circular Areas
1) Start by opening your image for the Circular Area detection. Select the proper detection method. For bright spots on a dark background choose Bright Spots. For dark spots on a bright background choose Dark Spots.
2) If you can't see any detected objects in your image yet, and yourPreviewbutton is checked, you should press theResetbutton.
3) Now choose theBright / Darkvs.Clustered / Different SizesdetectionMethodbased on your image. Continue by adjusting theTypical Diametervalues to fit our objects tightly inside the circles. Now adjust theContrastslider to remove unwanted spots. Optionally adjust theRemove Dark Objectsslider to remove undesirable dark spots.
4) If you are satisfied with the object detection, choose where to apply the current settings (Current Frame, All Frames or a Selection) and clickOK. Now you can save the new binary layer together with your file.
Note
Circular areas detected close to each other are automatically separated.
Figure 7.5. Circular Area output
Note
To see the binary layers as shown in the image above, right-click the View Overlay icon on the Image window toolbar and select Transparency 100% or use Ctrl +up/down arrow keys.
How to detect Spots
1) Do steps 1-3 from the How to detect Circular Areas procedure.
2) Switch the radio button fromCircular AreatoSpotand adjust the pixel size of the spots.
3) Choose where to apply the current settings (Current Frame, All Frames or a Selection) and click
OK.
How to detect Growing
1) Do steps 1-3 from the How to detect Circular Areas procedure.
2) Check theGrowingcheck box.
3) Adjust the slider position to augment/diminish the regions. Optionally use the Pick intensity
feature to grab the pixel intensity threshold directly from your image.
4) Choose where to apply the current settings (Current Frame, All Frames or a Selection) and click
OK.