By using the XImage.Raster SDK, you can cleanup image by assigning to the processor. The related propertied and methods are as follows.
- Binarize It may be useful to convert an image to 1bpp for facilitate cleanup image or image recognition. By setting the BinarizeThreshold property whose value range is 0 to 255, it will permanently modify the image to 1bpp grayscale image of the same dimensions. While, the BinarizeLceFactor property will control the image's contrast.
- Deskew Removes skew from the image. Skew is an artifact that occurs in scanned images because of the camera being misaligned, imperfections in the scanning or surface, or simply because the paper was not placed completely flat when scanned, adjust the rotation of the image, usually pass 0.4 to the DeskewImage method will get a best result. Rotation angle can be obtained from the RotationAngle property.
- Shear Unlike the Deskew method to adjust the rotation of the body of the image, the Shear method can adjust the text body of the image.
- Removespecks Reduce speckle noise
- Detect Blank Pages To identify blank page through the property BlankPageDetected, if there is a blank page, value true will be returned, otherwise value false will be returned.
- Delete Blank Pages Set property BlankPageDelete to true , blank pages in the document will be deleted.
- Remove Edges or Borders Automatically remove the borders of an image.
Sample Code (modify BinarizeThreshold):
RasterImage img = new RasterImage(@"C:\input.png");
ImageProcess process = new ImageProcess(img);
//Convert 24bpp image input.png to 1bpp, the pixel value below 150 will be set to 0,and above 150 will be set to 1.
process.BinarizeThreshold = 150;
img.Save(@"C:\output.png");
Sample Code (Deskew Image):
RasterImage img = new RasterImage(@"C:\input.png");
ImageProcess process = new ImageProcess(img);
//Deskew image, adjust the rotation angle of the image. Usually pass 0.4 to this method will get a best result.
process.DeskewImage(0.4);
img.Save(@"C:\output.png")
Sample Code (Shear Image):
RasterImage img = new RasterImage(@"F:\input.tif");
ImageProcess process = new ImageProcess(img);
//Shear image, set the x shear angle to 20, and y shear angle to 30.
process.ShearImage(20, 30);
//only shear the second page of the input tif.
process.ShearImage(20, 30, 1);
img.Save(@"C:\output.tif");
Sample Code (detect blank page):
RasterImage img = new RasterImage(@"F:\input.tif");
ImageProcess process = new ImageProcess(img);
//If there is a blank page in the input.tif the value true will be returned , otherwise will return false.
bool haveBlankPages = process.BlankPageDetected;
Sample Code (delete blank page):
RasterImage img = new RasterImage(@"C:\input.tif");
ImageProcess process = new ImageProcess(img);
//If there are blank pages in the input.tif, they will be removed form the input.tif.
process.BlankPageDelete = true;
img.Save(@"C:\output.tif");