Select the clips by thresholding
Now, we want to separate the clips from the background, i.e., select them. They clearly stand out from the background, thus a selection based on the gray value is appropriate. This operation is known as thresholding.
Enter threshold into the operator window. This is both the full name of an operator and part of other operator names. Thus, you get a list of matching operators with threshold pre-selected when you press Return. Press Return once more to confirm the selected operator and show its parameters.
In figure 4.4 you can see that the input parameter Image is set to Clip automatically. For input variables with no default value, reasonable suggestions are inferred automatically by collecting previous output variables of the same type. Therefore, the name of the most recent matching output parameter will be suggested (most recent being the closest predecessor of the current program line). In this example, only Clip is available.
Set MinGray and MaxGray to 0 and 30, respectively. This will select the dark pixels in the image.
Click Apply. This button executes the operator without adding it to the program. Additionally, it keeps the current parameters open for editing. This way, you can easily try different settings and immediately see the result. The selected pixels (the so-called region) are stored in the output variable Region, which is displayed in the variable window. The region is an image mask: White pixels are selected while black pixels are not.
The region is also displayed as an overlay in the graphics window. The selected pixels are displayed in red (unless you changed the default settings).
The selected threshold values are not perfect, but we will correct this later. For now, click Enter to add the operator to the program window. Contrary to clicking OK, this does not execute the operator. Note that the variable Region keeps its value but is no longer displayed in the graphics window. Also, the PC is not advanced, indicating that the second line of the program is yet to be executed.
Adding program lines with Enter is especially useful if some of the input parameters use variable names that will be added to the program at a later time.
Successor
Click on the just inserted program line to select it. You can let HDevelop suggest operators based on the selected line. Open the menu Suggestions ▹ Successors. This menu is filled dynamically to show typical successors of the currently selected operator. We want to split the selected pixels into contiguous regions. Move the mouse pointer over the menu entries. The status bar displays a short description of the highlighted operator. Looking through the menu entries, the operator connection looks promising, so we click on it. Any operator selected through this menu is transferred to the operator window.
Again, the variable names suggested by HDevelop look reasonable, so click OK. This time, two program lines are executed: The threshold operation and the connection operation. As noted above: Clicking OK executes from the PC to the IC.
In the graphics window, the contiguous regions calculated by the operator connection are now displayed in alternating colors.