0% found this document useful (0 votes)
52 views10 pages

Laboratory 4 Linear and Non Linear Spatial Filters: Cameraman - Tif' 'Ave' 'Replicate'

The document describes experiments using various spatial filters on images. It discusses averaging, median, and Laplacian filtering on sample images. It also applies lowpass and highpass filtering in the frequency domain by multiplying the image Fourier transform with Gaussian and inverse Gaussian filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views10 pages

Laboratory 4 Linear and Non Linear Spatial Filters: Cameraman - Tif' 'Ave' 'Replicate'

The document describes experiments using various spatial filters on images. It discusses averaging, median, and Laplacian filtering on sample images. It also applies lowpass and highpass filtering in the frequency domain by multiplying the image Fourier transform with Gaussian and inverse Gaussian filters.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Lihat, Vanessa Coleen A.

BS CPE 4B

LABORATORY 4

LINEAR AND NON LINEAR SPATIAL FILTERS

AVERAGE FILTERING
im = imread(cameraman.tif');
[r,c] = size(im);
f = fspecial('ave');
ave = imfilter(im, f, 'replicate');
subplot(1, 2, 1);
imshow(im); title (‘Original Image’);
subplot(1, 2, 2);
imshow(ave); title (‘Average Image’);

MEDIAN FILTERING
im = imread('eight.tif');
subplot(2,1,1);
imshow(im); title('Original Image');
K = medfilt2(im);
subplot(2,1,2);
imshow(K); title('Median Filtering');

LAPLACIAN FILTERING
im = imread(‘cameraman.tif’);
subplot(2,2,1);
imshow(im);
title('Original Image');
lap = fspecial('laplacian');
blurred = imfilter(im,lap);
subplot(2,2,2);
imshow(blurred);
title('Laplacian Filtering')
Lihat, Vanessa Coleen A.
BS CPE 4B

LABORATORY 5

IMAGE FILTERING IN FREQUENCY DOMAIN

TASK 1
im = imread('eight.tif');
[r, c] = size(im);
imshow(im);
im = im2double(im);
F = fft2(im);
F = fftshift(F);
Sigma = 30;
H = 1- fspecial('gaussian', [r c], Sigma);
G = H.*F;
G = ifftshift(G);
g = real(ifft2(G));
figure, imshow(g, []);

TASK 2

1. Image 1: Lowpass filter


2. Image 2: Highpass filter
Brigole, Faithtrex G.

BS CPE 4B

LABORATORY 4: LINEAR AND NON LINEAR SPATIAL FILTERS

Task 1:

a = imread('cameraman.tif');
[r, c] = size(a);
f = fspecial('average');
averaged = imfilter(a, f, 'replicate');
subplot(1, 2, 1);
imshow(a); title('Original Image');
subplot(1, 2, 2);
imshow(averaged); title('Averaged Image');

Task 2:

a = imread('eight.tif');
K = medfilt2(a);
imtool(a), imtool(K);

Task 3:

a = imread('cameraman.tif');
[r, c] = size(a);
f = fspecial('laplacian');
laplacian = imfilter(a, f, 'replicate');
subplot(1, 2, 1);
imshow(a); title('Original Image');
subplot(1, 2, 2);
imshow(laplacian); title('Laplacian Image');
Brigole, Faithtrex G.

BS CPE 4B

LABORATORY 5: IMAGE FILTERING IN FREQUENCY DOMAIN

Task 1:

I = imread('eight.tif');
[r, c] = size(I);
imshow(I);
I = im2double(I);
F = fft2(I);
F = fftshift(F);
Sigma = 30;
H = 1- fspecial('gaussian', [r c], Sigma);
G = H.*F;
G = ifftshift(G);
g = real(ifft2(G));
figure, imshow(g, []);

Task 2:

1. Lowpass filter
2. Highpass filter
Ybañez, Vaneza Ann Mae A.

BS CPE 4B

LAB 4
LINEAR AND NON LINEAR SPATIAL FILTERS

Task 1

x = imread('cameraman.tif');
[r, c] = size(x);
f = fspecial('average');
averaged = imfilter(x, f, 'replicate');
subplot(1, 2, 1);
imshow(x); title('Original');
subplot(1, 2, 2);
imshow(averaged); title('Averaged');

Task 2

x = imread('eight.tif');
K = medfilt2(x);
imtool(x), imtool(K);

Task 3

x = imread('cameraman.tif');
[r, c] = size(x);
f = fspecial('laplacian');
laplacian = imfilter(x, f, 'replicate');
subplot(1, 2, 1);
imshow(x); title('Original');
subplot(1, 2, 2);
imshow(laplacian); title('Laplacian');
Ybañez, Vaneza Ann Mae A.

BS CPE 4B

Lab 5
IMAGE FILTERING IN FREQUENCY DOMAIN

Task 1

x = imread('eight.tif');
[r, c] = size(x);
imshow(x);
I = im2double(x);
F = fft2(x);
F = fftshift(F);
Sigma = 30;
H = 1- fspecial('gaussian', [r c], Sigma);
G = H.*F;
G = ifftshift(G);
g = real(ifft2(G));
figure, imshow(g, []);

Task 2

1.Lowpass filter
2.Highpass filter
Malaran, Lea G.

BS CPE 4B

LABORATORY 4

Task 1
I = imread('cameraman.tif');
[r, c] = size(I);
f = fspecial('average');
averaged = imfilter(I, f, 'replicate');
subplot(1, 2, 1);
imshow(I); title('Original Image');
subplot(1, 2, 2);
imshow(averaged); title('Averaged Image');

Task 2
I = imread('eight.tif');
K = medfilt2(I);
imtool(I), imtool(K);

Task 3
I = imread('cameraman.tif');
[r, c] = size(I);
f = fspecial('laplacian');
laplacian = imfilter(I, f, 'replicate');
subplot(1, 2, 1);
imshow(I); title('Original Image');
subplot(1, 2, 2);
imshow(laplacian); title('Laplacian Image');
Malaran, Lea G.

BS CPE 4B

LABORATORY 5

Task 1
I = imread('eight.tif');
[r, c] = size(I);
imshow(x);
I = im2double(I);
F = fft2(I);
F = fftshift(F);
Sigma = 30;
H = 1- fspecial(‘gaussian’, [r c], Sigma);
G = H.*F;
G = ifftshift(G);
g = real(ifft2(G));
figure, imshow(g, []);

Task 2

1. Lowpass filter
2. Highpass filter
Rupinta, Clynt Neiko J.

BS CPE 4B

LABORATORY 4

Task 1:

A = imread('cameraman.tif');
[r, c] = size(A);
f = fspecial('average');
averaged = imfilter(A, f, 'replicate');
subplot(1, 2, 1);
imshow(A); title('Original');
subplot(1, 2, 2);
imshow(averaged); title('Averaged');

Task 2:
A = imread('eight.tif');
K = medfilt2(A);
imtool(A), imtool(K);

Task 3:
A = imread('cameraman.tif');
[r, c] = size(A);
f = fspecial('laplacian');
laplacian = imfilter(A, f, 'replicate');
subplot(1, 2, 1);
imshow(A); title('Original');
subplot(1, 2, 2);
imshow(laplacian); title('Laplacian');
Rupinta, Clynt Neiko J.

BS CPE 4B

LABORATORY 5

Task 1:
A = imread('eight.tif');
[r, c] = size(A);
imshow(A);
I = im2double(A);
F = fft2(A);
F = fftshift(F);
Sigma = 30;
H = 1- fspecial('gaussian', [r c], Sigma);
G = H.*F;
G = ifftshift(G);
g = real(ifft2(G));
figure, imshow(g, []);

Task 2:

1. Lowpass filter
2. Highpass filter

You might also like