ImageThreshold
ImageThreshold [flags] imageMatrix
Performs thresholding operation converts a grayscale imageMatrix into a binary image. This operation supports all data types. However, the source wave must be a 2D matrix. If imageMatrix contains NaNs, the pixels corresponding to NaN values are mapped into the value 64. The values for the On and Off pixels are 255 and 0 respectively. The resulting image is stored in the wave M_ImageThresh.
Flags
| /C | Calculate the correlation coefficient between the original image and the image generated by the threshold operation. The correlation value is printed to the history area (unless the /Q flag is specified), it is also stored in the variable V_correlation. | ||||||||||||||||||||||||||
| /DEST=destWave | |||||||||||||||||||||||||||
| Specifies the destination wave created by the operation. If you do not use this flag, the operation saves the output in the wave M_ImageThresh in the current datafolder. | |||||||||||||||||||||||||||
| It is an error to specify the same wave as both srcWave and destWave. | |||||||||||||||||||||||||||
| When used in a function, ImageThreshold creates a real wave reference for the destination wave. See Automatic Creation of Wave References for details. | |||||||||||||||||||||||||||
| /DEST flag was added in Igor Pro 10.00. | |||||||||||||||||||||||||||
| /FREE | Creates the destination wave destWave as a free wave. | ||||||||||||||||||||||||||
| /FREE is allowed only in functions and only if destWave is a simple name or wave reference structure field. | |||||||||||||||||||||||||||
| See Free Waves for more discussion. | |||||||||||||||||||||||||||
| The /FREE flag was added in Igor Pro 10.00. | |||||||||||||||||||||||||||
| /I | use this flag to invert the values written to the image, i.e., set to zero all pixels above threshold. | ||||||||||||||||||||||||||
| /M= method | The calculated value will be printed to the history area (unless /Q is specified) and stored in the variable V_threshold. | ||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| /N | Sets the background level to 64 (i.e., NaN) | ||||||||||||||||||||||||||
| /O | Overwrite the original image with the calculated threshold image. | ||||||||||||||||||||||||||
| If you do not specify the /O flag, the threshold image is written into the wave M_ImageThresh. | |||||||||||||||||||||||||||
| /P= layer | When imageMatrix is a 3D wave /P selects a specific layer for which to compute the threshold. layer is the zero-based layer index. | ||||||||||||||||||||||||||
| If layer is -1, which is the default value, the threshold is computed for all layers of imageMatrix . | |||||||||||||||||||||||||||
| The /P flag is not compatible with /O. | |||||||||||||||||||||||||||
| The /P flag was added in Igor Pro 7.00. | |||||||||||||||||||||||||||
| /Q | Suppress printing calculated correlation coefficients (/C) and calculated thresholds (/M) to the history area. | ||||||||||||||||||||||||||
| /R=roiSpec | Use this flag to specify a region of interest (ROI). The ROI is defined by a wave of type unsigned byte (/b/u). The ROI wave must have the same number of rows and columns as the image wave. The ROI itself is defined by the entries/pixels whose values are 0. Pixels outside the ROI can take any nonzero value. The ROI does not have to be contiguous and can take any arbitrary shape. See ImageGenerateROIMask for more information on creating ROI waves. | ||||||||||||||||||||||||||
| In general, the roiSpec has the form {roiWaveName , roiFlag }, where roiFlag can take the following values: | |||||||||||||||||||||||||||
| |||||||||||||||||||||||||||
| By default roiFlag is set to 1 and it is then possible to use the /R flag using the abbreviated form /R=roiWave . | |||||||||||||||||||||||||||
| /T=thresh | Use this flag when you know the desired threshold value. | ||||||||||||||||||||||||||
| /W=Twave | Use this flag when you want to apply threshold intervals. Each interval is specified by a pair of values in the wave Twave. The first element in each pair is the low value and the second element is the high value. Pixel values that lie outside all the specified intervals are set to 0. | ||||||||||||||||||||||||||
References
The automatic thresholding method (/M=1) is described in: T. W. Ridler and S. Calvard, IEEE Transactions on Systems, Man and Cybernetics, SMC-8, 630-632, 1978.
The thresholding method used with /M=6 is described in: A.Z. Arifin and A Asano, "Image segmentation by histogram thresholding using hierarchical cluster analysis", Pattern Recognition Letters 27 (2006) 1515-1521.