# Image Morphological Closing

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

> Canonical page: https://elysiatools.com/en/tools/image-close

- **Category:** Design

- **Keywords:** image, closing, morphology, dilation, erosion, holes, fill, binary

## 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.

## Inputs

- **Image File** (file): Best results with binary (black and white) images or images with holes to fill
- **Iterations** (number): Number of closing operations to apply. More iterations = stronger hole filling
- **Kernel Size** (select): Size of the morphological kernel to use

## 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.

## Frequently asked questions

### 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.

## Related tools

- [Image Binary Converter](https://elysiatools.com/en/tools/image-binary): Convert images to binary (black and white) with customizable threshold and options
- [Image Boolean AND](https://elysiatools.com/en/tools/image-boolean-and): Apply bitwise AND operation between two images to create intersection mask
- [Image Boolean NOT](https://elysiatools.com/en/tools/image-boolean-not): Apply bitwise NOT operation to invert all pixel values in an image
- [Image Boolean OR](https://elysiatools.com/en/tools/image-boolean-or): Apply bitwise OR operation between two images to create union mask
- [Image Boolean XOR](https://elysiatools.com/en/tools/image-boolean-xor): Apply bitwise XOR operation between two images to create difference mask
- [Image Dilate](https://elysiatools.com/en/tools/image-dilate): Apply dilation morphological operation to expand foreground objects in binary images
- [Image Edge Detection Kernel](https://elysiatools.com/en/tools/image-edge-detect-kernel): Apply edge detection convolution kernels to identify and highlight edges and contours in images
- [Image Erode](https://elysiatools.com/en/tools/image-erode): Apply erosion morphological operation to shrink foreground objects in binary images

## Samples

- [Web Image Processing Python Samples](https://elysiatools.com/en/samples/web-image-processing-python): Web Python image processing examples using PIL/Pillow including reading, saving, resizing, and format conversion
- [Web Image Processing TypeScript Samples](https://elysiatools.com/en/samples/web-image-processing-typescript): Web TypeScript image processing examples including image read/save, scaling, and format conversion
- [Android Image Processing Java Samples](https://elysiatools.com/en/samples/android-image-processing-java): Android Java image processing examples including reading/saving images, scaling, and format conversion
- [Android Image Processing Kotlin Samples](https://elysiatools.com/en/samples/android-image-processing-kotlin): Android Kotlin image processing examples including reading/saving images, scaling, and format conversion

## Related content

- [Binary Image Thresholding, Morphology, and Mask Tools](https://elysiatools.com/en/hubs/binary-image-thresholding-and-morphology): Turn images into binary masks, compare threshold methods, repair foreground shapes, and combine masks with morphological and Boolean operations.
