In This Topic
Programming / Document Cleanup / Connected characters and oversampled characters

Connected characters and oversampled characters

In This Topic

Sometimes characters in documents appear thick and their features unclear, like if there was too much ink while printing them. This is usually the result of repeated scanning and printing of the document, especially using the low setting such as DPI. Erosion can help fix this issue.

Before / After

Here is the code example how it works.

Copy Code
'We assume that GdPicture has been correctly installed and unlocked.
Dim oGdPictureImaging As New GdPictureImaging()
'Loading the image from a file.
Dim imageId As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("input.tif")
'Checking if the image resource has been loaded correctly.
If oGdPictureImaging.GetStat() <> GdPictureStatus.OK Then
    MessageBox.Show("The image can't be loaded. Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
    'Now you can erode the black content of your image.
    Dim status As GdPictureStatus = oGdPictureImaging.FxBitonalErode8(imageId)
    If status <> GdPictureStatus.OK Then
        MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        'After you are done with your processing, you can save the image.
        status = oGdPictureImaging.SaveAsTIFF(imageId, "Eroded_Image.tif", TiffCompression.TiffCompressionAUTO)
        If status <> GdPictureStatus.OK Then
            MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
    End If
    oGdPictureImaging.ReleaseGdPictureImage(imageId)
End If
oGdPictureImaging.Dispose()
Copy Code
//We assume that GdPicture has been correctly installed and unlocked.
GdPictureImaging oGdPictureImaging = new GdPictureImaging();
//Loading the image from a file.
int imageId = oGdPictureImaging.CreateGdPictureImageFromFile("input.tif");
//Checking if the image resource has been loaded correctly.
if (oGdPictureImaging.GetStat() != GdPictureStatus.OK)
{
    MessageBox.Show("The image can't be loaded. Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
    //Now you can erode the black content of your image.
    GdPictureStatus status = oGdPictureImaging.FxBitonalErode8(imageId);
    if (status != GdPictureStatus.OK)
    {
        MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
    else
    {
        //After you are done with your processing, you can save the image.
        status = oGdPictureImaging.SaveAsTIFF(imageId, "Eroded_Image.tif", TiffCompression.TiffCompressionAUTO);
        if (status != GdPictureStatus.OK)
        {
            MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "Document Cleanup Example", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }
    oGdPictureImaging.ReleaseGdPictureImage(imageId);
}
oGdPictureImaging.Dispose();