- Specify the size of the output image
- Specify the interpolation method used
- Specify the filter to use to prevent aliasing
For this example however i will be using the Resize to set the size of the output
Using imresize, you can specify the size of the output image in two ways:
- By specifying the magnification factor to be used on the image
- By specifying the dimensions of the output image
Using the Magnification Factor. To enlarge an image, specify a magnification factor greater than 1. To reduce an image, specify a magnification factor between 0 and 1.
For example, the command below increases the size of the image I by 1.25 times.
I = imread('circuit.tif');The same can be done in Videos:
J = imresize(I,1.25);
imshow(I);
figure, imshow(J)
fin = 'rawVideo.avi'; fout = 'test.avi'; fileinfo = aviinfo(fin); nframes = fileinfo.NumFrames; aviobj = avifile(fout, 'compression', 'none', 'fps',fileinfo.FramesPerSecond); for i = 1:20 %Read frames from input video mov_in = aviread(fin,i); im_in = frame2im(mov_in); %Do processing on each frame of the video
%----------------------------------------------------------------------
%In this example - Image Resize enlarge 5 times
im_out = imresize(im_in,5);
%----------------------------------------------------------------------
%Write frames to output video frm = im2frame(im_out); aviobj = addframe(aviobj,frm); %i %Just to display frame number end; %Don't forget to close output file aviobj = close(aviobj); msgbox('DONE'); return;
The results:
No comments:
Post a Comment