0% found this document useful (0 votes)
89 views12 pages

DIP Lab Report-3

This document appears to be a lab report submitted by Addisu Tekuar to Kidist K on December 27, 2021. It contains MATLAB code for image processing tasks including histogram equalization, filtering, Fourier transforms, and sharpening. The code processes various images, including squares, landscapes, binary patterns, MRI scans, and cell/fiber images. Plots and figures are generated after running each code section.

Uploaded by

Addisu Tekuar
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)
89 views12 pages

DIP Lab Report-3

This document appears to be a lab report submitted by Addisu Tekuar to Kidist K on December 27, 2021. It contains MATLAB code for image processing tasks including histogram equalization, filtering, Fourier transforms, and sharpening. The code processes various images, including squares, landscapes, binary patterns, MRI scans, and cell/fiber images. Plots and figures are generated after running each code section.

Uploaded by

Addisu Tekuar
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/ 12

ADDIS ABABA UNIVERSITY

ADDIS ABABA INSTITUTE OF TECHNOLOGY


CENTER OF BIOMEDICAL ENGINEERING

DIP lab report-3


Addisu Tekuar
ATR/6652/10

Submitted to: Kidist K


Date: Dec. 27, 2021
% Q1.1
%global histogram equalization
Sqaure_image = imread('square.tif');
figure, imshow(Sqaure_image);
numel(Sqaure_image);
figure, imhist(Sqaure_image);
histogram_equalized_image = histeq(Sqaure_image,256); %global histogram equalization
figure, imshow(histogram_equalized_image);
histeq_sqaure= imhist(histogram_equalized_image);

%local histogram equalization


Sqaure_image_decoy= Sqaure_image;
windowRow_1= 3;
windowcolumn_1= 3;
window_middle = round((windowRow_1*windowcolumn_1)/2);
carry = 0;
for n = 1: windowRow_1
for m = 1: windowcolumn_1
carry = carry + 1;
if (carry == window_middle)
PadRow= n-1;
PadColumn=m-1;
break;
end
end
end
PadImg= padarray(Sqaure_image,[PadRow PadColumn]);
for k = 1: size(PadImg,1)-((PadRow*2)+1)
for l = 1: size(PadImg,1)-((PadColumn*2)+1)
cdf = zeros(256,1);
inc = 1;
for o=1:windowRow_1
for p=1:windowcolumn_1
if(inc==window_middle)
Ele=PadImg(k+o-1,l+p-1)+1;
end
pos=PadImg(k+o-1,l+p-1)+1;
cdf(pos)=cdf(pos)+1;
inc=inc+1;
end
end
for q=2:256
cdf(q)=cdf(q)+cdf(q-1);
end
Sqaure_image_decoy(k,l)=round(cdf(Ele)/(windowRow_1*windowcolumn_1)*255);
end
end
figure,imshow(Sqaure_image_decoy);

=>when we run the code we get


% Q1.2

Lake_image = imread('Lake.jpg');
Hsv_convert_img = rgb2hsv(Lake_image);
valueHistEq = histeq(Hsv_convert_img(:,:,3));
HSV_mode=Hsv_convert_img;
HSV_mode(:,:,3) = valueHistEq;
RGBequalizedImg= hsv2rgb(HSV_mode);
figure, imshow(Lake_image);
figure, imshow(RGBequalizedImg);

=>when we run the code we get


% Q 2.1
black_image = zeros(256,256);
BandWimg = black_image;
for i = 1:256
for j = 1:256
if i>=64&& i<=192 && j>=64&& j<=192
BandWimg(i,j)=255;
end
end
end
figure,imshow(BandWimg);
Fourier_spectrumImage= fft2(BandWimg);
fsh=fftshift(Fourier_spectrumImage);
figure,imshow(abs(fsh),[]);
log_scale = log(abs(fsh)+1);
figure, imshow(log_scale,[]);

=>when we run the code we get


% Q 2.2
BandWimg_2 = black_image;
figure,imshow(BandWimg_2);
for i = 1:256
for j = 1:256
if i>=1 && i<128 && j>128 && j<=256
BandWimg_2(i,j)=255;
end
end
end
figure,imshow(BandWimg_2);
Fourier_spectrumImage_2= fft2(BandWimg_2);
fsh_2=fftshift(Fourier_spectrumImage_2);
figure,imshow(abs(fsh_2),[]);
log_scale_2 = log(abs(fsh_2)+1);
figure, imshow(log_scale_2,[]);

=>when we run the code we get


% Q2.3
BandWimgRot = imrotate(BandWimg,45);
figure,imshow(BandWimgRot);
Fourier_spectrumImage_3= fft2(BandWimgRot);
fsh_3=fftshift(Fourier_spectrumImage_3);
figure,imshow(abs(fsh_3),[]);
log_scale_3 = log(abs(fsh_3)+1);
figure, imshow(log_scale_3,[]);

=>when we run the code we get


% Q2.4
phase_BandWimg = angle(fsh);
figure, imshow(phase_BandWimg,[]);
phase_BandWimg_2 = angle(fsh_2);
figure, imshow(phase_BandWimg_2,[]);
phase_BandWimg_3 = angle(fsh_3);
figure, imshow(phase_BandWimg_3,[]);

=>when we run the code we get


%Q 3.1
MRI_Img=imread('T1W_MR_image.jpg');
MRI_gray_Img=rgb2gray(MRI_Img);
figure, imshow(MRI_Img);
noisy_img =imnoise(MRI_gray_Img, 'salt & pepper',0.061);
figure, imshow(noisy_img);
median_by_3Window = medfilt2(noisy_img,[3 3]);
figure, imshow(median_by_3Window);
median_by_5Window = medfilt2(noisy_img,[5 5]);
figure, imshow(median_by_5Window);
median_by_7Window = medfilt2(noisy_img,[7 7]);
figure, imshow(median_by_7Window);
Avarage_fil = fspecial('average',3);
avgFiltimage = imfilter(MRI_gray_Img, Avarage_fil,'replicate');
figure,imshow(avgFiltimage);

=>when we run the code we get

% Q3.2
imageCell=imread('cell.bmp');
figure,imshow(imageCell);
imageFibers2=imread('fibers2.jpg');
figure,imshow(imageFibers2);
Avarage_fil_1 = fspecial('average',3);
avgFiltcell = imfilter(imageCell, Avarage_fil_1,'replicate');
figure,imshow(avgFiltcell);
gauusian_filt_1 = fspecial('gaussian',10,3);
gauusian_filtCell_1 = imfilter(imageCell, gauusian_filt_1 ,'replicate');
figure,imshow(gauusian_filtCell_1);
Avarage_filfiber_1 = fspecial('average',3);
avgFiltfiber = imfilter(imageFibers2, Avarage_filfiber_1,'replicate');
figure,imshow(avgFiltfiber);
gauusian_filtfibber_1 = fspecial('gaussian',10,3);
gauusian_filtFibber_1 = imfilter(imageFibers2,gauusian_filtfibber_1,'replicate');
figure,imshow(gauusian_filtFibber_1);

=>when we run the code we get

% Q 3.3
%Sharpening using fspecial
shareping_fill = fspecial('unsharp');
sharped_mri = imfilter(avgFiltimage,shareping_fill,'replicate');
figure, subplot(2,1,2),imshow(sharped_mri);
subplot(2,1,1),imshow(avgFiltimage);

laplacian_fil = fspecial('laplacian',0.1);
lap_smoothed = imfilter(MRI_gray_Img,laplacian_fil,'replicate');
sharped_mri_2 = imfilter(lap_smoothed,shareping_fill,'replicate');
figure, subplot(2,1,1),imshow(lap_smoothed);
subplot(2,1,2),imshow(sharped_mri_2);

=>when we run the code we get

You might also like