Domanda

I'm trying to display live video from an external camera using the function "movie" after performing a 2x binning. My original video size is 768x576. However, when I bin my pixels, I get a 384x288 image that, when it's displayed, will look half the size of my original video. Is there any way I can increase the displayed size of the movie such that it looks the same size as the original? In other words, my pixel would look twice the size.

I have tried using set(gca,'Position'...) but it doesn't change the size of my movie.

Any suggestion?

È stato utile?

Soluzione

I'll use the example movie as found on 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 help movie, it says:

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

Thus, there is no way to display the movie at a bigger size than at which is was recorded. You'll have to blow up the pixels to make it display at 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)

Note that this won't win any prizes for readability, so if you're going to use this, please include a comment describing what it does.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top