HLS Threshold  
Top  Previous  Next

 
Toolbar:   colorthreshold  
Menu:   Processing > Threshold ->Binary  
Script   threshHLD  

Use this command to separate objects of interest from the background based on the ranges of HLS
components that represent pixel colors.

You can adjust the ranges of values for each color component interactively and preview the segmented areas in real time, as the color overlays highlight the objects of interest in the input image.

If you choose this command, the HLS Threshold dialog box will appear with the following options:

Input
 
Displays the input image frame number. If you want to apply thresholding to another image, type or select the corresponding value.  
 
Output
 
Displays the number of the frame in which the segmented image will be created. Depending on the Preferences. ImageWarp will set it either to the first available value or to the Input frame number. Type or select another value if you want the output image to be created in a different frame.  

Histogram display
 
Displays the 3-component histogram for the input image or its selection. When you activate the Hue, Luminance or Saturation component by clicking the related ruler or slider, the histogram graph for the selected component will be brought to the foreground. Green color of the histogram graph corresponds to the Hue, Blue color to Luminance and Red color to Saturation component. As you adjust the minimum and maximum levels for the active component, the markers of the corresponding color move over the histogram visually representing the boundaries of the threshold range.  

Y-scale
 
Use the Y-scale slider located on the right side of the Histogram display to change the scale of the Y-axis of the histogram chart. The default range of the Y-axis is determined by the largest frequency value.  

Component rulers
 
Display the scales for the Hue, Luminance and Saturation components. The color bars that appear at the bottom of each ruler highlight the current threshold ranges for each selected phase. Use them as a visual reference while adjusting the threshold levels. To move the threshold range for a specific phase along the component scale, locate at the bottom of the ruler the area highlighted with the color of the phase of interest, click in it and drag to the desired position. The sliders' positions and entries in the boxes on the left of the sliders will update accordingly.  
 
Mode
 
Lets you choose the mode for selecting the threshold ranges.  
In the Dialog mode, the minimum and maximum level for each color component is selected by moving a related pair of sliders. As you move the sliders, the color overlay on the input image corresponding to the active phase expands or contracts. The numbers in the boxes on the left and the markers in the histogram are updated accordingly, displaying the intensity range for the selected component and active phase. You can also edit the threshold levels by selecting or typing the desired values in the boxes on the left of the sliders and pressing ENTER, or by dragging the highlighted areas at the bottom of the Component rulers.  
 
In the Mouse mode, the threshold range for the selected component and active phase is selected by moving the mouse in the horizontal and vertical directions. Moving the mouse upward and downward widens or narrows the threshold range respectively. Moving the mouse rightward or leftward raises or lowers the threshold range respectively. As the sliders are moved, the color overlay on the input image corresponding to the active phase expands or contracts. Note that if the HLSThreshold function was called from the script with the MOUSE mode selected, the dialog box will not appear. . Press INSERT key to add a new phase. Press 1, 2,…,9 keys to switch to a specific phase. Press H, L, S keys to switch between Hue, Luminance and Saturation respectively. Press DELETE to remove the last added phase. Press the left mouse button to apply the threshold to the image. Press the right mouse button to switch to the Dialog mode.  
 
Select the Preset mode if you want to generate a script command that will perform automatic segmentation without displaying the HLS Threshold dialog box. Select the threshold ranges by using the sliders or boxes on the right of the sliders, and then click Apply. Make sure the Script Editor is in the Record mode. The HLSThreshold function will be recorded into the script with the selected levels, and its Mode parameter will be set to AUTO.  

Manual sampling
 
Click this button to sample the image and create the segmentation range based on the values of the sampled pixels. When you move the cursor over the input image, the cursor will take shape of an eyedropper. Position the cursor over the area you want to define as belonging to the selected phase and click the left mouse button. If the segmentation ranges for the current image have not been assigned yet, they will be set to the H, L and S ranges of the pixel values within the Sampling window. Otherwise, the currently selected ranges will be expanded to include the average values of the color components in the area under the cursor.  

Undo sampling
 
Click this button to undo the last change in the threshold ranges made by the manual sampling.  

Sampling window
 
Lets you select the size of the square area covered by the manual sampling. The size of side of the square is measured in pixels, and it can be set to the length from 1 to 15.  
 
Multiphase
 
Select this check box to create the output image as a multiphase one. The input pixels whose values fall within the color ranges specified for a certain phase are converted into the output pixels with values equal to the phase number, while the pixels whose values are outside the color ranges specified for any of the phases are assigned the zero level. Clear the Multiphase check box if you want the output image to be of the same type as the input one. In this case, the foreground pixels will be transferred into the output image unchanged, while the pixels with values outside the specified ranges will be assigned the black level. See Image Types for more details.  
 
Add phase
 
Click this button to add a new phase. The new phase will encompass the entire range of pixel values for all color components and become active. The overlay color related to the new phase will appear in the pain on the right. Note that the pixels in the image that fall within the color ranges of more than one phase are assigned the lowest phase that contains the pixels.  
 
Select phase
 
Lets you select the active phase. The color related to the new phase will appear in the square on the right, and the bars of the same color will show up at the bottom of the Component rulers indicating the positions of the maximum and minimum thresholds for the phase. When a phase becomes active, you will be able adjust its threshold ranges for each color component by using the sliders, or by typing or selecting the desired values in the boxes on the left of the sliders. Note that you can also make a phase active by clicking the related areas on the Component rulers.  
 
Delete phase
 
Click this button to remove the last added phase.  

Preview mode
 
Select one of the following modes for previewing foreground pixels:  
 
Opaque  
 
The pixels corresponding to the objects of interest in the image are highlighted with the solid colors representing the selected phases.  
 
Transparent  
 
The pixels corresponding to the objects of interest are highlighted with the transparent colors representing the selected phases. In this mode, you can see the original objects through the transparent overlay.  
 
Apply
 
Applies the function to the input image and creates the output image.  
 
Record
 
Inserts the corresponding script command into the Script Editor without applying the function.