0% found this document useful (0 votes)
28 views

Matlab Project

The document discusses image processing techniques applied to the cameraman.tif image. It resizes the image by scaling factors, performs arithmetic operations like addition and subtraction on images, applies logarithmic and power-law transformations, performs histogram equalization, applies filters like averaging, Laplacian and Gaussian filters, takes the Fourier transform, and applies low-pass and high-pass Gaussian filters. The key steps and filters applied are demonstrated through code snippets and resulting output images.

Uploaded by

razanahmad0502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Matlab Project

The document discusses image processing techniques applied to the cameraman.tif image. It resizes the image by scaling factors, performs arithmetic operations like addition and subtraction on images, applies logarithmic and power-law transformations, performs histogram equalization, applies filters like averaging, Laplacian and Gaussian filters, takes the Fourier transform, and applies low-pass and high-pass Gaussian filters. The key steps and filters applied are demonstrated through code snippets and resulting output images.

Uploaded by

razanahmad0502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

%Question 1

I = imread('cameraman.tif');

scaling_factor = 0.5; % for shrinking


%scaling_factor = 2; % for zooming

new_size = round(scaling_factor * size(I));

row = min(round(((1:new_size(1))-0.5)/scaling_factor+0.5),size(I,1));
column = min(round(((1:new_size(2))-0.5)/scaling_factor+0.5),size(I,2));
new_image = I(row,column);

figure;
subplot(1,2,1);
imshow(I);
title('Original Image');
subplot(1,2,2);
imshow(new_image);
title('New Image');
%%
%Question 2
cameraman = imread('cameraman.tif');

lena = imread('MicrosoftTeams-image.png');

lena=imresize(lena,[256,256]);

% Add
addition = cameraman + lena;

% Subtract
subtraction = cameraman - lena;

% Multiply
multiplication = cameraman * 4;
figure;
subplot(3,3,1);
imshow(cameraman);
title('Cameraman');
subplot(3,3,2);
imshow(lena);
title('Lena');
subplot(3,3,3);
imshow(addition);
title('Addition');
subplot(3,3,4);
imshow(subtraction);
title('Subtraction');
subplot(3,3,5)
imshow(multiplication);
title('Multiplication');
%%
%Question3
%logarithmic function

I=imread('cameraman.tif');
I_log=log(1+double(I));
I_log=im2uint8(mat2gray(I_log));
subplot(1,2,1);
imshow(I)
subplot(1,2,2);
imshow(I_log)
%%
%power function
img = imread('cameraman.tif');

power_law=imadjust(img,[0 1],[0 1],1);

figure;
subplot(1,2,1);
imshow(img);
title('Original Image');
subplot(1,2,2);
imshow(power_law);
title('Power-Law Transformed Image');
%%
%Question4
I=imread('cameraman.tif');
A=histeq(I);
subplot(2,2,3)
imhist(I,255);
subplot(2,2,4)
imhist(A,255);
subplot(2,2,1)
imshow(I);
subplot(2,2,2)
imshow(A)

%%
%Question5
I = imread('cameraman.tif');
mask = ones(3) / 9;
filtered_image = imfilter(I, mask);
montage({I, filtered_image}, 'Size', [1 2]);
title('Original Image (Left) vs Filtered Image (Right)');
%%
%Question6
%laplacian filter
I = imread('cameraman.tif');

L = [0 -1 0; -1 5 -1; 0 -1 0];

J = imfilter(I, L);

figure;
subplot(1,2,1);
imshow(I);
title('Original Image');
subplot(1,2,2);
imshow(J);
title('Enhanced Image');
%%
%Question7
I = imread('cameraman.tif');

h = fspecial('average', [3 3]);
low_pass_image = imfilter(I, h);
k = 1.5;
high_boost_filter = I - low_pass_image + k;
subplot(1,2,2);
imshow(I)
subplot(1,2,2);
imshow(high_boost_filter)

%%
%Question8

img = imread('cameraman.tif');
F = fft2(img);
F = fftshift(F);
F = abs(F);
F = log(F+1);
F = mat2gray(F);
imshow(F, []);
%%
%Question9

img = imread('cameraman.tif');

% Convert the image to grayscale


if size(img, 3) == 3
img = rgb2gray(img);
end
% Apply a Gaussian lowpass filter
sigma = 5;
img_lowpass = imgaussfilt(img, sigma);

% Apply a Gaussian highpass filter


img_highpass = imsubtract(img, img_lowpass);
figure;
subplot(1, 3, 1);
imshow(img);
title('Original Image');
subplot(1, 3, 2);
imshow(img_lowpass);
title('Lowpass Filtered Image');
subplot(1, 3, 3);
imshow(img_highpass);
title('Highpass Filtered Image');

You might also like