Resize a movie in Matlab

I am trying to display live video from an external camera using the movie function after doing 2x binning. My original movie size is 768x576. However, when I load my pixels, I get a 384x288 image that, when displayed, will look half the size of my original video. Is there a way to increase the displayed size of the movie so that it looks the same as the original? In other words, my pixel will look twice as large.

I tried using set(gca,'Position'...) but it does not resize my movie.

Any suggestion?

+4
source share
1 answer

I will use an example movie as shown in the documentation .

Suppose you have a bunch of frames:

 figure('Renderer','zbuffer') Z = peaks; surf(Z); axis tight set(gca,'NextPlot','replaceChildren'); % Preallocate the struct array for the struct returned by getframe F(20) = struct('cdata',[],'colormap',[]); % Record the movie for j = 1:20 surf(.01+sin(2*pi*j/20)*Z,Z) F(j) = getframe; end 

At the end of the help movie it says:

MOVIE (H, M, N, FPS, LOC) defines the place to play the movie in, relative to the lower left corner of the H object and in pixels, regardless of the value of the Units object property. LOC = [XY not used unused]. LOC is a 4-element vector position of which only the X and Y coordinates are used (the movie is played using the width and height at which it was recorded).

Thus, it is not possible to display a movie of a larger size than when recording. You will have to explode the pixels to display them at a larger size:

 % blow up the pixels newCdata = cellfun(@(x) x(... repmat(1:size(x,1),N,1), ... % like kron, but then repmat(1:size(x,2), N,1), :), ... % a bit faster, and suited {F.cdata}, 'UniformOutput', false); % for 3D arrays % assign all new data back to the movie [F.cdata] = newCdata{:}; % and play the resized movie movie(F,10) 

Please note that this will not win reading prizes, so if you intend to use it, provide a comment describing what it does.

+2
source

Source: https://habr.com/ru/post/1442739/


All Articles