ClearImage .NET API
BorderExtract Method (CiRepair)
Example 





Inlite.ClearImage Namespace > CiRepair Class : BorderExtract Method
Extract document image using borders
Syntax
'Declaration
 
Public Function BorderExtract( _
   ByVal Flags As EBorderExtractFlags, _
   ByVal Algorithm As EBorderExtractAlgorithm _
) As System.Integer
'Usage
 
Dim instance As CiRepair
Dim Flags As EBorderExtractFlags
Dim Algorithm As EBorderExtractAlgorithm
Dim value As System.Integer
 
value = instance.BorderExtract(Flags, Algorithm)
public System.int BorderExtract( 
   EBorderExtractFlags Flags,
   EBorderExtractAlgorithm Algorithm
)
public function BorderExtract( 
    Flags: EBorderExtractFlags;
    Algorithm: EBorderExtractAlgorithm
): System.Integer; 
public function BorderExtract( 
   Flags : EBorderExtractFlags,
   Algorithm : EBorderExtractAlgorithm
) : System.int;
public:
System.int BorderExtract( 
   EBorderExtractFlags Flags,
   EBorderExtractAlgorithm Algorithm
) 

Parameters

Flags
Algorithm
Remarks

Borders are dark areas along the edges of the image.  Borders can be present on one or more sides of the image.  Deskew angle is a dominant angle of the lines between the borders and inner area of the image.


If Flags = ciBexBorder border area pixels are set to white
If Flags = ciBexBorderDeskew border area pixels are set to white and whole image is deskewed.
If Flags = ciBexBorderDeskewCrop border area pixels are set to white and image is deskewed.  Then image is cropped along the lines between former border and inner area.
If Flags = ciBexDeskewCrop image is deskewed, then cropped along the lines between former border and inner area. Remnants might remain on the image.

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