Академический Документы
Профессиональный Документы
Культура Документы
▼2 f= d2f/dx2 + d2f/dy2. - A
In digital or discrete domain the derivatives are replaced by the differences. Thus here when we talk of
digital images then
0 1 0
1 -4 1
0 1 0
Implementation of B at a particular location (x,y) is equivalent of convolving it with the given kernel
and the laplacian of the whole image is carried out by passing the mask over the entire image and
replacing the value at x,y by the convolution result.
Thus as we can see that the defination of the
laplacian operator demands that the kernel is of the above order, that is why the sum of all individual
elements of the kernel is zero.
If we consider the terms df/dxdy in the definition of d2f/dx2 and d2f/dy2 ,then our kernel will be of the
type
1 1 1
1 -8 1
1 1 1
Then also the sum off all the elements of kernel is zero.
If the sum of all the elements in the kernel is not 0 then if we onvolve the kernel with the image of
uniform intensity or grey level,then also i will get a non zero value. As laplaian is an approximation of
second order derivative we must get non zero values where there are transition in greylevel value. So
our approximation will be wrong if sum of all elements in the kernel is not zero.
Image with salt and pepper noise Result of applying Adaptive Median Result of applying median filter with
Filter with Smax = 7 3x3 mask
Median filter is a non-linear filter.
Actually finding a median is itself not a linear operation. Hence the filter is a non linear filter.
Adaptive median filter would be used in applications where density of salt and pepper noise is
unpredictable. The size of the kernel is dependent on the noise distribution. For dense noise distribution
the kernel size is desired to be large (as the number of impulses will be high). While for lower density
the kernel size can be small.
Problem 2:
We have taken the image and have applied Gaussian filter on it which is having zero mean and a finite
variance. Here the image taken by us is the checkerboard pattern.
Original image
Basically Gaussian filter acts like a low pass filter which basically performs averaging. Hence when
the Gaussian filter is applied to the image it results in the blurring of the details in the image. Now if
the Gaussian filter is applied again and again it results in more blurring in the image. Figure shows the
application of Gaussian filter 10000 times on the above image.
Now we apply Gaussian filter to FFT of the image. The result is shown in the diagram given below.
More application of Gaussian filter on the FFT of the image gives the result as follows:-
Problem 4:
We have taken a image, which is shown below:-
Original image
Now we apply firstly Gaussian filter which results in blurring of the image. After that we apply
laplacian filter which basically results in edge detection. The output after application of the two filters
is shown below.
Problem 5:
Yes there exists a function whose Fourier transform is the function itself. It is the Gaussian function.
The Fourier transform of the Gaussian function is Gaussian.
PROOF:
We know that the Gaussian function is given by
f(z)=(1/2пσ2 )exp{(z-μ)2/2σ2}
where z is the pixel value, the term μ signifies mean and sigma standard deviation.
Let us leave the constants and treat the function in time domain. So we have
f(t)=exp{-t2/2σ2}
now the Fourier transform is given by
F(w)=∫ f(t)exp(-j2пft)dt
now apply the property of differentiation in time domain on the left hand side and that of differentiation
in frequency domain in right hand side. We get
jwF(w)=1/σ2(d/jdwF(w))
on rearranging
∫ (d/dw F(w))/F(w)= ∫ -wσ2
ln F(w) – ln F(0)=1/2σ2w2 .
thus
F(w)=F(0)exp{-1/2σ2w2)
√ (2пσ)
Hence proved.
Problem 6:
Changing of the histogram would result into changing of the dynamic range and hence change in the
frequencies of the values of the image.
Histogram equalization is the process in which the histogram of the image is stretched throughout the
dynamic range.
The transformation is done by the following formula:
p(xi) is the probability of occurrence of level i in the image. L is the maximum value. ni is the
frequency of level i and n is the total number of pixels in the image. C(i) gives the cumulative
frequency of all the gray levels till gray level i. This cumulative frequency distribution actually results
into the final output as given in third equation.
Once yi is obtained, the probabilities of all the values will be spread across the histogram, i.e. the
histogram is now actually stretched across the dynamic range. Hence performing histogram
equalization again on the image would mean again generating the same cumulative distribution as just
obtained. Hence histogram would remain as it is and hence histogram equalization is idempotent.
Results:
References:
1. Digital Image Processing- Rafael C. Gonzales
2. Digital Image Processing Using Matlab
3. www.wikipedia.com
Listings for the problems:
Listing 1:
%Lab Challenge 3: Problem 1
clear;
I = imread('Fig4.20(a).jpg');
f = fspecial('laplacian', 0);
J = imfilter(I, f, 'replicate');
K = I-J;
figure, imshow(K);
Listing 2:
%Lab Challenge 3: Problem 2
I = imread('checkerboard_50x50.bmp');
F = fft2(double(I));
imshow(log(1+abs(fftshift(F))), []);
figure, imshow(I);
f = fspecial ('gaussian', [3 3], 5)
n=5;
J=I;
K=F;
for j=1:10000
J = imfilter(J, f, 'replicate');
K = imfilter(F, f, 'replicate');
end
Listing 3:
%Lab Challenge 3: Problem 2
clear;
I = imread('Fig5.04(i).jpg');
[M,N] = size(I);
arr = zeros(1, 9, 'uint8');
J = zeros(size(I), 'uint8');
%Implementing Median Filter....
for i=2:M-1
for j=2:N-1
k=1;
for l=-1:1
for m=-1:1
arr(k)= I(i+l, j+m);
k=k+1;
end
end
arr = sort(arr);
J(i,j) = arr(5);
end
end
imshow(J);
Smax = input('Enter Maximum Window Size (An Odd Number):=> ');
K = adpmedian(I, Smax);
figure, imshow(K);
[M, N] = size(g);
f=g;
f(:) = 0;
alreadyProcessed = false(size(g));
%Begin filtering
for k=3:2:Smax
zmin = ordfilt2(g, 1, ones(k,k), 'symmetric');
zmax = ordfilt2(g, k*k, ones(k,k), 'symmetric');
zmed = medfilt2(g, [k k], 'symmetric');
processUsingLevelB = (zmed>zmin) & (zmax > zmed) & ~alreadyProcessed;
zB = (g>zmin) & (zmax>g);
outputZxy = processUsingLevelB & zB;
outputZmed = processUsingLevelB & ~zB;
f(outputZxy) = g(outputZxy);
f(outputZmed) = zmed(outputZmed);
alreadyProcessed = alreadyProcessed | processUsingLevelB;
if all(alreadyProcessed(:))
break;
end
end
f(~alreadyProcessed) = zmed(~alreadyProcessed);
Listing 4:
%Lab Challenge 3: Problem 4
I = imread('Fig4.20(a).jpg');
f = fspecial('gaussian', 5)
h = fspecial('laplacian',0)
J = imfilter(I, f, 'replicate');
imshow(J);
K = I-imfilter(J, h, 'replicate');
figure, imshow(K);
L = I-imfilter(I, h, 'replicate');
figure, imshow(L);
K = imfilter(L, f, 'replicate');
figure, imshow(K);
Listing 5:
%Lab Challenge 3: Problem 6
I = imread('Fig3.15(a)1top.jpg');
imhist(I, 255); figure;
J=histeq(I);
imshow(J);
figure, imhist(J);
J= histeq(J);
figure, imhist(J);