In order to visualize the spectrum to see how the energy is distributed in the frequency domain, convert the spectrum in the complex array into a real image. To do this, you first find the magnitude of each frequency component (with both real and imaginary parts), then normalize these values so that they range from 0 to 255. As most of the energy is contained in the DC component and low frequency components, you will most likely see a bright spot at the center of the spectrum (if centralized). To see better how the rest of the total energy is distributed, you can scale their magnitude nonlinearly by, say, y=pow(x, 0.3). Then save the spectrum as an image. Submit the image and its spectrum as images 1 and 2.
(i) an ideal low-pass filter (ILPF).
(ii) an ideal high-pass filter (IHPF).
(iii) a Butterworth low-pass filter (BLPF).
(iv) a Butterworth high-pass filters (BHPF).
Try a few different orders for Butterworth filter to see the effect. Also try
different cut-off frequencies to see the filtering effect. When considering the
cut-off frequency, always keep in mind that most of the energy is concentrated a
round the DC component. In other words, the radius of the filter (representing
cut-off frequency) can be small for low-pass filtering (as most low frequency
components are kept), and it should be large to cover enough energy for high-pass
filtering (as the DC and some low frequency components are filtered out).
Use the 1D fast DCT function contained in a sample program "/e186/programs/myfdct.c" in your own DCT 2D filtering program. Similar to the 2D DFT, here you transform the columns and then the rows to get the 2D spectrum. Print the spectrum as an image (after nonlinear scaling and normalization) to have a visual display of the spectrum. Submit this frequency spectral 2D array as image 5.
Then both high-pass and low-pass filter the image. Different from the Fourier spectrum, now the lowest frequency component, the DC component, is at the upper-left corner and the highest sequency component is at the lower-right corner of the 2D array of the spectrum. You should design your filters accordingly. To avoid the ringing effects, use any of the smooth filters discussed in class (Gaussian, Butterworth, or Hamming filter). Then inverse transform the filtered spectrum back to the spatial domain and submit the two filtered images as images 6 and 7.
Now do the same for sequency filtering. Use the provided 1D fast WHT function "/e186/programs/mywht.c" in your program. Save the sequency spectrum as an image (after rescaling and normalization) and submit it as image 8.
Then both high-pass and low-pass filter the sequency spectrum of the image in the same way as 2D DCT filtering (you can use exactly the same code). Then inverse transform the filtered spectrum back to the spatial domain. Note that the inverse transform is identical to the forward transform (How nice!). Submit the two filtered as images 9 and 10.