`
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Computer Vision Lab (7CAI4-22)
List of Experiments
Implementing various basic image processing operations in Python/Matlab/open-CV:
1. Reading images, writing image, conversion of images, and complementing of an image.
2. Implement contrast adjustment of an image. Implement Histogram processing and
equalization.
3. Use of Fourier transform for filtering the image.
4. Utilization of SIFT and HOG features for image analysis.
5. Performing/Implementing image segmentation.
6. Object detection and Recognition on available online image datasets using the YOLO
Model.
Beyond Syllabus:
1. Implementation of image restoring techniques
2. Implementation of Image Intensity slicing technique for image enhancement
3. Canny edge detection Algorithm
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Lab Objective and Outcome
Objective
The primary aim of this course is to provide essential and hands-on knowledge about computer
vision components and to cultivate the necessary skills for image processing, applicable both in
industry and research settings.
Key objectives of the course include:
1. Introducing fundamental terminology, technology, and its practical applications.
2. Exploring the concept of image processing and its essential operations.
3. Familiarizing students with Matlab, a versatile tool for image-related operations.
4. Introducing various datasets available on different platforms, widely used for analysis in
the field of image processing.
5. Guiding students in the practical implementation of image processing techniques using
both online and offline image datasets.
By the end of this course, students will be equipped with a solid foundation in computer vision,
image processing techniques, and the practical tools required for success in this field.
Course Outcomes
After completion of this course, students will be able to –
7CAI4-22.1 Explain the concept and Application of image processing for computer vision.
7CAI4-22.1 Illustrate key technologies and implement Histogram processing and
Equalization for an image.
7CAI4-22.1 Implement and Analyze the Fourier transform for filtering the image.
7CAI4-22.1 Application for performing and implementing different methods of image
segmentation
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
7CAI4-22.1 Design an Image processing application project using YOLO Model online
datasets.
Experiment – 1
Aim: Reading images, writing image, conversion of images, and complementing of an image.
Reading an Image
To import an image from any supported graphics image file format, in any of the supported
bit depths, use the imread function.
Syntax
A = imread(filename,fmt)
Description
A = imread(filename,fmt) reads a greyscale or color image from the file specified by the
string filename, where the string fmt specifies the format of the file. If the file is not in the
current directory or in a directory in the MATLAB path, specify the full pathname of the
location on your system.
Display An Image
To display iamge, use the imshow function.
Syntax
imshow(A)
Description
imshow(A) displays the image stored in array A.
Writing Image Data
Imwrite
Write image to graphics file
Syntax
imwrite(A,filename,fmt)
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Writing Image Data
Imwrite
Write image to graphics file
Syntax
imwrite(A,filename,fmt)
Example:
a=imread('pout.tif');
imwrite(a,gray(256),'b.bmp');
imshow('b.bmp')% imshow is used to display image
Writing Image to Disk
How to get no. of rows and columns of image
Function size gives the rows and columns dimension of image
[r,c]=size(a)
r = 291
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
c =240
Accessing the Pixel data
There is a one-to-one correspondence between pixel coordinates and the coordinates
MATLAB® uses for matrix subscripting. This correspondence makes the relationship between
an image's data matrix and the way the image is displayed easy to understand. For example, the
data for the pixel in the fifth row, second column is stored in the matrix element (5,2). You use
normal MATLAB matrix subscripting to access values of individual pixels. For example, the
MATLAB code
A(2,15)
returns the value of the pixel at row 2, column 15 of the image A.
MIRROR IMAGE GENERATION
% this program produces mirror image of the image passed to it n also
% displays both the original and mirror image
a=imread('pout.tif');
[r,c]=size(a);
for i=1:1:r
k=1;
for j=c:-1:1
temp=a(i,k);
result(i,k)=a(i,j);
result(i,j)=temp;
k=k+1;
end
end
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
subplot(1,2,1),imshow(a)
subplot(1,2,2),imshow(result)
Source Image and resultant One
TASK 1
Write a MATLAB code that reads a gray scale image and generates the flipped image of original
iamge. Your output should be like the one given below
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Source Image with Desired Output
******************************************************************
TASK 2
Write a MATLAB code that will do the following
1. Read any grayscale image.
2. Display that image.
3. Again display the image such that the pixels having intensity values below than 50 will display
as black and pixels having intensity values above than 150 will display as white. And the pixels
between these will display as it is.
8
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Experiment – 2
Aim: Implement contrast adjustment of an image. Implement Histogram processing and
equalization.
% Image Enhancement
I=imread('cancercell.jpg');
subplot(4,2,1); imshow(I); title('Original Image');
g=rgb2gray(I);
subplot(4,2,5); imshow(g); title('Gray Image');
J=imadjust(g,[0.3 0.7],[]);
subplot(4,2,3); imshow(J); title('Enhanced Image');
D= imadjust(I,[0.2 0.3 0; 0.6 0.7 1],[]);
subplot(4,2,4);imshow(D);title('Enhanced Image 2');
% Histogram and Histogram Equalization
subplot(4,2,7); imhist(g); title('Histogram of Gray Image');
m=histeq(g);
subplot(4,2,6); imshow(m); title('Equalized Image');
subplot(4,2,8); imhist(m); title('Histogram of Equalized
Image');
9
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
10
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Experiment – 3
Aim: Use of Fourier transform for filtering the image.
% Read an image
originalImage = imread('example.jpg'); % Replace 'example.jpg' with your image file
% Convert the image to grayscale if it's in color
if size(originalImage, 3) == 3
originalImage = rgb2gray(originalImage);
end
% Display the original image
subplot(2, 3, 1);
imshow(originalImage);
title('Original Image');
% Compute the 2D Fourier Transform of the image
fourierTransform = fft2(double(originalImage));
% Shift the zero frequency components to the center
fourierTransformShifted = fftshift(fourierTransform);
% Create a simple low-pass filter (e.g., a circular mask)
[M, N] = size(originalImage);
radius = 50; % Adjust the radius to control the filter size
[x, y] = meshgrid(1:N, 1:M);
centerX = N/2;
centerY = M/2;
mask = (x - centerX).^2 + (y - centerY).^2 <= radius^2;
11
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
% Apply the filter by multiplying it with the Fourier Transform
filteredTransform = fourierTransformShifted .* mask;
% Shift the frequency components back to their original positions
filteredTransformShifted = ifftshift(filteredTransform);
% Compute the inverse Fourier Transform to get the filtered image
filteredImage = ifft2(filteredTransformShifted);
% Display the filtered image
subplot(2, 3, 2);
imshow(abs(filteredImage), []);
title('Filtered Image');
% Display the magnitude of the Fourier Transform
subplot(2, 3, 3);
imshow(log(1 + abs(fourierTransformShifted)), []);
title('Magnitude of Fourier Transform');
% Display the filter mask
subplot(2, 3, 4);
imshow(mask, []);
title('Filter Mask');
% Display the phase of the Fourier Transform
subplot(2, 3, 5);
imshow(angle(fourierTransformShifted), []);
title('Phase of Fourier Transform');
12
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
% Display the phase of the filtered image
subplot(2, 3, 6);
imshow(angle(filteredImage), []);
title('Phase of Filtered Image');
% Wait for user input before closing the figure
pause;
close;
In the above code, we added two additional subplots to display the phase of both the Fourier
Transform and the filtered image. This will help you visualize both the magnitude and phase
changes resulting from the filtering process.
Original Image:
13
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
14
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
VISION (SKIT)
“To Promote Higher Learning in Advanced Technology and Industrial Research to make our
Country a Global Player”
MISSION (SKIT)
“To Promote Quality Education, Training and Research in the field of Engineering by establishing
effective interface with Industry and to encourage Faculty to undertake Industry Sponsored
Projects for Students”
QUALITY POLICY (SKIT)
“We are committed to ‘achievement of quality’ as an integral part of our institutional policy by
continuous self-evaluation and striving to improve ourselves.
Institute would pursue quality in:
➢ All its endeavors like admissions, teaching-learning processes, examinations, extra and co-
curricular activities, industry-institution interaction, research & development, continuing
education, and consultancy.
➢ Functional areas like teaching departments, training & placement cell, library,
administrative office, accounts office, hostels, canteen, security services, transport,
maintenance section and all other services.”
15
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
Vision and Mission of CSE Department
VISION (CSE Department)
“Producing quality graduates trained in the latest tools and technologies and to be a leading
department in the state and region by imparting in-depth knowledge to the students in an emerging
technologies in computer science & engineering.”
MISSION (CSE Department)
“Delivering Student’s resources in IT enabled domain through:
➢ Effective Industry interaction and project based learning
➢ Motivating our graduates for Employability, entrepreneurship, research and higher education
➢ Providing excellent engineering skills in a state-of-the-art infrastructure”
DEPARTMENT OF COMPUTER SCIENCE& ENGINEERING
Program Educational Objectives (PEOs)
Graduate of the CSE Program will be:
• Prepared to be employed in IT industries and be engaged in learning, understanding, and
applying new ideas.
• Able to apply their technical knowledge as practicing professionals or engage in graduate
education.
• Prepared to be responsible computing professionals in their own area of interest.
• Working successfully in their chosen career individually and within a professional team
environment.
Program Outcomes for CSE Department
PO1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals,
and an engineering specialization to the solution of complex engineering problems.
PO2: Problem analysis: Identify, formulate, research literature, and analyze complex engineering problems
reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering
sciences.
PO3: Design/development of solutions: Design solutions for complex engineering problems and design
system components or processes that meet the specified needs with appropriate consideration for the public
health and safety, and the cultural, societal, and environmental considerations.
PO4: Conduct investigations of complex problems: Use research-based knowledge and research methods
including design of experiments, analysis and interpretation of data, and synthesis of the information to
16
Lab Manual 7CAI4-22 (Computer Vision Lab) SKIT, Ramnagaria, Jagatpura, Jaipur
provide valid conclusions.
PO5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with an
understanding of the limitations.
PO6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,
health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional
engineering practice.
PO7: Environment and sustainability: Understand the impact of the professional engineering solutions in
societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable
development.
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering practice.
PO9: Individual and teamwork: Function effectively as an individual, and as a member or leader in diverse
teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the engineering
community and with society at large, such as, being able to comprehend and write effective reports and
design documentation, make effective presentations, and give and receive clear instructions.
PO11: Project management and finance: Demonstrate knowledge and understanding of the engineering
and management principles and apply these to one’s own work, as a member and leader in a team, to manage
projects and in multidisciplinary environments.
PO12: Life-long learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
Program Specific Outcomes for CSE Department
PSO1: Graduates will possess strong fundamental concepts on database technologies, Operating systems,
advanced programming, Software engineering and other core subjects.
PSO2: Graduates will demonstrate an ability to design, develop, test, debug, deploy, analyze, troubleshoot,
maintain, manage and secure the software.
PSO3: Graduates will possess the knowledge of institutions / organizations / companies related to computer
science & engineering.
17