GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / ConvertTo1BppSauvola Method / ConvertTo1BppSauvola(Int32,Single,Int32,Int32) Method
GdPicture image identifier.
Factor of thresholding reduction. Must be a balue in tha range ]0 ; 1. Suggested value is 0.35. Higher is the factor value lighter should be the resulting image.
This method segments the image in tiles and tries to adjust the contrast in each tiles. If the contrast in a tile is smaller than ContrastMinDif, it uses the minimum and maximum pixel values from neighbor tiles. The value must be in the range [0 - 255] and the suggested one is 50.
The half-width of the kernel used to smooth the minimum and maximum values of each tiles, in the range [0 (no smoothing) - 5]. Suggested value is 2, higer value should help to remove background parasites on poorly contrasted images.
Example





In This Topic
ConvertTo1BppSauvola(Int32,Single,Int32,Int32) Method
In This Topic
Converts a GdPicture image to a 1-bit (black and white) bitmap using the Sauvola local adaptive thresholding method and contrast normalization. This method is particularly efficient on documents with poor contrast.
Syntax
'Declaration
 
Public Overloads Function ConvertTo1BppSauvola( _
   ByVal ImageID As Integer, _
   ByVal Factor As Single, _
   ByVal ContrastMinDif As Integer, _
   ByVal SmoothKernel As Integer _
) As GdPictureStatus
public GdPictureStatus ConvertTo1BppSauvola( 
   int ImageID,
   float Factor,
   int ContrastMinDif,
   int SmoothKernel
)
public function ConvertTo1BppSauvola( 
    ImageID: Integer;
    Factor: Single;
    ContrastMinDif: Integer;
    SmoothKernel: Integer
): GdPictureStatus; 
public function ConvertTo1BppSauvola( 
   ImageID : int,
   Factor : float,
   ContrastMinDif : int,
   SmoothKernel : int
) : GdPictureStatus;
public: GdPictureStatus ConvertTo1BppSauvola( 
   int ImageID,
   float Factor,
   int ContrastMinDif,
   int SmoothKernel
) 
public:
GdPictureStatus ConvertTo1BppSauvola( 
   int ImageID,
   float Factor,
   int ContrastMinDif,
   int SmoothKernel
) 

Parameters

ImageID
GdPicture image identifier.
Factor
Factor of thresholding reduction. Must be a balue in tha range ]0 ; 1. Suggested value is 0.35. Higher is the factor value lighter should be the resulting image.
ContrastMinDif
This method segments the image in tiles and tries to adjust the contrast in each tiles. If the contrast in a tile is smaller than ContrastMinDif, it uses the minimum and maximum pixel values from neighbor tiles. The value must be in the range [0 - 255] and the suggested one is 50.
SmoothKernel
The half-width of the kernel used to smooth the minimum and maximum values of each tiles, in the range [0 (no smoothing) - 5]. Suggested value is 2, higer value should help to remove background parasites on poorly contrasted images.

Return Value

A member of the GdPictureStatus enumeration.
Remarks

This method requires the Image Documents component to run.

Example
Converts selected image to a 1-bit BW indexed color image, and saves result into a TIF file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    // Open an image file. An empty string allows the control to prompt for selecting a file.
    int imageID = gdpictureImaging.CreateGdPictureImageFromFile("");
 
    gdpictureImaging.ConvertTo1BppSauvola(imageID, 0.35f, 50, 2);
    gdpictureImaging.SaveAsTIFF(imageID, "output.tif", TiffCompression.TiffCompressionAUTO);
 
    // Release used resources.
    gdpictureImaging.ReleaseGdPictureImage(imageID);
}
See Also