Skip to main content

Filters and Image Processing | Web Document Scanner

Image Filters

You can apply a series of filter, cropping an resizing operations to images.
The scanbotSDK object contains the following function:

async createImageProcessor(imageBuffer: ArrayBuffer): Promise<ImageProcessor>

You can simply pass the image object from your DocumentDetectionResult to the filter function, to obtain an ImageProcessor that has your image loaded in its internal state. ArrayBuffer in this context is equal to the Uint8Array image in your DocumentDetectionResult object. It can also be the contents of a JPEG or PNG file.

Then, you can apply a series of operations to the image, and finally obtain the result. See the API reference for details on the supported operations:

Available Filters

There are a number of filters available that can help you improve your scan results. Most of the filters can also be configured. See the API reference for a list of available filters and their parameters.

Example

const imageBuffer: ArrayBuffer = ... // your image data
const imageProcessor = await scanbotSDK.createImageProcessor(imageBuffer);
await imageProcessor.crop([{x: 0.1, y: 0.1}, {x: 0.9, y: 0.1}, {x: 0.9, y: 0.9}, {x: 0.1, y: 0.9}]);
await imageProcessor.rotate("ROTATION_90_CLOCKWISE");

// Let us generate two versions of the image, using different binarization filters
const imageProcessorVersionA = imageProcessor;
const imageProcessorVersionB = imageProcessor.copy(); // Using copy is faster than creating a new image processor

await imageProcessorVersionA.applyFilter(new scanbotSDK.imageFilter.ScanbotBinarizationFilter());
const imageVersionA = await imageProcessorVersionA.processedImage();
await imageProcessorVersionA.release();

const filter = new scanbotSDK.imageFilter.CustomBinarizationFilter();
filter.preset = "PRESET_4";
filter.denoise = 0.2;
await imageProcessorVersionB.applyFilter(filter);
const imageVersionB = await imageProcessorVersionB.processedImage();
await imageProcessorVersionB.release();

// Now you can let the user choose the better version of the image

Want to scan longer than one minute?

Generate your free "no-strings-attached" Trial License and properly test the Scanbot SDK.

Get your free Trial License

What do you think of this documentation?


On this page

Scroll to top