ConvertTo1BppAT(Int32,Int32) Method
In This Topic
Converts a GdPicture image to a 1-bit (black and white) bitmap using a variant of the Otsu adaptive thresholding method. This method is particularly efficient on documents with contrasted foreground and background.
Syntax
Parameters
- ImageID
- GdPicture image identifier.
- Threshold
- Thresholding for determining the foreground. Must be a value between 0 and 100. Suggested value is 50. Higher is the Thresold value darker should be the resulting image.
Return Value
A member of the GdPictureStatus enumeration.
Example
Converting the image to black and white using a variant of the Otsu adaptive thresholding methods.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
//Convert to black and white.
gdpictureImaging.ConvertTo1BppAT(imageID, 45);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
Example
Converting the image to black and white using a variant of the Otsu adaptive thresholding methods.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
// LoadInMemory parameter is set to true in order to be able to update the input file.
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("image.tif", true);
//Convert to black and white.
gdpictureImaging.ConvertTo1BppAT(imageID, 45);
gdpictureImaging.SaveAsTIFF(imageID, "image.tif", TiffCompression.TiffCompressionAUTO);
gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also