Professional Documents
Culture Documents
Index: S.O. Name of Experiment Date No. Sign Remarks
Index: S.O. Name of Experiment Date No. Sign Remarks
Name of Page
S.o. Date Sign Remarks
EXPERIMENT No.
EXPERIMENT NO. 1
Introduction
MATLAB is a high-performance language for technical computing. It integrates computation,
visualization, and programming in an easy-to-use environment where problems and solutions are
expressed in familiar mathematical notation. Typical uses include:
● Math and computation
● Algorithm development
● Modeling, simulation, and prototyping
● Data analysis, exploration, and visualization
● Scientific and engineering graphics
● Application development, including Graphical User Interface building
MATLAB is an interactive system whose basic data element is an array that does not require
dimensioning. This allows you to solve many technical computing problems, especially those
with matrix and vector formulations, in a fraction of the time it would take to write a program in
a scalar noninteractive language such as C or Fortran.
The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide
easy access to matrix software developed by the LINPACK and EISPACK projects, which
together represent the state-of-the-art in software for matrix computation.
MATLAB has evolved over a period of years with input from many users. In university
environments, it is the standard instructional tool for introductory and advanced courses in
mathematics, engineering, and science. In industry, MATLAB is the tool of choice for
high-productivity research, development, and analysis.
MATLAB features a family of application-specific solutions called toolboxes. Very important to
most users of MATLAB, toolboxes allow you to learn and apply specialized technology.
Toolboxes are comprehensive collections of MATLAB functions (M-files) that extend the
MATLAB environment to solve particular classes of problems. Areas in which toolboxes are
available include signal processing, control systems, neural networks, fuzzy logic, wavelets,
simulation, and many others.
History
Cleve Moler, the chairman of the computer science department at the University of New Mexico,
started developing MATLAB in the late 1970s. He designed it to give his students access to
LINPACK and EISPACK without them having to learn Fortran. It soon spread to other
universities and found a strong audience within the applied mathematics community. Jack Little,
an engineer, was exposed to it during a visit Moler made to Stanford University in 1983.
Recognizing its commercial potential, he joined with Moler and Steve Bangert. They rewrote
MATLAB in C and founded MathWorks in 1984 to continue its development. These rewritten
libraries were known as JACKPAC. In 2000, MATLAB was rewritten to use a newer set of
libraries for matrix manipulation, LAPACK.
MATLAB was first adopted by researchers and practitioners in control engineering, Little's
specialty, but quickly spread to many other domains. It is now also used in education, in
particular the teaching of linear algebra, numerical analysis, and is popular amongst scientists
involved in image processing.
Syntax
Variables
The MATLAB® workspace consists of the variables you create and store in memory during a
MATLAB session. You can create new variables in the workspace by running MATLAB
code or using existing variables.
To create a new variable, enter the variable name in the Command Window, followed by an
equal sign (=) and the value you want to assign to the variable. For example, if you run
these statements, MATLAB adds the three variables x, A, and I to the workspace:
x = 5.71;
A = [1 2 3; 4 5 6; 7 8 9];
I = log10(100);
You do not have to declare variables before assigning values to them. MATLAB is a loosely
typed language. Specifying the data type of variable is not required. If you do not end the
assignment statement with a semicolon (;), MATLAB displays the result in the Command
Window.
1. Creating a matrix
>> a = [1 2 3; 4 5 6; 7 8 9; 10 11 12]
a =
1 2 3
4 5 6
7 8 9
10 11 12
a = 1 2 3 4
a =
5
4. Creating a square matrix
>> a = [1 2 3; 4 5 6; 7 8 9]
a =
1 2 3
4 5 6
7 8 9
a =
1 0 0
0 1 0
0 0 1
a =
0 0 0
0 0 0
0 0 0
a =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> A = [1 2 3; 4 5 6; 7 8 9]
A =
1 2 3
4 5 6
7 8 9
ans =
12 15 18
9. Transpose of a matrix
>>
A'
ans =
1 4 7
2 5 8
3 6 9
ans =
15
EXPERIMENT NO. 3
EXPERIMENT NO. 4
Aim : Reading and Displaying images using different color models
Convert RGB image to Grayscale image.
RGB = imread('E:\digital_image\football.jpg');
GRAY = rgb2gray(RGB);
figure, imshow(RGB);
figure, imshow(GRAY);
Figure 4.3 :Original IMAGE Figure 4.4 :Black and White IMAGE
Convert RGB image to NTSC pictures.
RGB = imread('E:\digital_image\messi.jpg');
figure, imshow(RGB);
NTSC = rgb2ntsc(RGB);
figure, imshow(NTSC);
EXPERIMENT NO. 5
Aim : Image enhancement using various transformations functions
Photographic negative (using imcomplement function)
I = imread('E:\digital_image\football.jpg');
NEGATIVE = imcomplement(I);
imshow(NEGATIVE);
I = imread('E:\digital_image\football.jpg');
figure, imshow(I);
GRAY = rgb2gray(I);
GRAY = double(GRAY);
LOG1 = 0.5*log10(1+GRAY);
figure, imshow(LOG1);
LOG2 = 0.2*log10(1+GRAY);
figure, imshow(LOG2);
EXPERIMENT 6
AIM : PERFORM ZOOMING AND SHRINKING OF IMAGE
matlab function imresize()
J = imresize(I,scale) returns image J that is scale times the size of grayscale, RGB, or binary
image I. If I has more than two dimensions, then imresize only resizes the first two dimensions
img = imread('E:\DIP\img.jpg');
bigger_img = imresize(img, 1.9);
smaller_img = imresize(img , 0.3);
imshow(img);
imshow(bigger_img);
Figure 6.2 :Zoomed IMAGE
imshow(smaller_img);
b) by interpolation method
Nearest neighbour interpolation is the simplest approach to interpolation. Rather than calculate
an average value by some weighting criteria or generate an intermediate value based on
complicated rules, this method simply determines the “nearest” neighbouring pixel, and assumes
the intensity value of it.
Bilinear Interpolation : is a resampling method that uses the distance weighted average of the
four nearest pixel values to estimate a new pixel value. The four cell centers from the input raster
are closest to the cell center for the output processing cell will be weighted and based on distance
and then averaged.
I = imread('D:\Image Processing\UlAvI.png');
Z = imresize(I, 2, 'nearest');
figure, imshow(Z);
Z = imresize(I, 2, 'bilinear');
figure, imshow(Z);
Z = imresize(I, 2, 'bicubic');
figure, imshow(Z);
we can also use 5*5 or 7*7 mask on the image as per our requirement.
We place a 3*3 mask on each pixel of an image.
We start from the left hand top corner. We cannot work with the borders and hence are normally
left as they are. We then multiply each component of the image with the corresponding value of
the mask.
Add these values to get the response.
Replace the center pixel of the output image with these response. We now shift the mask towards
the right till we reach the end of the line and then move it downwards.
Algorithm :
Conclusion :
Low mask filtering makes the image blurred.
img = imread('E:\DIP\img.jpg');
img = rgb2gray(img);
smooth_matrix = ones(5)/25;
smoothed_img = conv2(img, smooth_matrix, 'same');
imshow(smoothed_img);
Figure 7.1 :Original IMAGE
Theory : A high-pass filter can be used to make an image appear sharper. These filters
emphasize fine details in the image – exactly the opposite of the low-pass filter. High-pass
filtering works in exactly the same way as low-pass filtering; it just uses a different convolution
kernel. In the example below, notice the minus signs for the adjacent pixels. If there is no change
in intensity, nothing happens. But if one pixel is brighter than its immediate neighbors, it gets
boosted.
we can also use 5*5 or 7*7 mask on the image as per our requirement.
We place a 3*3 mask on each pixel of an image.
We start from the left hand top corner. We cannot work with the borders and hence are normally
left as they are. We then multiply each component of the image with the corresponding value of
the mask.
Add these values to get the response.
Replace the center pixel of the output image with these response. We now shift the mask towards
the right till we reach the end of the line and then move it downwards.
Algorithm :
1) read input image
2) ignore the border pixels
3) apply high mask to each and every pixel.
4) display the output image.
Conclusion :
High mask filtering makes the image sharpened.
img = imread('D:\Image Processing\einstien.jpg');
img = rgb2gray(img);
figure, imshow(img);
smooth_matrix = ones(3)/-9;
smooth_matrix(2,2) = 8/9;
smoothed_img = conv2(img, smooth_matrix, 'same');
figure, imshow(smoothed_img);
Figure 8.2 :Removing salt and pepper noise using various filters
EXPERIMENT NO. 9
newimg = imread('c:\\code\matlab\lilly.jpg');
I = rgb2gray(newimg);
BW_sobel= edge(I,'sobel',0.1) ;
BW_canny=edge(I,'canny',0.1);
BW_prew=edge(I,'prewitt',0.1);
figure
subplot(2,2,1), imshow(newimg);
title('Original Image');
subplot(2,2,2), imshow(BW_sobel);
title('Sobel');
subplot(2,2,3), imshow(BW_canny);
title('Canny');
subplot(2,2,4), imshow(BW_prew);
title('prewitt');
Conclusion: