The Min/Max Filter performs morphological operations on images. These are fundamental image processing operations useful for noise removal, edge detection, and mask/matte refinement.
Overview
Morphological operations use a "structuring element" (kernel) that slides across the image. At each position, the operation examines all pixels within the kernel and selects the minimum or maximum value.
Operations
| Operation | Description | Use Case |
|---|---|---|
| Minimum (Erosion) | Selects darkest pixel in kernel. Shrinks bright areas, expands dark areas. | Remove small bright noise, shrink masks |
| Maximum (Dilation) | Selects brightest pixel in kernel. Expands bright areas, shrinks dark areas. | Fill small holes, expand masks |
| Open | Min then Max. Removes small bright spots while preserving overall shape. | Remove salt noise, smooth contours |
| Close | Max then Min. Removes small dark spots while preserving overall shape. | Remove pepper noise, fill small holes |
| Gradient | Max minus Min. Highlights edges/boundaries. | Edge detection, outline extraction |
Settings
Operation
| Setting | Description |
|---|---|
| Operation | The morphological operation to perform |
| Iterations | Number of times to apply the operation (1-10). More = stronger effect. |
Kernel
| Setting | Description |
|---|---|
| Radius X | Horizontal radius of the kernel (1-100 pixels) |
| Radius Y | Vertical radius of the kernel (1-100 pixels) |
| Link radii | When ON, Radius Y follows Radius X for uniform kernel |
| Shape | Shape of the structuring element |
Kernel Shapes
| Shape | Description | Best For |
|---|---|---|
| Box | Square/rectangular kernel | General purpose, fast |
| Ellipse | Circular/elliptical kernel | Isotropic operations, natural look |
| Cross | Plus-shaped kernel (+) | Directional operations |
| Diamond | Diamond-shaped kernel (â—‡) | Compromise between box and ellipse |
Processing (Advanced)
| Setting | Description |
|---|---|
| Channel mode | Per-Channel: process R, G, B independently. Luminance: select whole pixel by brightness. |
| Process channels | Which channels to process (see below) |
Process Channels
| Option | Description |
|---|---|
| RGB | Process color channels only, preserve original alpha |
| RGBA | Process all channels including alpha |
| Alpha Only | Process only the alpha channel, preserve RGB colors |
The Alpha Only option is particularly useful for:
- Refining mattes and masks
- Choking/spreading alpha edges without affecting color
- Cleaning up keyed footage alpha
Keyboard Shortcuts
| Key | Function |
|---|---|
| F1 | Cycle through operations |
| F2 | Cycle through kernel shapes |
| F3 | Toggle channel mode (Per-Channel/Luminance) |
| F4 | Cycle process channels (RGB/RGBA/Alpha) |
| F5 | Toggle link radii |
| R | Reset all settings to defaults |
Reset
Click the Reset all button or press R to restore all settings to their default values:
- Operation: Maximum
- Iterations: 1
- Radius X/Y: 3
- Link radii: On
- Shape: Ellipse
- Channel mode: Per-Channel
- Process channels: RGB
Use Cases
Noise Removal
Salt noise (bright spots):
- Use Open operation (Min then Max)
- Small radius (1-3)
- 1-2 iterations
Pepper noise (dark spots):
- Use Close operation (Max then Min)
- Small radius (1-3)
- 1-2 iterations
Mask/Matte Refinement
Shrink mask (choke):
- Use Minimum operation
- Adjust radius to desired shrink amount
- Use Ellipse shape for smooth edges
Expand mask (spread):
- Use Maximum operation
- Adjust radius to desired expansion
- Use Ellipse shape for smooth edges
Clean up mask edges:
- Use Open then Close (or vice versa)
- Small radius (1-2)
- Removes small artifacts
Edge Detection
- Use Gradient operation
- Adjust radius for edge thickness
- Works like a simple edge detector
Creating Outlines
- Apply Maximum to expand the shape
- Subtract original from expanded version
- Result is an outline of the original shape
Channel Modes
Per-Channel Mode
Processes R, G, B channels independently. Each channel gets its own min/max calculation. This is the standard mode and works well for most cases.
Luminance Mode
Calculates brightness (luminance) for each pixel in the kernel and selects the entire pixel with the minimum/maximum luminance. This preserves color relationships better but may produce different results.
Performance Notes
- Larger radii are slower (O(r²) complexity)
- Box shape is slightly faster than Ellipse
- Multiple iterations are slower than single iteration with larger radius, but may produce different results
- Processing alpha adds minimal overhead
Comparison with Median Filter
| Feature | Min/Max | Median |
|---|---|---|
| Noise removal | Good for impulse noise | Better for mixed noise |
| Edge preservation | Can shift edges | Better edge preservation |
| Speed | Faster | Slower |
| Compound ops | Open/Close/Gradient | N/A |
| Use case | Mask refinement, morphology | General denoising |
Technical Details
The structuring element (kernel) determines which pixels are considered at each position:
Box 3x3: Ellipse 3x3: Cross 3x3: Diamond 3x3:
■■■· ■· · ■· · ■·
â– â– â– â– â– â– â– â– â– â– â– â–
■■■· ■· · ■· · ■·
For non-square kernels (Radius X ≠Radius Y), the shapes scale proportionally.