Note: Two pairs (four) of RGB-HSI conversion functions are provided in this program. They are based on, respectively, the RGB cube color model and the HSV hexcone model. Go through the code to make sure you understand how the conversion is done before you use it. For example, you should know that the intensity in the function is represented by a value between 0 and 1 (instead of 0 and 255!). Try both color models for the following and submit the better one for each. Comment on the difference (or similarity) between the two, if any.
(a) Increase the dynamic range of the intensity I of the image by linearly stretching its intensity histogram while keeping the hue and saturation unchanged. Submit the result as image 1.
(b) Increase the saturation S of the image while keeping their hue and intensity unchanged. Submit the result as image 2.
(c) Modify the hue H by changing the hue angle. Submit the image with increased hue (e.g. by 45 degrees) as image 3 and the one with decreased hue as image 4.
(d) Modify all three parameters H, S, and I of the image to make it most beautiful! Submit the result as image 5.
(e) Choose a gray level image and convert it into a psudo color image by assigning a color (in terms of the R, G, and B values) to each of the 256 gray levels through a color-lookup table, a 256 (for gray levels) by 3 (for R,G,B) array. You are free to choose the contents of the table for the color mapping. Submit the result as image 6.
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 7 and 8.
(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 provided to implement your own DCT 2D filtering. 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 13.
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 14 and 15.
Now do the same for sequency filtering. Use the provided 1D fast WHT function to do 2D WHT filtering. Save the sequency spectrum as an image (after rescaling and normalization) and submit it as image 16.
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 17 and 18.
Repeat the previous part based on the DHT. Submit the results as images 19, 20, and 21.