You are on page 1of 9

PROGRAMMING IN MATLAB

„ Image Capturing.
„ Image Processing..
„ Object Identification…
„ Movement Algorithm….
„ Output to Printer Port…..

Copyright ® IIT Guwahati


Robotics Club
Image Capturing.

„ Make an video input object.


„ Set various attributes of the object.
„ Take Snap Shots.
„ Save images in an array.

Copyright ® IIT Guwahati


Robotics Club
Image Capturing.
imaqreset;
imaqmem(inf);
vid=videoinput('winvideo',1,'RGB24_320x240');
set(vid,'FramesPerTrigger',Inf);
triggerconfig(vid, 'Immediate');
start(vid);

for ui=1:20
f=getsnapshot(vid);
imview(f);
flushdata(vid);
end
stop(vid);
Copyright ® IIT Guwahati
Robotics Club
Image Capturing.
„ Construct a video input object.
„ obj = videoinput('matrox', 1);

„ Select the source to use for acquisition.

„ set(obj, 'SelectedSourceName', 'input1')

„ View the properties for the selected video


source object. src_obj = getselectedsource(obj);
„ get(src_obj)
Copyright ® IIT Guwahati
Robotics Club
Image Capturing.
„ Preview a stream of image frames.
„ preview(obj);

„ Acquire and display a single image frame.

„ frame = getsnapshot(obj);
„ image(frame);

„ Remove video input object from memory.

delete(obj);
Copyright ® IIT Guwahati
„ Robotics Club
Image Processing..
„ imread : to read an image
eg i=imread(‘name.jpg’);
„ imview : to view the image
eg imview(i);
„ im2bw : converts a coloured image to black and white
eg b=im2bw(i);
or b=im2bw(i,.4);
„ edge : returns edges in an image
eg e=edge(b); this returns a matrix or image with only the
edges, in e.
Copyright ® IIT Guwahati
Robotics Club
Image Processing..

RGB components
„ For example, the red, green, and blue color
components of the pixel (10,5) are stored in
RGB(10,5,1), RGB(10,5,2), and RGB(10,5,3),
respectively.
eg
a=imread(‘name.jpg’);
r=a(100,100,1);
g=a(100,100,2);
b=a(100,100,3); Copyright ® IIT Guwahati
Robotics Club
Image Processing..

„ imcrop
„ bwarea
„ bwareaopen
„ bwlabel
„ regionprops – area,centroid
„ imsubtract
Copyright ® IIT Guwahati
Robotics Club
Output to Printer Port…..

„ putvalue(dio,[0 1]);
„ Write the value 8 as a decimal value and
as a binary vector. putvalue(dio,8)
putvalue(dio,[0 0 0 1])

Copyright ® IIT Guwahati


Robotics Club

You might also like