Please bookmark this page to avoid losing your image tool!

Image Digitizer From Scan

(Free & Supports Bulk Upload)

Drag & drop your images here or

The result will appear here...
You can edit the below JavaScript code to customize the image tool.
/**
 * Processes an image to "digitize" it, which is interpreted as converting
 * it into a high-contrast, black-and-white image, similar to a scanned document.
 * This is achieved by applying a threshold to the grayscale value of each pixel.
 *
 * @param {Image} originalImg The original Image object to be processed.
 * @param {number} [threshold=128] A value between 0 and 255. Pixels with a brightness
 * below this value will become black, and those above will become white.
 * @returns {HTMLCanvasElement} A new canvas element with the digitized image.
 */
function processImage(originalImg, threshold = 128) {
    // Create a new canvas element
    const canvas = document.createElement('canvas');
    const ctx = canvas.getContext('2d');

    // Set canvas dimensions to match the original image
    canvas.width = originalImg.naturalWidth;
    canvas.height = originalImg.naturalHeight;

    // Draw the original image onto the canvas
    ctx.drawImage(originalImg, 0, 0, canvas.width, canvas.height);

    // Get the image data from the canvas
    const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    const data = imageData.data;

    // Ensure the threshold is a valid number between 0 and 255
    const cleanThreshold = Math.max(0, Math.min(255, Number(threshold) || 128));

    // Iterate over each pixel in the image data array
    // The data array is a flat array of [R, G, B, A, R, G, B, A, ...]
    for (let i = 0; i < data.length; i += 4) {
        const r = data[i];
        const g = data[i + 1];
        const b = data[i + 2];

        // Use the luminosity formula to convert RGB to a single grayscale value
        const grayscale = 0.299 * r + 0.587 * g + 0.114 * b;

        // Determine if the pixel should be black or white based on the threshold
        const colorValue = grayscale < cleanThreshold ? 0 : 255;

        // Set the new color for the pixel (black or white)
        data[i] = colorValue; // Red
        data[i + 1] = colorValue; // Green
        data[i + 2] = colorValue; // Blue
        // Alpha channel (data[i + 3]) is left untouched
    }

    // Put the modified image data back onto the canvas
    ctx.putImageData(imageData, 0, 0);

    // Return the canvas element containing the digitized image
    return canvas;
}

Free Image Tool Creator

Can't find the image tool you're looking for?
Create one based on your own needs now!

Description

Image Digitizer From Scan is a tool that processes images to convert them into high-contrast, black-and-white representations, resembling scanned documents. By applying a threshold to the grayscale values of the pixels, this tool transforms images into a simplified, digitized format. This functionality is particularly useful for converting photos of printed documents, sketches, or other graphical content into clearer formats suitable for digital archiving, sharing, or further editing.

Leave a Reply

Your email address will not be published. Required fields are marked *

Other Image Tools:

Image Design for 10×4 Meter Landscape LED Screen with Running Video

Photo Custom Text Editor for Identification Cards

Image Outline Detection and Marking Tool

Image Diagonal Golden Ratio Overlay Tool

Image Line Drawer and Eraser

Image To Binary Converter For Optimized Storage

Image Japanese Anime Cell Shading Tool

Image Japanese Anime Cel Shading Renderer for Military Vehicles

Image Anime Cel Shade Effect Generator

Image Liquid Metallic Chrome Material Top View

Image Generator for Rainbow Six Siege Logo with Rainbow Fill

Image Transparency Adjuster for Clothing

Photo VHS Found Footage Analog Effect Tool

Image Old Fashioned Wanted Poster Creator

Image Toxic Waste Identifier

Image Realism Enhancer

Image Bulk Date and Location Stamp Adder Without Background Color

Image Time Stamp Removal Tool

Image Bulk Date and Text Stamp Adder

Image Bulk Date and Location Stamp Adder

Image Date and Location Stamp Adder

Image Date and Zone Stamping Tool

Image Bulk Date and Location Stamper

Image Bulk Date and Coordinate Stamper

Photo Artificial Metadata Generator

Photo Artificial Pattern Generator for Deepfake Bypass

Image Ultra Realistic Skin Texture Pore Emulation Tool

Image Chaotic Noise and Blur Generator for Deepfake Detection Evasion

Image Deep Effects Modification Tool

Image Portrait to Classic Hollywood Cinematic Still Enhancer

Image Chaotic Deep Modifications Editor

Image Chaotic Interleaving Modifier

Image Random Effects Generator with Low Intensity

Image Random Effects Generator

Image Chaotic Noise and Mosaic Effect Maker

Image Chaotic Noise Generator for Deepfake Detection Evasion

See All →