Operácie

Robotic Vision

Z SensorWiki

Verzia z 22:43, 21. november 2015, ktorú vytvoril Balogh (diskusia | príspevky) (Matlab code)

Support page to the MOOC Course by Peter Corke

Matlab code

 im = iread('/path/to/image.jpg');
 idisp(im); // special display for the course from the vision package

Compare this

a = 100;
b = 200;

a+b
a-b 
a/b

a = uint8(100);
b = uint8(200);

a+b
a-b 
a/b

Getting an image from videocamera. Grab and display a image from the camera.

 cam = VideoCamera(0);
 im = cam.grab();
 clear cam // In order to turn the camera off, use the clear function.


Getting an image from movie.

cam = Movie('traffic_sequence.mpg');
cam.grab(); // next sequence image


Creating an image from code

Create a 200x200 matrix of zeros (representing black) and set the first (top, left) element to 1 (representing white). Display the image.

 im = zeros(200, 200);
 im(1,1) = 1;
 idisp(im)

 im(150:160,60:70) = 0.5;
 idisp(im)

 circle = kcircle(30);
 idisp(circle)

 im = ipaste(im, circle*0.7, [100 30]);
 idisp(im)

 im = iline(im, [30 40], [150 190], 0.9);
 idisp(im)

 im = testpattern('rampx', 200);
 idisp(im)

 im = testpattern('squares', 200, 50, 25);

 im = iread('monalisa.png', 'grey');
 about im
 idisp(im)

 im(194,276)
 ans = 26

 im2 = im(180:210,260:290);
 idisp(im2)

 lin = im(190,260:290);
 plot(lin)

 im3 = im(1:4:end,1:4:end);
 idisp(im3)

 im4 = im(end:-1:1,1:end);
 idisp(im4)