IMAGE commands


PROGRAM NAME

ifiltdesign - General 2-D image filter design

DESCRIPTION

This routine generates a spatial frequency image of real values (zero phase) that represent the magnitude response of the requested filter type and brand. The filter types are are: lowpass, highpass, bandpass, and bandstop. The function brands are: ideal, Butterworth, Gaussian, Chebyshev I, and Chebyshev II.

The output is symmetric across a diameter thru the origin of the image; the origin can be either the center of the image or the top left corner of the image. Cutoff frequencies are normalized to the Nyquist frequency, thus implying that 0 corresponds to DC and 1.0 corresponds to the Nyquist frequency.

Note that the number of pixels between DC and Nyquist is given by the image_width/2 in the width direction and image_height/2 in the height direction. This means that if you ask for a non-square image you will get a non-circularly symmetric passband in the output. This occurs because it is assumed that the frequency sampling interval is the same in both directions.

For the ideal filter, the magnitude response is 1.0 in the passband, 1.0 at the cutoff frequency, and zero in the stopband.

For the Butterworth filter (also called a maximally-flat filter), the magnitude response in the passband grades from 1.0 down to 1/sqrt(2) at the cutoff frequence. The response in the stopband falls from 1/sqrt(2) towards zero at a rate that increases with the order of the filter. This filter is described in Oppenheim and Schafer, p.845, Eq. B.1.

For the Gaussian filter (actually a super-Gaussian), the passband response grades from 1.0 down to 1/sqrt(2) at the cutoff frequency. The response in the stopband falls from 1/sqrt(2) towards zero at a rate that increases with the order of the filter. This is an ad-hoc filter that has nice behavior and is easy to understand.

The Chebyshev type I filter is an equiripple filter that places the ripple in the passband. In the passband, the response oscillates between 1.0 and 1/sqrt(1+epsilon^2), where epsilon controls the ripple . At the cutoff frequency, the magnitude response is exactly 1/sqrt(1+epsilon^2). The response in the stopband falls from that level towards zero at a rate that increases with the order of the filter. One way to set the parameters for this filter is to set epsilon to obtain the desired ripple behavior and then set the order to obtain the desired attenuation in the stopband. This filter is described in Oppenheim and Schafer, p.847, Eq. B.4.

The Chebyshev type II filter is an equiripple filter that places the ripple in the stopband. In the stopband, the response oscillates between 0.0 and 1/sqrt(1+(1/epsilon^2)), where epsilon controls the ripple . At the cutoff frequency, the magnitude response is exactly 1/sqrt(1+(1/epsilon^2)). The response in the passband falls from 1.0 towards that level at a rate that depends on the order of the filter. One way to set the parameters for this filter is to set epsilon to obtain the desired ripple behavior and then set the order to obtain the desired behavior in the passband. This filter is described in Oppenheim and Schafer, p.848, Eq. B.10.

REQUIRED ARGUMENTS

-o
type: outfile
desc: Output image

Mutually Exclusive Group; you must specify ONE of:

-lp
type: flag
desc: Low pass (requires upper cutoff)
OR
-hp
type: flag
desc: High pass (requires lower cutoff)
OR
-bp
type: flag
desc: Band pass (requires lower and upper cutoff)
OR
-bs
type: flag
desc: Band stop (requires lower and upper cutoff)

Mutually Exclusive Group; you must specify ONE of:

-ideal
type: flag
desc: Ideal
OR
-but
type: flag
desc: Butterworth
OR
-gauss
type: flag
desc: Gaussian
OR
-ch1
type: flag
desc: Chebyshev1
OR
-ch2
type: flag
desc: Chebyshev2

OPTIONAL ARGUMENTS

-wsize
type: integer
desc: Image width size (pixels)
default: 256
bounds: value > 0
-hsize
type: integer
desc: Image height (pixels)
default: 256
bounds: value > 0
-pos
type: cycle
desc: Low frequencies located at image center or corners
default: 1 "Center of Image"
-order
type: integer
desc: Filter order (related to steepness of cutoff and amount of attenuation)
default: 1
bounds: value > 0
-lcutoff
type: double
desc: Normalized lower cutoff frequency (fraction of Nyquist)
default: 0.25
bounds: 0 < [-lcutoff] < 1
-ucutoff
type: double
desc: Normalized upper cutoff frequency (fraction of Nyquist)
default: 0.5
bounds: 0 < [-ucutoff] < 1
-eps
type: double
desc: Ripple parameter (Chebyshev only)
default: 0.5
bounds: 0 < [-eps] < 1
-type
type: cycle
desc: Data type for output image
default: 11 "Double"

EXAMPLES

ifiltdesign -o output.filt -lp -but -order 4 -ucutoff 0.1 -wsize 512 -hsize 512

This command will generate a 512 x 512 image of doubles values with a range from 0 to 1 that corresponds to the frequency image that results from a normalized cutoff of 0.1 and a fourth order Butterworth transfer function. The DC value is centered at 256, 256 in the image.

This image can then be multiplied with the frequency domain representation of the image to be filtered, thus performing the filtering operation (in the frequency domain).

The following shows how one might apply the above filter to the "ball" image:
% kfft -i image:ball -o ball.fft -dir 0 -center 1 -scale 1
% kmul -i1 ball.fft -i2 output.filt -o ball.lp.fft
% kfft -i ball.lp.fft -o ball.lp -dir 1 -center 1 -scale 2
% kcmplx2real -i ball.lp -or ball.lp

The lowpass filtered output, ball.lp, can then be displayed directly using putimage.

SEE ALSO

kfft, kmul, lifiltdesign, kimage_proc

RESTRICTIONS

These filters generate only the magnitude response. While this is useful for filtering operations, the zero phase behavior may not be appropriate for other applications.

REFERENCES

Alan V. Oppenheim and Ronald W. Schafer, "Discrete-Time Signal Processing", ISBN 0-13-216292-X, Prentice-Hall, 1989.

Edward P. Cunningham,"Digital Filtering: An Introduction", ISBN 0-395-53989-7, Houghton Mifflin, 1992.

COPYRIGHT

Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.