Categories

Image Morphological Closing

Apply morphological closing operation (dilation followed by erosion) to fill small holes and connect nearby objects

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

Best results with binary (black and white) images or images with holes to fill

Number of closing operations to apply. More iterations = stronger hole filling

Size of the morphological kernel to use

Key Facts

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

Overview

The Image Morphological Closing tool performs a sequence of dilation followed by erosion to clean up binary images. This process effectively fills small holes, gaps, and noise within shapes while connecting nearby objects, making it an essential utility for image preprocessing and computer vision tasks.

When to Use

  • When you need to remove small black noise or holes from white objects in a binary image.
  • When you want to bridge small gaps between fragmented parts of an object to create a solid shape.
  • When preparing images for contour detection or segmentation where object continuity is required.

How It Works

  • Upload your binary image file (JPEG, PNG, WEBP, etc.) to the tool.
  • Adjust the number of iterations to control the intensity of the hole-filling effect.
  • Select the kernel size (Standard 3x3 or Large 5x5) to define the scope of the morphological operation.
  • Process the image to download the cleaned, closed version.

Use Cases

Cleaning up scanned documents or text to ensure characters are solid and readable.
Refining masks in image segmentation workflows to remove internal noise.
Connecting broken lines or fragmented shapes in technical drawings or schematics.

Examples

1. Restoring Fragmented Text

Data Entry Specialist
Background
A batch of scanned receipts contains text with broken characters due to low-quality printing.
Problem
The OCR software fails to recognize characters because of small gaps and holes within the letters.
How to Use
Upload the scanned image and apply the closing operation with 1 iteration and the standard 3x3 kernel.
Example Config
iterations: 1, kernelType: 'default'
Outcome
The small gaps in the characters are filled, resulting in solid, legible text that the OCR software can process accurately.

2. Cleaning Binary Segmentation Masks

Computer Vision Researcher
Background
A machine learning model generated a segmentation mask for an object, but the mask contains internal noise and small holes.
Problem
The mask is not a solid shape, which interferes with downstream object measurement tasks.
How to Use
Upload the binary mask and use the large 5x5 kernel with 2 iterations to ensure all internal holes are filled.
Example Config
iterations: 2, kernelType: 'large'
Outcome
The mask becomes a solid, continuous shape with all internal noise removed, ready for precise area calculation.

Try with Samples

image, png, jpg

Related Hubs

FAQ

What is morphological closing?

It is a mathematical morphology operation that performs dilation followed by erosion, which helps to close small gaps and fill holes in foreground objects.

What type of images work best?

Binary images (black and white) provide the most predictable results, as the operation is designed to distinguish between foreground and background pixels.

How do iterations affect the output?

Increasing the number of iterations makes the closing effect stronger, filling larger holes and connecting more distant objects.

What is the difference between kernel sizes?

The Standard 3x3 kernel provides subtle closing, while the Large 5x5 kernel covers a wider area, making it more effective for filling larger gaps.

Will this tool change my image resolution?

No, the tool modifies the pixel values based on morphological rules but maintains the original dimensions of your input image.

API Documentation

Request Endpoint

POST /en/api/tools/image-close

Request Parameters

Parameter Name Type Required Description
imageFile file (Upload required) Yes Best results with binary (black and white) images or images with holes to fill
iterations number No Number of closing operations to apply. More iterations = stronger hole filling
kernelType select No Size of the morphological kernel to use

File type parameters need to be uploaded first via POST /upload/image-close 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-close": {
      "name": "image-close",
      "description": "Apply morphological closing operation (dilation followed by erosion) to fill small holes and connect nearby objects",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=image-close",
      "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]