OCR Preprocessing API — Convert an Image of Text into Binarized (Light & Dark View)

Cloudmersive
2 min readMay 20, 2022

--

It’s a lot easier to perform an OCR operation when the document in question has a simpler color scheme. After all, we usually don’t need OCR conversions to contain color. With the help of our Binarization OCR Preprocessing API, you can ensure all documents are converted to light & dark view before the subsequent OCR conversion.

To take advantage of this API, all you need to do is follow instructions below to structure your API call with JavaScript. If you’re looking to use a different programming language, check out our Cloudmersive API Console to find code available in a dozen common programming languages.

To get started, let’s install the jQuery library. Just run the below command:

`bower install jquery

Now let’s include a snippet to capture the input image file for this operation:

var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");

After that, it’s time to call the preprocessing function. Include the below code examples, and make sure to supply your Cloudmersive API key where it says to do so:

var settings = {
"url": "https://api.cloudmersive.com/ocr/preprocessing/image/binarize",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

All done. If you don’t currently have a Cloudmersive API key, you can get one easily by registering for a free account on our website (Home — Cloudmersive APIs).

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet