Introduction to MATLAB
www.tripleninfotech.com
MATLAB Overview
What is MATLAB?
History of MATLAB
Who developed MATLAB
Why MATLAB was developed
Who currently maintains MATLAB
Strengths of MATLAB
Weaknesses of MATLAB
www.tripleninfotech.com
What is MATLAB?
Matlab = Matrix laboratory
problem-solving environment
Designed
for
computations, esp.
convenient
numerical
matrix manipulation,
but also DEs, stats, and graphics
Developed by Cleve Moler in 1970s as a
teaching tool
www.tripleninfotech.com
MATLAB
MATLAB is a program for doing numerical computation.
It was originally designed for solving linear algebra
type problems using matrices.
Its name is derived
from MATrix LABoratory.
MATLAB has since been expanded and now has built-in
functions for solving problems requiring data analysis,
signal processing, optimization, and several other
types of scientific computations.
It also contains
functions for 2-D and 3-D graphics and animation.
www.tripleninfotech.com
What is MATLAB?
Originally FORTRAN; now C++/Java
Can call external C/FORTRAN routines
Interpreted
Customized graphical-user-interface
building
Has many specialized functions (Toolboxes)
www.tripleninfotech.com
WHY MATLAB
Ease of use
Rapid prototyping/debugging of
sophisticated code
Can be used interactively
(scratchpad) or from scripts
www.tripleninfotech.com
HISTROY OF MATLAB
MATLAB gained popularity primarily
through word of mouth because it was
not officially distributed
In the 1980s, MATLAB was rewritten in
C with more functionality (such as
plotting routines)
www.tripleninfotech.com
CONTI
The Mathworks, Inc. was created in 1984
The Mathworks is now responsible for
development, sale, and support for MATLAB
The Mathworks is located in Natick, MA
The Mathworks is an employer that hires
co-ops through our co-op program
www.tripleninfotech.com
STRENGTH OF MATLAB
MATLAB is relatively easy to learn
MATLAB code is optimized to be relatively quick
when performing matrix operations
MATLAB may behave like a calculator or as a
programming language
MATLAB is interpreted, errors are easier to fix
Although primarily procedural, MATLAB does have
some object-oriented elements
www.tripleninfotech.com
WEAKNESS OF MATLAB
MATLAB is NOT a general purpose programming
language
MATLAB is an interpreted language (making it for
the most part slower than a compiled language
such as C++)
MATLAB is designed for scientific computation
and is not suitable for some things (such as
parsing text)
www.tripleninfotech.com
MATLAB GUI
Launch Pad / Toolbox
Workspace
Current Directory
Command History
Command Window
www.tripleninfotech.com
WORKSPACE
Allows access to data
Area of memory managed through the
Command Window
Shows Name, Size (in elements),
Number of Bytes and Type of Variable
www.tripleninfotech.com
LAUNCH PAD / TOOL
Will not be covered
Launch Pad allows you to start
help/demos
Toolbox is for use with specialized
packages (Signal Processing)
www.tripleninfotech.com
CURRENT DIRECTORY
MATLAB, like Windows or UNIX, has a
current directory
MATLAB functions can be called from
any directory
Your programs (to be discussed later)
are only available if the current directory
is the one that they exist in
www.tripleninfotech.com
COMMAND HISTROY
Allows access to the commands used
during this session, and possibly previous
sessions
Clicking and dragging to the Command
window allows you to re-execute previous
commands
www.tripleninfotech.com
COMMAND WINDOW
Probably the most important part of the
GUI
Allows you to input the commands that
will create variables, modify variables
and even (later) execute scripts and
functions you program yourself.
www.tripleninfotech.com
SIMPLE COMMANDS
who
whos
save
clear
load
www.tripleninfotech.com
WHO
who lists the variables currently in the
workspace.
As we learn more about the data
structures available in MATLAB, we will see
more uses of who
www.tripleninfotech.com
WHOS
whos is similar to who, but also gives size and
storage information
s = whos(...) returns a structure with these
fields name variable name size variable size
bytes number of bytes allocated for the array
class class of variable and assigns it to the
variable s. (We will discuss structures more).
www.tripleninfotech.com
SAVE
save saves workspace variables on disk
save filename stores all workspace variables
in the current directory in filename.mat
save filename var1 var2 ... saves only the
specified
workspace
variables
in
filename.mat. Use the * wildcard to save
only those variables that match the specified
pattern.
www.tripleninfotech.com
CLEAR
clear removes items from workspace,
freeing up system memory
Examples of syntax:
clear
clear
name
clear name1 name2 name3 ...
www.tripleninfotech.com
LOAD
load - loads workspace variables from
disk
Examples of Syntax:
load
load
filename
load filename X Y Z
www.tripleninfotech.com
MATLAB FUNCTION
Functions are similar to scripts
Functions may take arguments
Functions may return one or more values
www.tripleninfotech.com
CONTI
Example function
function [output] = square(input)
output = input*input;
Body of functions can contain code just like
scripts could
www.tripleninfotech.com
MATH FUNCTION
Elementary functions (sin, cos, sqrt, abs,
exp, log10, round)
type
help elfun
Advanced functions (bessel, beta,
gamma, erf)
help specfun
type help elmat
type
www.tripleninfotech.com
GRAPH FUNCTIONS
plot linear plot
stem discrete plot
grid add grid lines
xlabel add X-axis label
ylabel add Y-axis label
title add graph title
subplot divide figure window
figure create new figure window
pause wait for user response
www.tripleninfotech.com
GETTING HELP
Using the Help Browser (.html, .pdf)
View getstart.pdf, graphg.pdf, using_ml.pdf
Type
help
help function, e.g. help plot
Running demos
type demos
type help demos
www.tripleninfotech.com
ARITHMATIC OPERATIONS
1) plus
- Plus
+
2) uplus
- Unary plus
+
3) minus
- Minus
4) uminus
- Unary minus
5) mtimes
- Matrix multiply
*
6) times
- Array multiply
.*
7) mpower
- Matrix power
^
8) power
- Array power
.^
9) mldivide - Backslash or left matrix divide
10) mrdivide - Slash or right matrix divide
11) ldivide - Left array divide
.\
12) rdivide - Right array divide
./
www.tripleninfotech.com
\
/
RELATIONAL OPERATIONS
1) eq
- Equal
- Not equal
==
2)
ne
3)
lt
4)
gt
- Greater than
>
5)
le
- Less than or equal
<=
6)
ge
- Less than
www.tripleninfotech.com
- Greater
than or equal
~=
<
>=
LOGICAL OPERATORS
1)Short-circuit logical AND
&&
2)Short-circuit logical OR
||
3) and
- Element-wise logical AND
or
not
xor
any
nonzero
8) all
nonzero
4)
5)
6)
7)
- Element-wise logical OR
|
- Logical NOT
~
- Logical EXCLUSIVE OR
- True if any element of vector is
- True if all elements of vector are
www.tripleninfotech.com
&
BITWISE OPERATORS
1) bitand
2)
bitcmp
3)
bitor
4)
bitmax
5)
6)
7)
8)
- Bit-wise AND.
- Complement bits.
- Bit-wise OR.
- Maximum floating point
integer.
bitxor
- Bit-wise XOR.
bitset
- Set bit.
bitget
- Get bit.
bitshift - Bit-wise shift.
www.tripleninfotech.com
COMMAND SYNTAX
MATLAB is case-sensitive. All built-in commands are
in lower case. A command normally terminates with a
carriage return. Including a semicolon (;) at the end
of
a command suppresses MATLABs echoing to the
terminal (this is useful when dealing with large sets of
numbers.)
www.tripleninfotech.com
FILE I/0
fopen
fclose
fprintf
fgetl / fgets
www.tripleninfotech.com
VECTORS & matrix
A = [5,8,2,3,2,4,7,2,8,9,8,3,0,3] ;
S=[3,8,9;2,7,7;4,9,0];
www.tripleninfotech.com
Save and load variable
A=5;
save A A;
load A
B=1;
C=A+B;
disp(C);
www.tripleninfotech.com
graph
Clc
close all
clear all
t=0:0.25:7;
y = sin(t);
plot(t,y,'r--') ;
xlabel('Time');
ylabel('Frequency');
title('sin wave');
grid on;
gtext('X axis 1 cm = 1');
gtext('Y axis 1 cm = 0.2');
legend('contious sinwave');
print -djpeg075 sinwave.jpg
www.tripleninfotech.com
IF LOOP
a=5;
if a > 6
disp('a is greater');
elseif a==0
disp('a is zero');
else
disp('a is smaller');
end
www.tripleninfotech.com
FOR LOOP
a=5;
for i=1:5
a=a+1
end
disp(a);
ANS a =10
www.tripleninfotech.com
While Loop
a=5;
while a < 10
a=a+1;
end
disp(a);
Ans a =10
www.tripleninfotech.com
Function
function c=add(a,b);
c=a+b;
return
function c=mul(a,b);
c=a*b;
return
Main
a=5;
b=6;
c=add(a,b);
disp(c);
d=mul(a,b);
disp(d);
www.tripleninfotech.com
Sample Program
load noissin;
figure;
plot(noissin);
figure;
c=cwt(noissin,1:10:500,'db4','plot');
www.tripleninfotech.com
Signal generation
t=0:0.01:4;
x=sin(2*pi*t);
x=cos(2*pi*t);
figure;
plot(t,x);
axis([0 2 -1 1]);
xlabel('Time (sec)');
ylabel('amplitude (Volt)');
figure;
tem(t,x);
xis([0 5 -1 1]);
xlabel('Time (sec)');
ylabel('amplitude (Volt)');
www.tripleninfotech.com
Exponential sequence
n=input('enter the length of exponential sequence =');
t=0:n;
a=input('Enter a value =');
y=exp(a*t);
figure;
stem(t,y);
axis([0 4 0 10]);
xlabel('Time (sec)');
ylabel('Amplitude (volt)');
title('Exponential Signal');
www.tripleninfotech.com
Ramp Sequence
n=input('Enter the length of sequence=');
t=0:n;
figure;
stem(t,t);
xlabel('samples (n)-->');
ylabel('Amplitude (volt)');
title('Ramp Sequence');
www.tripleninfotech.com
Unit Step Sequence
n=input('Enter the length of sequence =');
t=1:n;
y=ones(1,n);
stem(t,y);
xlabel('samples (n)-->');
ylabel('Amplitude (volt)');
title('Unit Step Sequence');
www.tripleninfotech.com
Unit Impulse Sequence
n=input('Enter the length of sequence =');
t= -n:1:n;
y=[zeros(1,n),ones(1,1),zeros(1,n)];
stem(t,y);
xlabel('samples (n)-->');
ylabel('Amplitude (volt)');
title('Unit Impulse Sequence');
www.tripleninfotech.com
Signal with noise
t = (0:0.001:1)';
y = sin(2*pi*50*t) + 2*sin(2*pi*120*t);
randn('state',0);
yn = y + 2*randn(size(t));
plot(t(1:50),yn(1:50));
www.tripleninfotech.com
Sawtooth waveform
t=0:.001:1;
x=sawtooth(2*pi*50*t);
plot(t,x);
axis([0 .2 -1 1]);
www.tripleninfotech.com
Square waveform
t=0:.01:10
x=square(t,15);
plot(t,x);
www.tripleninfotech.com
Triangular waveform
t=-3:.1:3
y=tripuls(t);
plot(t,y);
www.tripleninfotech.com
Rectangular waveform
t=-3:.1:3;
y=2*rectpuls(t);
plot(t,y);
axis([-3 3 0 3]);
www.tripleninfotech.com
How to read an image
a =imread('cameraman.tif');
imshow(a);
pixval on;
a =imread('flowers.tif');
imshow(a);
pixval on;
www.tripleninfotech.com
How to read an audio file
a =wavread ('test.wav');
wavplay(a,44100);
Plot(a);
www.tripleninfotech.com
How to read an video file
a=aviread('movie.avi');
movie(a);
www.tripleninfotech.com
Add two images
I = imread(rice.png');
J = imread('cameraman.tif');
K = imadd(I,J);
imshow(K,[])
I = imread('rice.png');
J = imadd(I,50);
subplot(1,2,1), imshow(I)
subplot(1,2,2), imshow(J)
www.tripleninfotech.com
Subtract two images
I = imread('rice.png');
Iq = imsubtract(I,50);
subplot(1,2,1), imshow(I)
subplot(1,2,2), imshow(Iq)
www.tripleninfotech.com
Convert image to gray and binary
clc;
clear;
close all
a= imread('flowers.tif');
subplot(2,2,1);
imshow(a);
subplot(2,2,2);
b=imresize(a,[256 256]);
imshow(b);
subplot(2,2,3);
c=rgb2gray(b);
imshow(c);
subplot(2,2,4);
d=im2bw(c);
imshow(d);
www.tripleninfotech.com
RGB component
a=imread('flowers.tif');
subplot(2,2,1);
imshow(a);
[r c p]=size(a)
R=a;
G=a;
B=a;
R(:,:,2:3)=0;
subplot(2,2,2);
imshow(R);
G(:,:,1)=0;
G(:,:,3)=0;
subplot(2,2,3);
imshow(G);
B(:,:,1)=0;
B(:,:,2)=0;
subplot(2,2,4);
imshow(B);
www.tripleninfotech.com
Convert Image into One dimensional
a = imread('cameraman.tif');
[r c]=size(a);
Len=r*c;
b=reshape(a,[1 Len]);
www.tripleninfotech.com
CONVER MOVIE TO FRAMES
file=aviinfo('movie1.avi');
% to get inforamtaion abt video
file
frm_cnt=file.NumFrames
% No.of frames in the video file
str2='.bmp'
h = waitbar(0,'Please wait...');
for i=1:frm_cnt
frm(i)=aviread(filename,i); % read the Video file
frm_name=frame2im(frm(i)); % Convert Frame to image file
frm_name=rgb2gray(frm_name);%convert gray
filename1=strcat(strcat(num2str(i)),str2);
imwrite(frm_name,filename1);
waitbar(i/frm_cnt,h)
% Write image file
www.tripleninfotech.com
CONVERT FRAMES TO MOVIES
frm_cnt=5;
number_of_frames=frm_cnt;
filetype='.bmp';
display_time_of_frame=1;
mov = avifile('MOVIE.avi');
count=0;
for i=1:number_of_frames
name1=strcat(num2str(i),filetype);
a=imread(name1);
while count<display_time_of_frame
count=count+1;
imshow(a);
F=getframe(gca);
mov=addframe(mov,F);
end
count=0;
end
mov=close(mov);
www.tripleninfotech.com
How to read a text file
fid = fopen('message.txt','r');
ice1= fread(fid);
s = char(ice1');
fclose(fid);
disp(s);
Ans hello
www.tripleninfotech.com
How to write a text file
txt=[65 67 68 69];
fid = fopen('output.txt','wb');
fwrite(fid,char(txt),'char');
fclose(fid);
ANS =ACDE
www.tripleninfotech.com
Store an Image,Audio
a =imread('cameraman.tif');
imwrite(a,'new.bmp');
a=wavread('test.wav');
wavwrite(d,44100,16,'nTEST.WAV');
www.tripleninfotech.com
SAVE AND LOAD THE VARIABLE
A=5;
save A A;
load A
B=1;
C=A+B;
disp(C);
www.tripleninfotech.com
NOISE AND FILTER
I = imread('eight.tif');
J = imnoise(I,'salt & pepper',0.02);
K = medfilt2(J);
subplot(1,2,1);imshow(J)
subplot(1,2,2);imshow(K)
www.tripleninfotech.com
M FILE & FUNCTION
CREATION
www.tripleninfotech.com
There are four ways of doing code in
Matlab
terminal window
script M-file
function M-file
.mex files
www.tripleninfotech.com
Terminal window
This method of doing calculations is
good for short.
one-time-only
calculations
or
for
calculations where one does not wish to
change any parameters.
www.tripleninfotech.com
M file window
If we wish to execute repeatedly some
set of commands, and possibly change
input parameters as well, then one
should create a script M-file
A MATLAB script file is called as M-file.
The file is saved with the extension ".m".
When the file is run", the script is
carried out.
www.tripleninfotech.com
Block Diagram of MATLAB
Series
of
Matlab
comma
nds
Matlab
Command
Dat
m-files
mat-files
Line
a
Command
sto
execution
Input functions
rag
like
DOS
Output
e/
command
loa
capabil
window
www.tripleninfotech.com
din
ity
Function M file window
Most of the M-file that one ultimately
uses will be function M-file
These files again have the .m"
extension.
Function files have input and output
arguments.
www.tripleninfotech.com
Conti
The syntax
definition is:
for
MATLAB
function
function [val1, , valn] = myfunc (arg1,
, argk)
where val1 through valn are the specified
returned values from the function.
arg1 through argk are the values sent to
the function.
www.tripleninfotech.com
Conti
The word function appears at the start of
the file, and in lower case letters.
Function files are normally used to
combine functions in Matlab to get new
functions.
If it is not, the directory must be
changed before calling the function.
www.tripleninfotech.com
Conti..
If MATLAB cannot find the function or its
syntax does not match the function call,
an error message will appear.
Failure to change directories often
results in the error message:
Undefined function or improper matrix
assignment
www.tripleninfotech.com
Conti..
When the function file is not in the
current working directory, a cd or chdir
command may be issued to change the
directory.
cd E:\ OR
chdir E:\.
www.tripleninfotech.com
IMAGE PROCESSING
www.tripleninfotech.com
What is an Image
An image is an array, or a matrix, of
square pixels (picture elements)
arranged in columns and rows.
www.tripleninfotech.com
Types of image
Black & white
Grayscale
RGB or Color image
www.tripleninfotech.com
Image format
JPEG (Joint Pictures Expert Group)
GIF (Graphic Interchange Format)
TIFF (Tagged Image File Format)
PNG (Portable Network Graphics)
JPEG2000
BMP(Windows Bitmap)
www.tripleninfotech.com
Binary or Black & White Image
Binary: Each pixel
is just black or
white. Since there
are
only
two
possible
values
for
each
pixel
(0,1), we only
need one bit per
pixel.
www.tripleninfotech.com
Grayscale Image
Each pixel is a
shade of gray,
normally from 0
(black) to 255
(white).
This range means
that each pixel
can
be
represented
by
eight
bits,
or
www.tripleninfotech.com
exactly one byte.
Color or RGB Image
Each pixel has a particular
color; that color is described
by the amount of red, green
and blue in it.
If each of these components
has a range 0255, this gives
a total of 2563 different
possible colors. Such an
image is a stack of three
matrices; representing the
red, green and blue values
for each pixel.
This means that for every
pixel there correspond 3
values.
www.tripleninfotech.com
Conti
The secondary colors of
RGB cyan, magenta, and
yellow are formed by
mixing two of the primary
colors (red, green or blue)
and excluding the third
color.
Red and green combine to
make yellow, green and
blue to make cyan, and blue
and red form magenta.
The combination of red,
green, and blue in full
intensity makes white.
www.tripleninfotech.com
Rotate image
a=imread(cameraman.tif)
figure
imshow(a)
b=imrotate(a,45)
figure
imshow(b)
www.tripleninfotech.com
Resize image
a=imread(sunset.jpg)
figure
imshow(a)
b=imresize(a,10)
figure
imshow(b)
www.tripleninfotech.com
Cropping an image
a=imread(winter.jpg)
figure
imshow(a)
b=imcrop(a,[10 20 30 40])
figure
imshow(b)
www.tripleninfotech.com
Complement image
z=imread(desret.jpg)
figure
imshow(z)
g=imcomplement(z)
figure
imshow(g)
www.tripleninfotech.com
Histogram an image
a=imread(cameraman.tif)
figure
imhow(a)
j=histeq(a)
figure
imshow(j)
www.tripleninfotech.com
IMTOOL
Image Display tool for performing basic
image processing task
The tools are,
Pixel region tool, Distance tool, Adjust
contrast, Crop tool, Image information
Example
imtool(peppers.png);
www.tripleninfotech.com
Indexed Image
The syntax are ,
[X map]= rgb2ind(rgb,n);
[X map]=gray2ind(gray,n);
It gives pixel intensities and color map
values. n is size of color map.
It is used to increase the color resolution
of image.
rgb=ind2rgb(X,map);
gray=ind2gray(X,map);
www.tripleninfotech.com
RGB->Indexed and gray->indexed
a = imread(peppers.png);
[x map]=rgb2ind(a, 10);
figure;
imshow(x,map);
b=imread(rice.png);
[x1 map1]=gray2ind(b,50);
figure;
imshow(x1,map1);
www.tripleninfotech.com
Color space conversions
Three color models :
HSV
YCbCr
YIQ
Computer display screen depth
>>get(0,ScreenDepth);
www.tripleninfotech.com
Example
rgb=imread(peppers.png);
hsv=rgb2hsv(rgb);
figure;
imshow(hsv);
Yc=rgb2ycbcr(rgb);
Yi=rgb2ntsc(rgb);
figure; imshow(Yc);
figure; imshow(Yi);
www.tripleninfotech.com
Image Enhancement
a=imread(pout.tif);
figure; subplot(2,1,1); imshow(a);
subplot(2,1,2); imhist(a);
b=imadjust(a);
figure; subplot(2,1,1); imshow(b);
subplot(2,1,2); imhist(b);
c=histeq(a);
figure; subplot(2,1,1); imshow(c);
subplot(2,1,2); imhist(c);
d=adapthisteq(a);
figure; subplot(2,1,1); imshow(d);
www.tripleninfotech.com
subplot(2,1,2); imhist(d);
OVERVIEW
REGION OF INTEREST
DEBLURRING
EDGE DETECTION
www.tripleninfotech.com
Region of Interest
a=imread(pout.tif);
Figure;imshow(b);
b=roipoly(a);
figure;
imshow(b);
[r c]=find(b==1);
xmin=min(r);xmax=max(r);
ymin=min(c);ymax=max(c);
D=a(xmin:xmax,ymin:ymax);
Figure;imshow(d);www.tripleninfotech.com
Roipoly Example
a=imread(coins.png);
figure;imshow(a);
b=roipoly(a);
loc=find(b==1); loc1=find(b ~= 1);
pri=zeros(r,c); pri(loc)=a(loc);
sec=zeros(r,c); sec(loc1)=a(loc1);
figure;
imshow(pri,[]);
figure;
imshow(sec,[]); www.tripleninfotech.com
Roicolor example
a=imread(rice.png);
Figure(1);
imshow(a);
b=roicolor(a,170,210);
Figure(2);
imshow(b);
www.tripleninfotech.com
Roifill Example
a=imread(pout.tif);
figure(1);
Imshow(a);
bw=roipoly(a);
c=roifill(a,bw);
figure(2);
Imshow(c);
www.tripleninfotech.com
Roifilter example
a=imread(pout.tif);
figure(1);
Imshow(a);
bw=roipoly(a);
F=fspecial(unsharp);
Out=roifilt2(F,a,bw);
figure(2);
Imshow(Out);
www.tripleninfotech.com
Blurring effect on image
a=imread(peppers.png);
figure(1); imshow(a);
H = fspecial('motion',20,45)
Blurred =imfilter(a,H,circular);
figure(2);
imshow(Blurred);
title('Motion Blurred Image');
www.tripleninfotech.com
Deblurring
a=imread(peppers.png);
figure(1); imshow(a);
H = fspecial('motion',20,45)
Blurred =imfilter(a,H,circular);
figure(2);
imshow(Blurred);
title('Motion Blurred Image');
De=deconvwnr(Blurred,H);
figure(3);
www.tripleninfotech.com
Imshow(De);
Image analysis
a=imread(peppers.png);
figure(1); imshow(a);
P=impixel(a);
disp(P);
a=imread(coins.png);
Figure(1); imshow(a);
b=improfile;
Disp(b);
a=imread(rice.png);
imcontour(a,2);
title(Contour plot); www.tripleninfotech.com
IMAGE PROCESSING
TECHNOLGIES &
APPLICATIONS
www.tripleninfotech.com
Digital Image
Processing?...
An image can be defined as a two-dimensional
signal (analog or digital), that contains
intensity (grayscale), or color information
arranged along an x and y spatial axis.
Histogram, Co-Variance, Mean, Standard
Deviation these are all the some basic
calculation
process
in
Digital
Image
Processing.
Classification,
Resizing,
Extraction,
Recognition these are all the some basic
Process.
www.tripleninfotech.com
Current Trends in Digital Image
Processing in Different Applications
Technologies
Compression
Steganography
Applications
Transmission & Storage
Secret Communications
Watermarking
Copyright Protection
Segmentation
Medical & Image Classifications
Image Retrieval
Web Applications
Recognition
Fusion
De-noising
Authentication
Medical & Satellite
Digital Cameras & Video codec
www.tripleninfotech.com
Compression
The Process to remove the Redundancy (Duplication) in Image
Types of Compression
Lossless Compression
Data
can be completely recovered after decompression
Recovered
Lossy Compression
Data
cannot be completely recovered after decompression
Some
data is identical to original
information is lost for ever
Applications
All Multimedia Equipments such as Mobiles, DVD Players, TV, PC,
etc..,
www.tripleninfotech.com
Compression Block Diagram
B
I
Input Image
Quantization
Entropy Encoding T
S
T
R
E
Reconstructed
De-quantization Decoding
A
Image
M
S
www.tripleninfotech.com
Steganography
Hiding a Secret data in Digital Images without affecting the
quality of Medium.
This image is called as StegoImage.
Original Image
Stego Image
Application
Send secret communication
like Military applications
www.tripleninfotech.com
Steganography Block Diagram
Original
Image
Preproces
s
Original
Image
Embeddin
g in Image
Stegoimag
e
Secret
Data
Extraction
from
Stegoimage
Secret
Data
www.tripleninfotech.com
Watermarking
Water Marking Embed the secret image in an image or
any type of multimedia data.
We should hide the image without changing original
image quality.
Water marking is used only for copyright protection.
Types of Water Marking
Visible & Invisible
Applications
In telebroadcasting & web applications
www.tripleninfotech.com
Watermarking Block Diagram
Input Image
Copyright Image
DWT
Key
Embedding Process
Water Marked Image
www.tripleninfotech.com
Watermarking Extraction
Copyright Image
Water Marked Image
IDWT
Key
Extraction Process
Copyright output Image
www.tripleninfotech.com
Segmentation
Segmentation refers to the process of partitioning a digital image into
multiple regions (sets of pixels).
The goal of segmentation is to simplify and/or change the representation
of an image into something that is more meaningful and easier to
analyze.
Each of the pixels in a region are similar with respect to some
characteristic or computed property, such as color, intensity, or texture.
Applications
In
Medical applications to find brain tumor, cancer detection & classify
the images in different domains
www.tripleninfotech.com
Image Retrieval
Image retrieval techniques are useful in many imageprocessing applications.
In Image retrieval systems so many techniques are there.
Color Histogram based IR
Metadata based IR
Shape based IR
Applications
In web & medical applications to search particular image
form large database
www.tripleninfotech.com
Fusion
Image Fusion is the process of combining relevant
information from two or more images into a single image.
The fused image should have more complete information
which is more useful for human or machine perception.
The resulting image will be more informative than any of
the input images.
Applications
Where we need the high information images in that
places like Medical & Satellite etc..,
www.tripleninfotech.com
Basic Diagram of Image Fusion
www.tripleninfotech.com
Simulation &
Implementation
www.tripleninfotech.com
Simulation Result for
Steganography
www.tripleninfotech.com
Original Image & StegoImage
www.tripleninfotech.com
Fusion for Medical Application
www.tripleninfotech.com
Fusion
www.tripleninfotech.com
Simulation Result for Image
Retrieval
www.tripleninfotech.com
Searching Process
www.tripleninfotech.com
Input Video
www.tripleninfotech.com
Compressed Video
www.tripleninfotech.com
www.tripleninfotech.com
TRANSFORMATION
Discrete Cosine Transform (DCT)
Discrete Wavelet Transform (DWT)
www.tripleninfotech.com
Discrete Cosine Transform
The DCT is similar to the DFT since it
decomposes a signal into a series of
harmonic cosine functions.
It is sum of cosine function at different
frequency.
Cosine function are much more effective
compared to sine function.
It is dependent on time or frequency.
www.tripleninfotech.com
Conti..
Here It separates the Image to number of
blocks.
In these blocks first block has the low frequency
information.
We can see clear information in low frequency
sub band
DC
w
lo
horizontal edges
www.tripleninfotech.com
fr
cy
n
ue
q
e
vertical edges
le c y
d
i d u en
m eq
fr
Conti
The 2-D DCT and its inverse (IDCT) of an
N x N block are shown below:
2-D-DCT
N 1 N 1
2
(2 x 1)u
(2 y 1)v
F (u , v) C (u )C (v) f ( x, y ) cos[
] cos[
]
N
2N
2N
y 0 x 0
2-D-IDCT
2
f ( x, y )
N
(2 x 1)u
(2 y 1)v
C (u )C (v) F (u, v) cos[
] cos[
]
2N
2N
v 0 u 0
N 1 N 1
www.tripleninfotech.com
Conti
One disadvantage of DCT has blocking
artifacts, due to Zigzag error during
reconstruction of image.
Itll overcome by wavelet transform.
www.tripleninfotech.com
Conti
a=imread('cameraman.ti
f');
subplot(1,3,1);
imshow(a,[]);
title(Input image)
b=dct2(a);
subplot(1,3,2);
imshow(b,[]);
title('DCT');
c=idct2(b);
subplot(1,3,3);
imshow(c,[]);
www.tripleninfotech.com
Discrete Wavelet Transform
It has higher compression ratios avoid
blocking artifacts.
It is convert spatial domain to frequency
domain.
It is a type of signal representation that
can give the frequency content of the
signal at a particular instant of time or
spatial location.
www.tripleninfotech.com
Conti
Allows good localization both in time and
spatial frequency domain.
It has more efficiency compare with DCT.
www.tripleninfotech.com
DWT Calculation Procedure
Even + odd
Even + odd
Even odd
Image
Even - odd
HL
Even + odd
LL
LH
Even odd
www.tripleninfotech.com
HH
Conti..
a=imread('cameraman.tif')
;
[LL LH HL
HH]=dwt2(a,'haar');
Dec=[...
LL,LH
HL,HH
...
];
imshow(Dec,[]);
www.tripleninfotech.com
GUI
www.tripleninfotech.com
DIALOG BOX
warndlg('hello');
helpdlg('hello');
msgbox('hello');
www.tripleninfotech.com
errordlg('hello');
ButtonName=questdlg('What is your wish?', ...
'Genie Question', ...
'Food','Clothing','Money','Money');
switch ButtonName,
case 'Food',
disp('Food is delivered');
case 'Clothing',
disp('The Emperor''s new clothes have arrived.')
case 'Money',
disp('A ton of money falls out the sky.');
end % switch
www.tripleninfotech.com
USER INTERFACE GET FILE
[filename, pathname] = uigetfile('*.m', 'Pick an
M-file');
if isequal(filename,0) | isequal(pathname,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(pathname,
filename)])
end
www.tripleninfotech.com
USER INTERFACE PUT FILE
[filename, pathname] = uiputfile('*.m', 'Pick an M-file');
if isequal(filename,0) | isequal(pathname,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(pathname, filename)])
end
www.tripleninfotech.com
GUI
www.tripleninfotech.com
GET IMAGE FILE
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject
% eventdata reserved - to be defined in a future version of MATLAB
% handles
[filename, pathname] = uigetfile('*.jpg', 'Pick an Image');
handle to pushbutton1 (see GCBO)
structure with handles and user data (see GUIDATA)
if isequal(filename,0) | isequal(pathname,0)
warndlg('User pressed cancel')
else
M1 = imread( filename);
handles.M1 = M1;
axes(handles.axes1);
imshow(M1);
handles.filename1=filename;
%Update handles structure
guidata(hObject, handles);
end
www.tripleninfotech.com
GUI
www.tripleninfotech.com
MENU BAR
www.tripleninfotech.com
PUSH BUTTON
www.tripleninfotech.com
TOGGLE BUTTON
www.tripleninfotech.com
RADIO BUTTON
www.tripleninfotech.com
CHECKBOX
www.tripleninfotech.com
EDIT TEXT
www.tripleninfotech.com
STATIC TEXT
www.tripleninfotech.com
SLIDER
www.tripleninfotech.com
FRAME
www.tripleninfotech.com
LISTBOX
www.tripleninfotech.com
POPUP MENU
www.tripleninfotech.com
AXES
www.tripleninfotech.com
ALIGN OBJECTS
www.tripleninfotech.com
MENU EDITOR
www.tripleninfotech.com
M FILE EDITOR
www.tripleninfotech.com
PROPERTY INSPECTOR
www.tripleninfotech.com
www.tripleninfotech.com
RUN
www.tripleninfotech.com
EMPTY GUI
www.tripleninfotech.com
GENERATED M FILE
www.tripleninfotech.com
PUSH BUTTON
www.tripleninfotech.com
RIGHT CLICK PUSH BUTTON & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
RIGHT CLICK PUSH BUTTON & GO FOR M
FILE EDITOR
www.tripleninfotech.com
GO FOR CALLBACK
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
a =imread('cameraman.tif');
imshow(a);
www.tripleninfotech.com
RUN THE PROGRAM OR PRESS F5
www.tripleninfotech.com
CHOOSE AXES
www.tripleninfotech.com
CHOOSE AXES
www.tripleninfotech.com
RIGHT CLICK AXES & GO FOR PROPERTY
INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
a =imread('cameraman.tif');
axes(handles.one);
imshow(a);
www.tripleninfotech.com
RUN THE PROGRAM
www.tripleninfotech.com
CODE
a =imread('cameraman.tif');
axes(handles.one);
imshow(a);
www.tripleninfotech.com
TOGGLE BUTTON
www.tripleninfotech.com
RIGHT CLICK TOGGLE & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
RIGHT CLICK TOGGLE & GO FOR M FILE
EDITOR
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
a=get(hObject,'Value');
if a ==1
a =imread('cameraman.tif');
axes(handles.one);
imshow(a);
else
a =imread('greens.jpg');
axes(handles.one);
imshow(a);
end
www.tripleninfotech.com
RUN THE PROGRAM
www.tripleninfotech.com
RIGHT CLICK RADIO BUTTON & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
RIGHT CLICK CHECK BOX & GO FOR MFILE
EDITOR
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
www.tripleninfotech.com
RUN THE PROGRAM
www.tripleninfotech.com
RIGHT CLICK CHECK BOX & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
RIGHT CLICK CHECK BOX & GO FOR M FILE
EDITOR
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
www.tripleninfotech.com
RUN THE PROGRAM
www.tripleninfotech.com
RIGHT CLICK FRAME & SEND TO
BACK
www.tripleninfotech.com
RUN THE PROGRAM
www.tripleninfotech.com
RIGHT CLICK LIST BOX & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
EDIT THE STRING OPTIONS
www.tripleninfotech.com
RIGHT CLICK LIST BOX & GO FOR M FILE
EDITOR
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
contents = get(hObject,'Value')
switch contents
case 1
a =imread('cameraman.tif');
axes(handles.one);
imshow(a);
case 2
a =imread('flowers.tif');
axes(handles.one);
imshow(a);
case 3
a =imread('rice.tif');
axes(handles.one);
imshow(a);
otherwise
a =imread('mri.tif');
axes(handles.one);
imshow(a);
end
www.tripleninfotech.com
CHOOSE POPUPMENU
www.tripleninfotech.com
RIGHT CLICK POPUP MENU & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
EDIT THE STRING OPTIONS
www.tripleninfotech.com
WRITE THE CODE
contents = get(hObject,'Value')
switch contents
case 1
a =imread('cameraman.tif');
axes(handles.one);
imshow(a);
case 2
a =imread('flowers.tif');
axes(handles.one);
imshow(a);
case 3
a =imread('rice.tif');
axes(handles.one);
imshow(a);
otherwise
a =imread('mri.tif');
axes(handles.one);
imshow(a);
end
www.tripleninfotech.com
RIGHT CLICK EDIT TEXT & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
EDIT STRING AND TAG
www.tripleninfotech.com
RIGHT CLICK EDIT TEXT & GO FOR M FILE
EDITOR
www.tripleninfotech.com
RIGHT CLICK AXES & GO FOR PROPERTY
INSPECTOR
www.tripleninfotech.com
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
a=get(hObject,'String') ;
b=char(a);
c=imread(b);
axes(handles.one);
imshow(c);
www.tripleninfotech.com
RIGHT CLICK STATIC TEXT & GO FOR
PROPERTY INSPECTOR
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
a=get(hObject,'String') ;
set(handles.t1,'String',a);
b=char(a);
c=imread(b);
axes(handles.one);
imshow(c);
www.tripleninfotech.com
SLIDER
www.tripleninfotech.com
RIGHT CLICK SLIDER & GO FOR PROPERTY
INSPECTOR
www.tripleninfotech.com
DROP TWO AXES
www.tripleninfotech.com
DROP PUSH BUTTON
www.tripleninfotech.com
CHANGE THE STRING AND TAG
VALUE
www.tripleninfotech.com
GO FOR CALLBACK
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
[filename, pathname] = uigetfile('*.bmp', 'Pick an Image');
if isequal(filename,0) | isequal(pathname,0)
warndlg('User pressed cancel')
else
a=imread(filename);
axes(handles.axes1);
imshow(a);
handles.filename=filename;
guidata(hObject, handles);
end
www.tripleninfotech.com
RIGHT CLICK SLIDER & GO FOR M FILE
EDITOR
www.tripleninfotech.com
www.tripleninfotech.com
WRITE THE CODE BELOW THE
CALLBACK
www.tripleninfotech.com
RUN THE PROGRAM
a=get(hObject,'Value');
filename =handles.filename;
I = imread(filename);
J = imadd(I,50);
axes(handles.axes2);
imshow(J)
www.tripleninfotech.com
MENU EDITOR
www.tripleninfotech.com
www.tripleninfotech.com
EDIT STRING AND TAG
www.tripleninfotech.com
RUN
www.tripleninfotech.com
Further contact
E-Mail:tripleninfotech@gmail.com
project@tripleninfotech.com
Contact No
+91-9566234284
+91-9566763284
Like Facebook page
https://www.facebook.com/tripleninfotechiee
eprojecs
www.tripleninfotech.com
CORPORATE OFFICE ADDRESS
Triple N Infotech-Chennai
Triple N Infotech-Trichy
No 33,(Old No 14/1),
No 73/5, 3rd Floor,
First Floor,
Kamachi Complex,
Madley Road,
Opp City Hospital,
T.Nagar
Salai Road,
Chennai-17
Trichy-18
044-42868371
0431-4050403
9566234284
7200021404
www.tripleninfotech.com
www.tripleninfotech.com
www.tripleninfotech.com