ClearImage .NET API
ClearBackground Method (CiRepair)
Example 





Inlite.ClearImage Namespace > CiRepair Class : ClearBackground Method
Background threshold level (range 0-100)
Set background to white
Syntax
'Declaration
 
Public Function ClearBackground( _
   ByVal ThrLevel As System.Double _
) As System.Integer
'Usage
 
Dim instance As CiRepair
Dim ThrLevel As System.Double
Dim value As System.Integer
 
value = instance.ClearBackground(ThrLevel)
public System.int ClearBackground( 
   System.double ThrLevel
)
public function ClearBackground( 
    ThrLevel: System.Double
): System.Integer; 
public function ClearBackground( 
   ThrLevel : System.double
) : System.int;
public:
System.int ClearBackground( 
   System.double ThrLevel
) 

Parameters

ThrLevel
Background threshold level (range 0-100)
Remarks

Scanning of documents with white background as grayscale and color typically produces off-white background on the scanned image.  This method sets all pixels brighter than the specified threshold to pure white to bring visually quality closer to the original document.

Recommended ThrLevel is 30.   Higher number causes more pixels to be set to white.

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