imfilter.q

This file contains very useful functions for linear image filtering, as well as routines to check whether a given filter mask is separable.

Summary
imfilter.qThis file contains very useful functions for linear image filtering, as well as routines to check whether a given filter mask is separable.
Functions
is_filtermask_separableChecks whether a given kernel is separable, and if so, returns the separable components
imfilter_separableApplies a 2D separable impulse response (FIR) filter to an image
imfilterApplies a 2D finite impulse response (FIR) filter to an image.
hor_sobelExtracts the horizontal edges of an image using a horizontal sobel filter
ver_sobelExtracts the vertical edges of an image using a vertical sobel filter
sobelFind the edge magnitude using the Sobel filters.
hor_scharrExtracts the horizontal edges of an image using a horizontal scharr filter
ver_scharrExtracts the vertical edges of an image using a vertical scharr filter
scharrFind the edge magnitude using the scharr filters.
hor_prewithExtracts the horizontal edges of an image using a horizontal prewith filter
ver_prewithExtracts the vertical edges of an image using a vertical prewith filter
prewithFind the edge magnitude using the prewith filters.
gaussfilterApplies a Gaussian filter to the image

Functions

is_filtermask_separable

Checks whether a given kernel is separable, and if so, returns the separable components

function [result, mask_hor, mask_ver] = is_filtermask_separable(kernel)

Parameters

kernelthe filter mask to check
resulta boolean value indicating whether the mask is separable
mask_horthe horizontal filter mask (only when the filter is separable)
mask_verthe vertical filter mask (only when the filter is separable)

See also

imfilter

imfilter_separable

Applies a 2D separable impulse response (FIR) filter to an image

function y = imfilter_separable(x, vmask, hmask, center = 0, boundary_mode = "zero")

Parameters

xthe input image
vmaskthe vertical filter mask
hmaskthe horizontal filter mask
centera 2D vector containing the center of the filter mask
boundary_modethe boundary extension mode to be used for filtering
  • ”zero”: the image is extended with zeros outside its boundaries
  • ”mirror”: values outside the image are obtained by mirroring
  • ”circular”: values outside the image are obtained by circularly shifting (resulting in a periodic extension)

Notes

  • The actual 2D mask can be calculated by the formula:
mask = transpose(vmask) * hmask.
  • The function skip the separability check, and may slightly be faster than imfilter for separable filters

See also

periodize, mirror_ext, is_filtermask_separable, imfilter

imfilter

Applies a 2D finite impulse response (FIR) filter to an image.

function y = imfilter(x, mask, center = 0, boundary_mode = "zero")

Parameters

xthe input image
maskthe filter mask (i.e. filter impulse response)
centera 2D vector containing the center of the filter mask
boundary_modethe boundary extension mode to be used for filtering
  • ”zero”: the image is extended with zeros outside its boundaries
  • ”mirror”: values outside the image are obtained by mirroring
  • ”circular”: values outside the image are obtained by circularly shifting (resulting in a periodic extension)

Notes

The function automatically checks whether the 2D filter mask is separable.  If this is the case, a more efficient separable implementation is used.

See also

periodize, mirror_ext, is_filtermask_separable, imfilter_separable

hor_sobel

Extracts the horizontal edges of an image using a horizontal sobel filter

function y = hor_sobel(x)

ver_sobel

Extracts the vertical edges of an image using a vertical sobel filter

function y = ver_sobel(x)

sobel

Find the edge magnitude using the Sobel filters.

function y = sobel(x)

hor_scharr

Extracts the horizontal edges of an image using a horizontal scharr filter

function y = hor_scharr(x)

ver_scharr

Extracts the vertical edges of an image using a vertical scharr filter

function y = ver_scharr(x)

scharr

Find the edge magnitude using the scharr filters.

function y = scharr(x)

hor_prewith

Extracts the horizontal edges of an image using a horizontal prewith filter

function y = hor_prewith(x)

ver_prewith

Extracts the vertical edges of an image using a vertical prewith filter

function y = ver_prewith(x)

prewith

Find the edge magnitude using the prewith filters.

function y = prewith(x)

gaussfilter

Applies a Gaussian filter to the image

function y=gaussfilter(x,sigma,n=7)

Parameters

xthe input image
sigmathe sigma parameter of the gaussian filter
nthe number of filter taps (divided by 2).  The filter support is -n..n.
Applies a 2D finite impulse response (FIR) filter to an image.
Computes x modulo a: but in a sense that the result is in the range [0, a[, even for negative numbers
Performs mirror reflection of the input coordinate
Checks whether a given kernel is separable, and if so, returns the separable components
Applies a 2D separable impulse response (FIR) filter to an image
Close