Back to FabImage Library website

You are here: Start » Function Reference » Image » Image Local Transforms » SmoothImage_Median


Header: FIL.h
Namespace: fil
Module: FoundationLite

Replaces each pixel with the median of pixels within a kernel.

Applications: Edge-preserving noise removal (but slow).


void fil::SmoothImage_Median
	const fil::Image& inImage,
	ftl::Optional<const fil::Region&> inRoi,
	ftl::Optional<const fil::Region&> inSourceRoi,
	fil::SmoothImageMedianKernel::Type inKernel,
	int inRadiusX,
	ftl::Optional<int> inRadiusY,
	fil::Image& outImage


Name Type Range Default Description
Input value inImage const Image& Input image
Input value inRoi Optional<const Region&> NIL Range of outImage pixels being written
Input value inSourceRoi Optional<const Region&> NIL Range of inImage pixels being read
Input value inKernel SmoothImageMedianKernel::Type
Input value inRadiusX int 0 - 1 Nearly half of the kernel's width (2*R+1)
Input value inRadiusY Optional<int> 0 - NIL Nearly half of the kernel's height (2*R+1), or same as inRadiusX
Output value outImage Image& Output image


For input inImage only pixel formats are supported: uint8.

Read more about pixel formats in Image documentation.


  • Define the kernel size by setting the inRadiusX and inRadiusY inputs.
  • For small kernels consider switching to SmoothImage_Median_Mask to achieve higher performance.


SmoothImage_Median performed on a sample image with inRadiusX = 4, inRadiusY = Nil.

Hardware Acceleration

This operation supports automatic parallelization for multicore and multiprocessor systems.


List of possible exceptions:

Error type Description
DomainError Not supported kernel in SmoothImage_Median.
DomainError Not supported pixel format in SmoothImage_Median.
DomainError Region exceeds an input image in SmoothImage_Median.
DomainError Source roi exceeds an input image in SmoothImage_Median.
DomainError Not supported inImage pixel format in SmoothImage_Median. Supported formats: UInt8.