Professional Documents
Culture Documents
It is also mostly & very widely used in the field of medical &
space research works.
SENSORS
Analogous to human sensory organs: Eyes,
ears, nose, tongue, skin
Help robot to know its surroundings better
Improves its actions and decision making
ability
Provides feedback control.
CAMERA VISION
CCD
Higher quality images with little noise
Typically more pixels
Higher sensitivity to light
CMOS
Lower cost
Easier to build
Lower power consumption
USB 1.1 - USB was the first widespread high speed method of data transfer
from cameras. It is theoretically capable of transfer speeds up to 11
megabits/second (note megabits not megabytes)
USB 2.0 - A development of USB but much faster - up to 480
megabits/second.
IEEE 1394 (Firewire) - Though this is an older interface than USB, it was
originally only really used much on Apple computers. It's capable of high
speed transfer (400 megabits/second) and it's now found on some PCs or
it can be added to them via a plug-in card. More common on digital video
cameras than still digital cameras.
EXPLORING 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 is an interpreter -> not as fast as
compilers.
File extension for MATLAB is .m
INTRODUCTION TO MATLAB
VARIABLES:
Variable names can contain up to 63 characters
Variable names must start with a letter followed by letters, digits,
and underscores.
Variable names are case sensitive
Special variables: ans
Default variable name for results
pi
Value of
eps
Smallest incremental number
inf
Infinity
NaN
Not a number e.g. 0/0
Realmin
The smallest usable positive real number
realmax
The largest usable positive real number
Disp
displays the contents of a variable
MATHEMATICAL OPERATIONS
& : and
| : or
~ : not
< : less than
<= : less than or equal to
> : greater than
>= : greater than or equal to
== : equal
~= : not equal
SIGNAL REPRESENTATION
EXAMPLE:
> n=-5:0.5:5;
> x(n)=exp(j*(0.4*pi*n-0.5*pi));
> y(n)=x(n)-x(n-1);
> stem(y,n)
% sampling frequency
% setup time from 0 to 1 second
% input frequency
% input signal
% plot the signal
% plot the signal using stem
ARRAY OPERATION
The Matlab array arithmetic operations are:
addition (+)
subtraction (-)
>> A = [ 1 2; 3 4], B = [5 6; 7 8]
>> A.*B
>> A.^2
>> A./B
>> size(A); The result gives the size of A, i.e., the number of
rows and columns.
>> sum(A) ; This function calculates the column sums in a
rectangular array A and gives the sums in a row vector. (A column
sum is the sum of the elements of a column.) If A is a row vector,
then the sum of the elements of A is calculated. The function
>> prod(A); does the same for the product.
Other Array operations are:
transpose()
> greater than
>= greater than or equal to
<= lower than or equal to
STRING OPERATION
A string matrix is like any other, except the
elements in it are interpreted as ASCII
numbers.
To create a string variable, enclose a string of
characters in single quotation marks
Ex: stg = 'This is a string';
x = ['ab' ; 'cd']
x = ['ab' 'cd']
MATRIX OPERATION
Matlab treats all variables as matrices. For our purposes a
matrix can be thought of as an array, in fact, that is how it is
stored.
Vectors are special forms of matrices and contain only one
row OR one column.
Scalars are matrices with only one row AND one column.
A matrix with only one row is called a row vector. A row
vector can be created in Matlab as follows (note the
commas):
rowvec = [12 , 14 , 63]
rowvec =
12 14 63
A(i,j)
Accessing Multiple Elements of a Matrix
sum(A(:,end))
X(:,2) = []
Concatenating Matrices A and B
C=[A;B]
X = A
X = inv(A)
d = det(A)
[X,D] = eig(A)
% Transposed matrix
% Inverse matrix squared matrix
% Determinant
% Eigenvalues and eigenvectors
MATRIX FUNCTIONS:
ones
ones matrix
zeros
zeros matrix
size
size of a matrix
diag
diagonal elements of a matrix
inv
matrix inverse
rand
uniformly distributed random numbers
randn
normally distributed random numbers
cumprod
cumulative product of elements
max
largest component
min
smallest component
sum
sum of elements
mean
average or mean value
median
median value
std
standard deviation
sort
sort in ascending order
find
find indices of nonzero entries
corrcoef
correlation coefficients
cov
covariance matrix
TYPES OF IMAGE
Monochrome
An image displayed in a single color or shades of a single color.
Least memory requirement
Also known as 1-bit image, each pixel is stored as a bit.
Gray Scale
A grayscale (or graylevel) image is simply one in which the only colors are shades of gray.
Processing is faster & easier.
Also known as 8-bit image, each pixel is usually stored as a byte (value between 0 to 255) .
Colored
A (digital) color image is a digital image that includes color information for each pixel.
It is the combination of the 3- primary colors (RGB).
Also known as 24- bit image, each pixel contains 3 values i.e. R, G & B-value.
PIXEL
Short for Picture Element,
A single point in a graphic image.
RESOLUTION
900 pixels 300ppi
= 3 inches wide
600 pixels 300ppi
= 2 inches high
TEXTURE
The feel of a surface or a fabric
Texture mapping is a method for adding details
or color to a computer generated graphic or 3-D model.
DIFFERENT CONCEPTS
Luminance
The amount of brightness.
Chrominance
Same chrominance ,
different luminance
Hue
The property of colors by which they can be perceived as ranging
from red through yellow, green, and blue, as determined by the
dominant wavelength of the light.
Same luminance,
different chrominance
Intensity/Saturation
The strength of a color, especially the degree to which it lacks its complementary color.
Color Space:
RGB - Red Green Blue
CMYK - Cyan Magenta Yellow Black
HSV - Hue Saturation Value
Printing applications
Y luminance
I Hue (Orange Blue range)
Q Saturation (Purple Green range)
Defined by NTSC
- luminance
Cb & Cr
- Chrominance Information
Cr
IMPORTING IMAGE
There are two possible ways of importing image:
Using webcam with Image Acquisition Tool box
Example:
>> image=vfm(grab);
>> imshow(image);
Using the stored image from the hard disk
>> image=imread(ball.jpg);
>> imshow (image);
Example:
N.B.: Before using this you have to store ball.jpg in the current directory.
IMAGE REPRESENTATION
You can store/save an image by using imwrite();
Grayscale
True color RGB
Indexed
Binary
8-bit images/Unit8
Filling an ROI
Filling is a process that fills a region of interest
(ROI) by interpolating the pixel values from the
borders of the region.
>> I = imread('ballgray.bmp');
>> imshow(I);
>> I2 = roifill;
>> imshow(I2);
IMAGE MATRIX
Any image (supported format) can be stored in MATLAB in
the form of a matrix.
To show how an image is being stored in a matrix:
>> I = imread('balls.bmp');
>> size(I)
>> I(1:10,1:10)
Pre-processing
Decision
Making
Image acquisition
Feature extraction
Data
communication
'log
'motion
'prewitt
'sobel
THRESHOLDING
Thresholding is a non-linear operation that converts a gray-scale image
into a binary image where the two levels are assigned to pixels that are
below or above the specified threshold value.
You can apply a threshold to data directly from the command line,
e.g., BW = im2bw(I, level)
Automatically calculate a threshold value using an iterative method. >>
>>x=imread('balls.bmp');
>> x=imread('balls.bmp');
>> BW = im2bw(x,0.4);
>> Y = zeros(194,250);
>> imshow(x), figure, imshow(BW)
>> for(i=1:194)
>>for(j=1:250)
>>if(x(i,j) > 50)
>>Y(i,j) = 1;
>>end
>>end
>>end
>> imshow(Y);
IMAGE ARITHMATIC
Scanner resolution
Film grain (granularity)
Hardware (interference patterns)
Other
Modeling of noise:
The function imnoise allows different types of noise
to be modeled.
Syntax:
J = imnoise(I,type,parameters)
I Image
type gaussian, localvar, poisson, salt & pepper, speckle
parameters additional parameters needed
given the type of noise
Median filtering
When noise causes the pixels to vary greatly from the original value (salt and
pepper), a median filter is more effective in reducing the noise.
Adaptive filtering
This type of filter is effective in reducing the effects of Gaussian whitenoise.
EDGE DETECTION
Edge detection is nothing but a filtering process.
The edge function of the Image Processing Toolbox makes it easy to
perform edge detection.
Followings are the different edge detection functions:
sobel
prewitt
roberts
log (laplacian)
Roberts Mask
Prewitts Mask
Sobel Mask
HARDWARE DETAILS
CMOS webcam:
Parallel port:
Parallel port has 25 pins Pins 2-9 are bi-directional data pins (pin 9 gives the most
significant bit (MSB)), pins 10-13 and 15 are output pins (status pins), pins
1,14,16,17 are input pins (control pins), while pins 18-25 are Ground pins.
CONT.
Distinguishing between
BG color & ball color by
setting proper threshold value
Problematic situation:
Can
be tackled by selecting appropriate threshold
Dia.
for i1=1:r
for i2=1:c
if (image_cr(i1,i2)>cr &&
image_cb(i1,i2)<cb)
output_image(i1,i2)=1;
else
output_image(i1,i2)=0;
end
end
end
imshow(output_image)
if (r_cent<90)
disp('forward()');
forward();
stop();
forward();
stop();
elseif (r_cent>150)
disp('back()');
back();
stop();
back();
stop();
else
stop();
disp('stop');
end
end
end
for i=1:500
for j=1:500
for k=1:x %if u give x=420 u will get a
delay of 1 second.
end
end
end
%toc
imshow(output_image)
[r_cent c_cent]=centroid1(output_image);
total_pix=sum(sum(output_image));
disp(total_pix);
if(total_pix<7000)
% stop();
disp('No Line');
else
if (c_cent<120)
left();
left();
disp(left()');
disp(c_cent);
disp(r_cent);
if (r_cent<90)
back();
disp('back()');
disp(c_cent);
disp(r_cent);
elseif (r_cent>120)
forward();
stop();
forward();
stop();
disp('forward()');
disp(c_cent);
disp(r_cent);
else
disp('stop()');
disp(c_cent);
disp(r_cent);
end
end
end