![]() |
Home · Pages · Index · Overviews |
Filters Module ReferenceEfficient routines for filtering images with common filters. More... #include <filters.h> Routines
Detailed DescriptionMany common filters such as applying a Gaussian or min/max filter can be performed very efficiently when one considers applying the filter to an entire array, as opposed to individual pixel locations (see the Convolver class). This module contains efficient routines for computing common preprocessing filters on an entire array. Please note carefully that the routines work directly on the array in question performing their operations in-place, and perforce saving intermediate results in the type and precision of the array. This implies that for integer type arrays that involve intermediate steps, say performing separable convolution along each dimension, that rounding occurs at each stage and this can accumulate leading to somewhat perturbed over those values that might normally be expected. For example, an average operation on an n-dimensional, integer array could be off by as much as n in the worst case. If this behavior is undesirable then you should either convert the image to a floating-point type before operating upon it, or if space is at a premium, then you can use a less efficient Convolver to perform the operations. Average_Array replaces each pixel with the average of the pixels in a window of a specified radius about the pixel in total time O(vn) where v is the size of the array and n is its dimensionality. Sum_Array replaces each pixel with the sum of the pixels in a window of a specified radius about the pixel in total time O(vn) where v is the size of the array and n is its dimensionality. Variance_Array replaces each pixel with the variance of the pixels in a window of a specified radius about the pixel in total time O(vn) and requires a single copy of the array temporarily during its operation. Min_Array and Max_Array replace each pixel with the min/max of the pixels in a window of a specified radius about the pixel in total time O(vn). One should note that the operators are equivalent to the dilate and erode morphological operators on grey-scale images. LOG_Array and ALOG_Array apply a Laplacian of Gaussian (LOG) filter to pixels where a single standard deviation and support are applied in every dimension by LOG_Array and inidividual standard deviations and supports are supplied to ALOG_Array. The filtration takes place in O(vn2r) time where r is the radius or support of the filter, and requires 2 extra copies of the array during its operation. (See also LOG_Filter and ALOG_Filter). DOG_Array and ADOG_Array apply a difference of Gaussian (DOG) filter to pixels where a single standard deviation and support are applied in every dimension by DOG_Array and inidividual standard deviations and supports are supplied to ADOG_Array. The filtration takes place in O(vnr) time where r is the radius or support of the filter, and requies an extra copy of the array during its operation. (See also DOG_Filter and ADOG_Filter). DOB_Array and ADOB_Array apply a difference of boxes (DOB) filter to pixels where a single pair of radii are applied in every dimension by DOB_Array and inidividual radii pairs are supplied to ADOB_Array. The filtration takes place in O(vn) time. (See also DOB_Filter and ADOB_Filter). Median_Array replaces each pixel with the median value of the pixels in a window of a specified radius about the pixel in total time O(vr n). More generally, one can request the kth largest element with Order_Array. For separable filters, such as a Gaussian, the routine Filter_Array applies a given 1-dimensional filter to each dimension in turn, and Filter_Array_List applies a distinct 1-dimensional filter to each dimension in turn. Even greater granularity is possible with Filter_Dimension that applies a given 1-dimensional filter along a particular dimension of an array. For example: Array *AGaussian_Array(Array *image, double *sigma, int *radii) { int i; for (i = 0; i < n; i++) Filter_Array_Dimension(image,Gaussian_Filter(sigma[i],radii[i]),i); return (image); } One can also apply an average filter, a square filter, or a min/max filter in just a given dimension with the routines Average_Dimension, Sum_Dimension, Square_Dimension, Min_Dimension, and Max_Dimension. Routine Documentation
Applies the 1-dimensional filter filter to every pixel in array image along dimension dim. The filtration occurs in-place, i.e. every pixel is replace with the convolution of the filter with the array, where the filter's mid pixel is centered on the pixel in question. The complexity is O(vr) where v is the size of image and r is the size of filter.
Applies a 1-dimensional average filter of radius radius to every pixel of the array image along the dimension dim. The complexity is O(v) where v is the size of image.
Applies a 1-dimensional sum filter of radius radius to every pixel of the array image along the dimension dim. The complexity is O(v) where v is the size of image.
Applies a 1-dimensional square filter of radius radius to every pixel of the array image along the dimension dim. A square filter produces the average of the sum of the squares of the values within the window of the filter, that is, S = Σi xi2 / n where n = 2*radius+1. This operation is useful for computing a variance filter as the variance over the same window is Σi (xi - σ)2 / n = S - σ2 where σ is the mean obtained with an average filter. The complexity is O(v) where v is the size of image.
Applies a 1-dimensional min filter of radius radius to every pixel of the array image along the dimension dim. The complexity is O(v) where v is the size of image.
Applies a 1-dimensional max filter of radius radius to every pixel of the array image along the dimension dim. The complexity is O(v) where v is the size of image.
Applies the 1-dimensional filter filter to every pixel of the array image along every dimension. That is the result is the same as applying the n-dimensional filter Filter_Power(filter,image->ndims) to every pixel. The complexity is O(vrn) where v is the size of image, r is the size of filter, and n is the dimensionality of image.
For dimensions i from 0 to image->ndims-1 in that order, apply the 1-dimensional filter filter[i] to image along dimension i. The complexity is O(vrn) where v is the size of image, r is the average size of the filters, and n is the dimensionality of image.
Apply an average filter of radius radius to image image. The complexity is O(vn) where v is the size of image and n is the dimensionality of image.
Apply a sum filter of radius radius to image image. The complexity is O(vn) where v is the size of image and n is the dimensionality of image.
Apply a variance filter of radius radius to image image. The complexity is O(vn) where v is the size of image and n is the dimensionality of image. One spare working copy of the image is required during the operation.
Apply a min filter of radius radius to image image. This is also a generalization of the morphological erosion operator for grey-scale images. The complexity is O(vn) where v is the size of image and n is the dimensionality of image.
Apply a max filter of radius radius to image image. This is also a generalization of the morphological dilation operator for grey-scale images. The complexity is O(vn) where v is the size of image and n is the dimensionality of image.
Apply a Laplacian of Gaussian (LOG) filter to image image where the filter has standard deviation sigma and support radius radius in every dimension. See LOG_Filter for a formal definition of the filter. The complexity is O(vn2r) where v is the size of image, n is the dimensionality of image, and r is the radius of the support. Two spare working copies of the image are required during the operaion.
Apply a difference of Gaussians (DOG) filter to image image where a Gaussian with standard deviation sigma2 is subtracted from a Gaussian with standard deviation sigma1 over a support of radius radius in every dimension. See DOG_Filter for more on how this filter is an efficient approximation of the LOG filter. The complexity is O(vnr) where v is the size of image, n is the dimensionality of image, and r is the radius of the support. One spare working copy of the image is required during the operation.
Apply a difference of boxes (DOB) filter to image image where a box filter with radius deviation radius2 is subtracted from a box filter with radius radius1 in every dimension. The support of the filter in each dimension is the greater of radius1 and radius2. The complexity is O(vn) where v is the size of image, and n is the dimensionality of image.
Apply a Laplacian of Gaussian filter to image image where the filter has standard deviation sigma[i] and support radius radius[i] in dimension i. See ALOG_Filter for a formal definition of the filter. The complexity is O(vn2r) where v is the size of image, n is the dimensionality of image, and r is the average radius of the supports.
Apply a difference of Gaussians (DOG) filter to image image where a Gaussian with standard deviation sigma2[i] is subtracted from a Gaussian with standard deviation sigma1[i] over a support of radius radius[i] in dimension i. See ADOG_Filter for more on how this filter is an efficient approximation of the LOG filter. The complexity is O(vnr) where v is the size of image, n is the dimensionality of image, and r is the radius of the support. One spare working copy of the image is required during the operation.
Apply a difference of boxes (DOB) filter to image image where a box filter with radius deviation radius2[i] is subtracted from a box filter with radius radius1[i] in every dimension. The support of the filter in each dimension is the greater of radius1[i] and radius2[i]. The complexity is O(vn) where v is the size of image, and n is the dimensionality of image.
Apply a median filter to image image over a window of radius radius in every dimension. The time complexity is O(vr n) where v is the size of image, n is the dimensionality of image, and r is the radius of the support.
Replace each pixel of image with the rankth largest element in a window of radius in every dimension. The complexity is O(vr n) where v is the size of image, n is the dimensionality of image, and r is the radius of the support. |