0% found this document useful (0 votes)
90 views4 pages

DIP Lab 03 Solution

The document describes Lab 02 on image processing in Matlab. The objectives are to introduce basic image processing functions in Matlab. Tools used include Matlab. Task 1 involves designing a GUI to load an image, binarize it with code, and convert it to grayscale with code. Task 2 involves designing a GUI to load an image and apply geometric transformations like cropping, resizing, rotating and translating by selecting the transformation from a dropdown and displaying the result.

Uploaded by

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

DIP Lab 03 Solution

The document describes Lab 02 on image processing in Matlab. The objectives are to introduce basic image processing functions in Matlab. Tools used include Matlab. Task 1 involves designing a GUI to load an image, binarize it with code, and convert it to grayscale with code. Task 2 involves designing a GUI to load an image and apply geometric transformations like cropping, resizing, rotating and translating by selecting the transformation from a dropdown and displaying the result.

Uploaded by

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

Digital Image Processing Lab

CEN-444

Lab Journal 03

Burhan Ahmed Satti


01-134172-065
BS CS 6-A

Department of Computer Science


BAHRIA UNIVERSITY, ISLAMABAD
Lab 02: Image Processing in Matlab

Objectives:

The aim of this introductory lab is to introduce you to the basic functions in the Matlab Image Processing
Toolbox. By the end of today’s lab, you should be able to handle forms

Tools Used:

Matlab

Submission Date:

Evaluation: Signatures of Lab Engineer:


Task # 3.1:
Design a Matlab GUI, to implement following operations:
• Loads image and display it in axis
• Push button that binarize image and display the image in other axis. Binarize image by code
instead of command im2bw(f,T) that you have already done in previous lab
• Push button that change image to grayscale and display the image in axis. Do it by code instead
of command mat2gray(A).
Procedure/Program:
function Binarizer_Callback(hObject, eventdata, handles)
Image = imread('peppers.png');
[height, width] = size(Image);
for i = 1: height
for j = 1: width
if uint8(Image(i, j)) <= 127
binzarized_rice_img(i, j) = 0;
else
binzarized_rice_img(i, j) = 1;
end
end
end
imshow(binzarized_rice_img, 'Parent', handles.axes3);
function GrayScale_Callback(hObject, eventdata, handles)
Image = imread('peppers.png');
[height, width, channels] = size(Image);
if channels == 3
for i = 1:height
for j = 1:width
grayscale(i, j) = uint8((Image(i, j, 1)+Image(i, j, 2)+Image(i, j, 3))/
3);
end
end
end
imshow(grayscale, 'Parent', handles.axes2);
function Load_Callback(hObject, eventdata, handles)
Image = imread('peppers.png');
imshow(Image, 'Parent', handles.axes1);
Result/Output:
Task # 3.2:
Design Matlab GUI which loads the image in axis and apply geometric transformation functions (crop,
resize,rotate,translate) by selecting from combo box and display all in axis. You can use Matlab commands for
geometric transformation functions.
Procedure/Program:
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
src_img = imread('rice.png');
v = get(handles.popupmenu2,'Value'); %get currently selected option from menu
if v == 1
cropped_img = imcrop(src_img, [10, 10, 100, 100]);
imshow(cropped_img, 'Parent', handles.axes1);
elseif v == 2
rotated_img = imrotate(src_img, 45);
imshow(rotated_img, 'Parent', handles.axes1);
elseif v == 3
translated_img = imtranslate(src_img, [10, 10]);
imshow(translated_img, 'Parent', handles.axes1);
end

Result/Output:

You might also like