ClearImage .NET API
AdvancedBinarize Method (CiRepair)
Example 





Inlite.ClearImage Namespace > CiRepair Class : AdvancedBinarize Method
0                     converts to 300 DPI
-1                    preserves current DPI
100 to 600      converts to specified DPI
Set to 0.0
Set to 0.0
Optimized conversion of color and grayscale image to a bi-tonal image.
Syntax
'Declaration
 
Public Function AdvancedBinarize( _
   ByVal targetDpi As System.Integer, _
   ByVal reserved1 As System.Double, _
   ByVal reserved2 As System.Double _
) As System.Integer
'Usage
 
Dim instance As CiRepair
Dim targetDpi As System.Integer
Dim reserved1 As System.Double
Dim reserved2 As System.Double
Dim value As System.Integer
 
value = instance.AdvancedBinarize(targetDpi, reserved1, reserved2)
public System.int AdvancedBinarize( 
   System.int targetDpi,
   System.double reserved1,
   System.double reserved2
)
public function AdvancedBinarize( 
    targetDpi: System.Integer;
    reserved1: System.Double;
    reserved2: System.Double
): System.Integer; 
public function AdvancedBinarize( 
   targetDpi : System.int,
   reserved1 : System.double,
   reserved2 : System.double
) : System.int;
public:
System.int AdvancedBinarize( 
   System.int targetDpi,
   System.double reserved1,
   System.double reserved2
) 

Parameters

targetDpi
0                     converts to 300 DPI
-1                    preserves current DPI
100 to 600      converts to specified DPI
reserved1
Set to 0.0
reserved2
Set to 0.0
Remarks
This method utilizes multiple image analysis techniques.  It is significantly slower than CiImage.ToBitonal method and recommended when original image has a complex background.
Example
void RepairMethods(string imageFile, string imageFileOut)
{
    // Open image file
    CiServer ci = Inlite.ClearImageNet.Server.GetThreadServer();
    CiRepair Repair = ci.CreateRepair();
    Repair.Image.Open(imageFile, 1);
    // Do Processing
    Repair.AutoDeskew();             // Use AutoDeskew before AutoRotate
    Repair.AutoRotate();
    // Repair.AutoCrop(10, 10, 10, 10); // Do not use AutoCrop with AutoRegister or BorderExtract
    // Repair.AutoRegister(100, 100);   // Do not use AutoRegister with AutoCrop or BorderExtract
    Repair.AdvancedBinarize(0, 0, 0);
    Repair.BorderExtract(EBorderExtractFlags.ciBexBorderDeskewCrop, EBorderExtractAlgorithm.ciBeaCleaner);
    Repair.RemovePunchHoles();
    Repair.SmoothCharacters(ESmoothType.ciSmoothDarkenEdges);
    Repair.CleanNoise(3);            // Use CleanNoiseExt to remove white noise
    // Repair.CleanNoiseExt(ECleanNoiseFlags.ciCnxBlackNoise | ECleanNoiseFlags.ciCnxWhiteNoise, 3, 3, 10, 0);
    Repair.pLineCurvature = ELineCurvature.ciCurvLow;
    Repair.pMaxLineAngle = 5;
    Repair.pMaxLineGap = 5;
    Repair.pMinLineLength = 200;
    Repair.DeleteLines(ELineDirection.ciLineVertAndHorz, true);
    Repair.Image.SaveAs(imageFileOut, EFileFormat.ciEXT);
}
Sub RepairMethods(imageFile As String, imageFileOut As String)
    ' Open image file
    Dim ci As CiServer = Inlite.ClearImageNet.Server.GetThreadServer()
    Dim Repair As CiRepair = ci.CreateRepair()
    Repair.Image.Open(imageFile, 1)
    ' Do Processing
    Repair.AutoDeskew()             ' Use AutoDeskew before AutoRotate
    Repair.AutoRotate()
    ' Repair.AutoCrop(10, 10, 10, 10) ' Do not use AutoCrop with AutoRegister or BorderExtract
    ' Repair.AutoRegister(100, 100)   ' Do not use AutoRegister with AutoCrop or BorderExtract
    Repair.AdvancedBinarize(0, 0, 0)
    Repair.BorderExtract(EBorderExtractFlags.ciBexBorderDeskewCrop, EBorderExtractAlgorithm.ciBeaCleaner)
    Repair.RemovePunchHoles()
    Repair.SmoothCharacters(ESmoothType.ciSmoothDarkenEdges)
    Repair.CleanNoise(3)            ' Use CleanNoiseExt to remove white noise
    ' Repair.CleanNoiseExt(ECleanNoiseFlags.ciCnxBlackNoise + ECleanNoiseFlags.ciCnxWhiteNoise, 3, 3, 10, 0)
    Repair.pLineCurvature = ELineCurvature.ciCurvLow
    Repair.pMaxLineAngle = 5
    Repair.pMaxLineGap = 5
    Repair.pMinLineLength = 200
    Repair.DeleteLines(ELineDirection.ciLineVertAndHorz, True)
    Repair.Image.SaveAs(imageFileOut, EFileFormat.ciEXT)
End Sub
See Also

Reference

CiRepair Class
CiRepair Members