GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / IsBitonal Method / IsBitonal(Int32,Int32) Method
GdPicture image identifier.
Threshold between 0 (max confidence) and 765 (min confidence). A value near or higher than 50 is highly suggested.
Example





In This Topic
IsBitonal(Int32,Int32) Method
In This Topic
Determines whether a GdPicture image or the area defined by SetROI() method is composed of black and white pixels only. This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead. This method accepts a threshold parameter which speaks to the confidence of the detection. Low Threshold values will require high confidence for the image to be determined as bitonal, and high values will require low confidence for the image to be determined as bitonal.
Syntax
'Declaration
 
Public Overloads Function IsBitonal( _
   ByVal ImageID As Integer, _
   ByVal Threshold As Integer _
) As Boolean
public bool IsBitonal( 
   int ImageID,
   int Threshold
)
public function IsBitonal( 
    ImageID: Integer;
    Threshold: Integer
): Boolean; 
public function IsBitonal( 
   ImageID : int,
   Threshold : int
) : boolean;
public: bool IsBitonal( 
   int ImageID,
   int Threshold
) 
public:
bool IsBitonal( 
   int ImageID,
   int Threshold
) 

Parameters

ImageID
GdPicture image identifier.
Threshold
Threshold between 0 (max confidence) and 765 (min confidence). A value near or higher than 50 is highly suggested.

Return Value

True if it is a bitonal image, else False.
Remarks

Use the GetStat() method to check if this method has completed successfully.

This method uses a linear formula to determine the color intent. To obtain more accurate result the ColorDetection() method should be used instead.

This method requires the Image Documents component to run.

Example
Finding out if an image is bitonal.
Saving an image to tiff ccitt IV or jpeg depending whether it is bitonal or not.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
 
    // Save the image to tiff ccitt iv in case it is bitonal otherwise save to jpeg.
    if (gdpictureImaging.IsBitonal(imageID, 0))
    {
        gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
    }
    else
    {
        gdpictureImaging.SaveAsJPEG(imageID, "image.jpg", 75);
    }
 
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Removing staple marks on 1bpp b&w image.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.bmp");
 
    if ((gdpictureImaging.GetBitDepth(imageID) == 1) && gdpictureImaging.IsBitonal(imageID, 0))
    {
        gdpictureImaging.RemoveStapleMark(imageID);
        gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionCCITT4);
    }
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also