How to C#: Imaging
Using Imaging SDK for C#.NET
Winforms Controls
Image Load
Image Access and Modify
Cleanup Images
Cleanup Images
  |  
Home ›› XImage.Raster ›› C# Raster: Cleanup Images

How to C#: Cleanup Images


Overview for How to Cleanup Images



Related .net document control helps:
asp.net excel document viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications
asp.net azure document viewer: ASP.NET Azure Document Viewer: view, annotate files online using ASP.NET Cloud Service
asp.net pdf file permission: ASP.NET PDF File Permission Control: apply, remove PDF file permission settings in C#
asp.net edit pdf text: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net dnn pdf editor: ASP.NET DNN PDF Editor Control: view, edit PDF files in Dotnetnuke application
asp.net sharepoint pdf editor: ASP.NET SharePoint PDF Editor Control: view, edit, annotate, redact PDF document in SharePoint sites
asp.net webforms pdf editor: ASP.NET WebForms PDF Editor: create, view, edit, annotate, redact PDF file in ASP.NET WebForms application


Overview



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.




Steps to Cleanup Image



Load an image with RasterImage object.


Create an image processor with ImageProcess object.


Call the responding method of ImageProcess object to complete the task flopping image.


Save the modified image to an image file on the disk.


In order to acheive the work, please refer to the following steps.




Install XImage.Raster in C# Project



Add necessary references to your C#.NET project. Right-click the project and select "Add Reference..." to locate and add the following DLLs as project references;


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.XImage.Raster;


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




C# Demo Code to Cleanup Images



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");