Categories

Image Adaptive Threshold

Apply adaptive threshold operation that calculates threshold for small regions, suitable for varying lighting conditions

Click to upload file or drag and drop file here

Maximum file size: 10MB Supported formats: image/jpeg, image/png, image/webp, image/gif, image/bmp, image/tiff

Size of a pixel neighborhood that is used to calculate a threshold for the pixel (must be odd)

Constant subtracted from the mean or weighted mean. Usually positive.

Adaptive thresholding method to use

Key Facts

Category
Design
Input Types
file, number, select
Output Type
file
Sample Coverage
4
API Ready
Yes

Overview

The Image Adaptive Threshold tool performs local binarization on images, calculating unique thresholds for small pixel neighborhoods to effectively handle uneven lighting and shadows.

When to Use

  • When an image has inconsistent lighting that makes global thresholding ineffective.
  • When you need to extract text or fine details from documents with shadows or gradients.
  • When preparing images for OCR or feature detection where local contrast is more important than overall brightness.

How It Works

  • Upload your image file in a supported format like PNG, JPEG, or TIFF.
  • Set the block size to define the neighborhood area for local threshold calculation.
  • Choose between Gaussian or Mean methods to determine how the threshold is weighted within each block.
  • Apply the constant value to fine-tune the sensitivity of the binarization process.

Use Cases

Binarizing scanned documents with uneven page lighting or shadows.
Isolating objects from backgrounds in images with complex, non-uniform illumination.
Preprocessing images to improve the accuracy of optical character recognition (OCR) software.

Examples

1. Binarizing a Shadowed Document

Archivist
Background
A collection of historical documents features uneven lighting and dark shadows across the pages, making the text difficult to read.
Problem
Global thresholding turns the entire page black or white, losing the text in shadowed areas.
How to Use
Upload the document scan, set the block size to 21, and select the Gaussian method to account for local intensity variations.
Example Config
blockSize: 21, method: 'gaussian', constant: 5
Outcome
The text becomes sharp and legible against a clean white background, regardless of the original lighting inconsistencies.

2. Isolating Features for Computer Vision

Data Scientist
Background
An image of a mechanical part has a strong light source on one side, creating a gradient that hides surface details.
Problem
Standard binarization fails to capture the edges of the part due to the brightness gradient.
How to Use
Upload the image, use a smaller block size of 11 to focus on local contrast, and apply the Mean method.
Example Config
blockSize: 11, method: 'mean', constant: 2
Outcome
The edges of the mechanical part are clearly defined as a binary mask, making them ready for further feature extraction.

Try with Samples

image, png, jpg

Related Hubs

FAQ

What is the difference between Gaussian and Mean methods?

The Mean method calculates the average of the neighborhood, while the Gaussian method uses a weighted sum based on a Gaussian distribution, often resulting in smoother edges.

Why must the block size be an odd number?

An odd block size ensures there is a clear center pixel for the neighborhood calculation, which is required for the mathematical operation.

What does the constant value do?

The constant is subtracted from the calculated mean; increasing it can help remove background noise or faint artifacts from the final binary image.

Which file formats are supported?

The tool supports common image formats including JPEG, PNG, WebP, GIF, BMP, and TIFF.

Can I process multiple images at once?

No, this tool is designed to process one image file at a time.

API Documentation

Request Endpoint

POST /en/api/tools/image-adaptive-threshold

Request Parameters

Parameter Name Type Required Description
imageFile file (Upload required) Yes -
blockSize number Yes Size of a pixel neighborhood that is used to calculate a threshold for the pixel (must be odd)
constant number No Constant subtracted from the mean or weighted mean. Usually positive.
method select Yes Adaptive thresholding method to use

File type parameters need to be uploaded first via POST /upload/image-adaptive-threshold to get filePath, then pass filePath to the corresponding file field.

Response Format

{
  "filePath": "/public/processing/randomid.ext",
  "fileName": "output.ext",
  "contentType": "application/octet-stream",
  "size": 1024,
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
File: File

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-image-adaptive-threshold": {
      "name": "image-adaptive-threshold",
      "description": "Apply adaptive threshold operation that calculates threshold for small regions, suitable for varying lighting conditions",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=image-adaptive-threshold",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

Supports URL file links or Base64 encoding for file parameters.

If you encounter any issues, please contact us at [email protected]