Top  Previous  Next

threshMulti ( integer Input, integer Output, integer Mode, integer& Phases, floating& Min1,
floating& Max1 [, floating& Min2, floating& Max2 ] … )

Use this function to separate objects of interest from the background and segment them into different phases by specifying the ranges of pixel intensities that represent each phase. The output image is created as a multiphase one with a selected number of phases. Input pixels whose values fall within the range specified for a certain phase are converted into the output pixels with values equal to the corresponding phase number, while the pixels whose values are outside the intensity ranges specified for any of the phases are assigned the zero level.

The function can be called in the automatic or interactive modes. In the interactive modes, the user can adjust the range of intensities for the foreground pixels interactively and preview the segmented areas in real time, as the color overlays highlight the objects of interest in the input image.

An integer between 0 and 116 specifying the input image frame number. A value of 0 represents the DMA memory buffer of the video device. Values in the range of 100-116 correspond to hidden frames. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), only visible frames (1-99) can be used.  
An integer between 1 and 116 specifying the output image frame number. Values in the range of 100-116 correspond to hidden frames.  
An enumerated integer that describes the mode to use. Must be one of the following values:  
M_PRESET=0 – immediately applies the function to the input image using the values specified by the Min and Max parameters.  
M_DIALOG=1 – opens the Multiphase Threshold dialog that lets the user adjust the threshold ranges manually by moving the sliders on the dialog or picking up foreground levels with the Sampling tool. As the sliders are moved, the color overlay on the input image corresponding to the active phase expands or contracts.  
M_MOUSE=2 – activates the mouse mode that lets the user interactively select the threshold ranges for the active phase with a mouse. 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. Pressing INSERT adds a new phase, pressing 1, 2,…,9 switches to a specific phase, pressing DELETE removes the last added phase. To apply the changes and exit the function, press the left mouse button. To exit the function without applying the changes to the image, press the right mouse button.  
An integer between 1 and 16 specifying the amount of phases into which the input image will be segmented. Depending on a value of Phases, the function will expect a corresponding number of Min/Max pairs following this argument. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variable will return a selected number of phases.  
Min1, Max1, Min2, Max2, ….  
Floating arguments specifying the minimum and maximum levels of the thresholding range for each phase. A value of Max must be greater than a corresponding value of Min, and all the levels must be in the range of pixel values allowable for the input image type. The number of Min/Max pairs submitted to the function must be equal to the amount of phases specified by the Phases argument. If the function is called in the interactive mode (M_DIALOG or M_MOUSE), the variables will return interactively selected levels.  
Error flags

The flag set if successful.  
The flag set if failed.  
The flag set if the function cancelled in the interactive mode.  


This set of statements performs thresholding of a captured image using the dialog mode and outputs interactively selected levels for the first three phases to the terminal window.  
grabIm (1)  
Print "Use your mouse to select pixels for a phase"  
Print "Press Insert to add a new phase"  
Print "Press 1, 2, … to switch to a specific phase"  
threshMulti (1, 2, M_MOUSE, count, Min1, Max1, Min2, Max2, Min3, Max3)  
Print "Number of phases segmented: ", count  

For more information on the Multiphase Threshold dialog box, refer to ImageWarp User's Guide.