Vous êtes sur la page 1sur 9

Lab Review 02

Filtering Operations
Image Analysis and Computer Vision
November 27, 2013
=====================================================================
Question 1: Repeat this exercise with the coordinates p and q set to (9, 5), (17, 9), (17, 121), (5, 1)
and (125, 1) respectively. What do you see? Explain?
fftwavetemplate(p,q,size)
The image intensity changes in the spatial domain changes the most if we go along horizontally,
vertically, and diagonally.
So we see that the Fourier transform is change of a basis function, from discrete delta functions defined
in on the Cartesian image domain to complex exponential function with maximum spatial extension.
The basis vector is given by the index (p, q).
F (u, 0) is related to the frequency u of sinusoids occurring parallel to the x axis of the image i.e. the
intensity changes most if we go vertically. So the sinusoids occur parallel to the x axis. And the direction
is vertical from the origin.
F (0, v) is related to the frequency v of sinusoids occurring parallel to the y axis of the image i.e. the
intensity changes most if we go horizontally. So the sinusoids occur parallel to the y axis. So the
direction is horizontal from the origin.
F (u, v) is related to the frequency u**2+v**2 of sinusoids parallel to a line from the origin to (u, v) i.e.
the intensity changes most diagonally from the origin. So the sinusoids parallel to a line from the origin
to (u, v).
The frequency component near the centre represents low frequency and the point far from the centre
represents high frequency.
The point (9, 5) in the frequency domain presents the changes of the image intensity in the spatial
domain. As it changes the most in the right diagonal direction, so the periodic patterns are left diagonal.
=====================================================================================
.

===========================================================================
Question 2: Explain and illustrate with a Matlab figure how a position (p, q) in the Fourier domain
will be projected as a sine wave in the spatial domain.
lab2_ex2(64,64)
In the Fourier domain image, each point represents a particular frequency contained in the spatial domain
image.
If an image has perfectly sinusoidal variations in brightness, then it can be represented by very few dots
on the frequency image. From those images, you can also see that regular images or images of repeating
pattern generate fewer dots on the frequency graph.
Since the images contain only distinct frequencies, the Fourier images contain only dots, i.e., have nonzero values only at specic locations.
Since the coordinates of the dots equal the frequencies of the sinusoids occurring in the original image,
higher image frequencies cause the dots to move away from the origin.
The dots are oriented from the origin in the same direction as the frequency wave in the original image.
If we rotate the image (e.g., consider the rst and second rows), the Fourier transform rotates with it.
The dots are oriented in the direction of the waves, so perpendicular to the edges occurring in the original
image.
===========================================================================
The magnitude is simply the peak value, and the phase determines where
the origin is, or where the sinusoid starts.
===========================================================================
Question 3: How large is the amplitude? Write down the expression derived from Equation (4) in
these notes. Complement the code (variable amplitude) accordingly.
Fabsmax = max(abs(F(:)));

amplitude = Fabsmax;

========================================================================
Question 4: How does the direction and length of the sine wave depend on p and q? Draw an
illustrative figure on paper. Write down the explicit expression that can be found in the lecture
notes. Complement the code (variable wavelength) accordingly.
lab2_ex2(120,5)

========================================================================
Question 5: What happens when we pass the point in the center and either p or q exceeds half the
image size? Explain and illustrate graphically with Matlab!
lab2_ex5(0,0)
In the centered image the centre point represents the 0 frequency.
For fft image it can be viewed as swapping diagonal opposite image parts to each other.
========================================================================

Question 6: What is the purpose of the instructions following the question what is done by these
instructions? In the code?
This means to change the origin after using fft2. It finds the place with respect to the changed origin for a
shifting fft2.
===========================================================================

Linearity
fftshift:
Y = fftshift(X) rearranges the outputs of fft, fft2, and fftn by moving the zero-frequency component to the
center of the array. It is useful for visualizing a Fourier transform with the zero-frequency component in
the middle of the spectrum. For vectors, fftshift(X) swaps the left and right halves of X. For matrices,
fftshift(X) swaps the first quadrant with the third and the second quadrant with the fourth.
ExamplesFor any matrix X Y = fft2(X)

has Y(1,1) = sum(sum(X)); the zero-frequency component of the signal is in the upper-left corner of the
two-dimensional FFT. For Z = fftshift(Y) this zero-frequency component is near the center of the matrix.

===========================================================================
Question 7: Why are these Fourier spectra concentrated to the borders of the images?
lab2_ex7()
lab2_ex7_split_1()
lab2_ex7_split_g()
The image has a square wave/box like part which means theoretically it has infinite frequency
components. Also the white part is completely horizontal/vertical. And before centre shifting the
upper left corner represents the zero frequency/centre of the FFT. These are the reasons why we
see the spectra concentrated to the borders.

===========================================================================
Question 8: Why is the logarithm function applied?
Typically, the values of |F(u, v)| are such that direct display of these values results in dark, low-contrast
images. To enhance contrast, log(|F(u, v)| + 1) (or a similar remapping of |F(u, v)|) is often displayed
instead. So it enhance the grey level details.
The logarithmic transformation of the fourier transform shows that the image contains minor frequencies
which may not be visible in the original image due to large range to values.
===========================================================================
It is also common to display |F(u, v)| for negative values of u and v. For this, the
origin of the image is shifted to the image center
===========================================================================
Question 9: What conclusions can be drawn regarding linearity?
We can add two functions (images) or rescale a function, either before or after computing the Fourier
transform. It leads to the same result.
However, the logarithmic scaling makes it difficult to tell the influence of single frequencies in the
original image. To find the the most important frequencies we threshold the original fourier magnitude
image.
===========================================================================

Multiplication
===========================================================================
Question 10: Are there any other ways to compute the last image? Remember what multiplication
in Fourier domain equals to in the spatial domain !!
lab2_ex8()
Multiplication in the spatial domain is same as convolution in the fourier domain or vice versa.
Fourier transformation of a convolution is the point wise product of the fourier transformation.

===========================================================================
Scaling
===========================================================================
Question 11: What conclusions can be drawn from comparing the results with those in the previous
exercise?
lab2_ex11()
Compression in the spatial domain is same as the expansion in the fourier domain and vice versa.
i.e. the dimensions of the box have inverse relation with the pattern of the fourier spectrum. If the width is
increased, the corresponding fourier pattern gets narrower and denser.
So we get the centered log transformation.
===========================================================================
Rotation
===========================================================================
Question 12: What can be said about possible similarities and differences?
L2_12ex()
Same as the original image but rotate 30 degree like the original. One of the properties of the 2D FT is
that if you rotate the image, the spectrum will rotate in the same direction.
So the rotation of the image causes same rotation in the FFT. But there are some interference
pattern appears in the rotated one, because the image is not smooth. When we rotate back the FFT
we see a similar to original but with interference pattern.

===========================================================================
Rotational symmetry
===========================================================================
Question 13: How does the rotational symmetry affect the Fourier spectrum and why?
L2_13ex()
The Fourier Transform is rotationally invariant.
The fft of the circle image is also a circular pattern. It is like a summation of box function rotated in every
angle, so the corresponding fourier spectrum is also the summation of the individual patterns which looks
like the circular one.
===========================================================================
Translation
===========================================================================
Question 14: What similarities and differences can you observe?
L2_14ex()

Here the position of the image is changed. But the FFTs are looks similar. The phase is different.
Similar into the centered fourier transform but differences into the phase spectrum.
===========================================================================
Information in Fourier phase and magnitude
===========================================================================
Question 15: What information is contained in the phase and in the magnitude of the Fourier
transform?
Phone = phonecalc128;
L2_15ex(inpic)
pow2image() for different magnitude using power spectrum and randphaseimage() that keeps the
magnitude of the fourier distribution but replaces the phase information with a random distribution.
Phase contains most of the position information of the image (power is changed but still the images are
recognizable for the phase) and the magnitude contains some information about grey levels.
===========================================================================
Gaussian convolution implemented via FFT
Gaussian convolution means that we convolve the image with a Gaussian kernel.
With spatial discretization and spatial convolution:
1. Generate a filter based on a sampled version of the Gaussian function.
2. Convolve the image with this filter using the embedded Matlab-function conv2.
With spatial discretization and convolution via FFT:
1. Generate a filter based on a samples version of the Gaussian function.
2. Fourier transform the original image and the Gaussian filter.
3. Multiply the Fourier transforms.
4. Invert the resulting Fourier transform.
Gaussian convolution in the Fourier domain:
1. Fourier transform the original image
2. Multiply the transformed image with the Fourier transform of the Gaussian kernel.
3. Invert the resulting Fourier transform.
===========================================================================
spat_filter = gaussffta(phone,10); this function uses: gauss = l_p_filter_sp(m, n, sigma);
four_filter = gaussfftb(phone,10); this function uses: H = low_pass_filter(type, M, N, D0, n)
pixels = discgaussfft(inpic, sigma2)

===========================================================================

Question 16: How does the result correspond to the ideal continuous case, for which the covariance
matrix is t multiplied by the identity matrix?
V = L2_17ex(0.1 or 1 or 10 or 100) %discgauss

We calculate the impulse response, so the variance is just what was given input.
We get the covariance matrix which is an identity matrix multiplied by t.
Here we calculate the impulse response, so the variance is just what was given input. The
covariance matrix of the Gaussian kernel does not changed by this.

===========================================================================
Question 17: Show the impulse response and variance for the above mentioned t-values. What are
the variances of your discretized Gaussian kernel for t = 0.1, 1.0, 10.0 and 100.0?
[variance_spa, variance2_gauss] = L2_16ex_1(0.1)
===========================================================================
===========================================================================
Question 18: Can you note any differences between the results of gaussffta and gaussfftb? Why are
the results different from or similar to the estimated variance? Lead: First consider the results for
small t values.
[variance_spa, variance2_gauss] = L2_16ex(phone,10)
L2_18ex_1(Phone,0.1)
Little difference in the borders of the different filter image.
Also I found little different in the variance. And that may be because of filter in different way.
===========================================================================
Question 19: Convolve a couple of images with Gaussian functions of different variances (like t =
1.0, 4.0, 16.0, 64.0 and 256.0). What effects can you observe?
L2_18ex_1(Phone,0.1)
The images getting blurred with t.
===========================================================================
Smoothing

L2_18ex(office)
===========================================================================
Question 20: What conclusions can you draw from comparing the results of the respective method?
L2_19ex(phone)
/all in one with gauss noise
L2_19ex_new(imag)

/ all in one with sap noise

L2_20ex(phone)
L2_21ex(phone)
L2_22ex(phone)
By filters, we change in image intensity also change in amount of noise. Gaussian filter is comparatively
better for removing Gaussian noise, but it blurs the image.
The amount of noise removal and amount of blurring increases as t increases.
Median filter works well specially for removing sap noise and it creates a paining like image as
window size increases.
Ideal low pass filter creates a ringing effect for both add and sap, where the ring size increases as the cutoff frequency decreases. It can be useful to see the effects of high frequencies in the image.
===========================================================================
Question 21: What positive and negative effects does each filter type have?
L2_19ex(phone)
L2_20ex(phone)
L2_21ex(phone)
L2_22ex(phone)
===========================================================================
Question 22: What respective similarities and differences can you observe between the different
filters?
L2_19ex(phone)
L2_20ex(phone)
L2_21ex(phone)
L2_22ex(phone)

===========================================================================
Question 23: How do the results depend on the filter parameters?
L2_19ex(phone)
L2_20ex(phone)
L2_21ex(phone)
L2_22ex(phone)

===========================================================================
Question 24: What are the effects you observe based on these illustrations?
[var3] = L2_24ex_new(0.3) , t = 0.6, 0.5
The impulse response of an ideal low pulse filter has a bright component at the origin and some
circular components around this. The radius of the circular component is inversely proportional to
the value of cut-off frequency.
===========================================================================
Contrast improvement
===========================================================================
Question 25: Why can you replace the whole operation above with a single filter?
Blocks = blocks1;
% % sharpmask = L2_ex25(blocks,0.1);
sharpmask = l25_ruf(imag,t);
filtered image = image coeef * lapalace * image
= (1- coeff*laplace)*image
we made the function sharpmask , so now we can use this function.
===========================================================================
Question 26: How is the Laplace operator affected by noise?
L2_ex26(blocks)
It enhances the noise, because noise is sharp change in the pixel intensity.
So we loose the edge contrast.edge is not understandable if we apply the laplace operator to the noise.
===========================================================================

Vous aimerez peut-être aussi