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

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",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (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).



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


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