【问题标题】:Dimension of a movie generated from VideoWriter: 420x560x3?从 VideoWriter 生成的电影的尺寸:420x560x3?
【发布时间】:2014-06-03 18:28:12
【问题描述】:

我正在尝试使用 VideoWriter 函数下的一系列函数在 Matlab 中创建电影。我的代码有点像下图:

vidObj=VideoWriter('movie.avi');
open(vidObj);

for i=1:N %N is number of frames

[nx,ny]=coordinates(Lx,Ly,Nx,Ny,[x(i),-y(i)]);
%Lx and Ly refer to the length and height in meters. 
%Nx and Ny are number of pixels (boxes) and fit into the respective L's. 
%If Lx=10e-6 , with Nx=5, there will be 5 pixels in x dimension,
%each of length 2e-6 m.
[xf,yf]=ndgrid(nx,ny);
zf=zeros(size(xf))+z(i);    

% generate a frame here
[E,H]=nfmie(an,bn,xf,yf,zf,rad,ns,nm,lambda,tf_flag,cc_flag);
Ecc=sqrt(real(E(:,:,1)).^2+real(E(:,:,2)).^2+real(E(:,:,3)).^2+imag(E(:,:,1)).^2+imag(E(:,:,2)).^2+imag(E(:,:,3)).^2);
clf
imagesc(nx/rad,ny/rad,Ecc)
rectangle('Position',[-rad(end),-rad(end),dia(end),dia(end)],'Curvature',[1,1]);
axis image;
axis off;
currFrame=getframe(gcf);
writeVideo(vidObj,currFrame);
end
close(vidObj);
toc
return

这生成了一个名为movie.avi 的电影。但是,影片(以及从命令窗口生成的 tif 图像)的尺寸为“420x560x3”。我不明白它是怎么来的。请帮忙!! 并提前感谢您。

【问题讨论】:

    标签: matlab video dimensions


    【解决方案1】:

    视频的每一帧都有 420 x 560 像素,每个像素都有一个 RGB 值,存储为 3 个数字。例如:

    CurrFrame(120, 300) = [0 0 0]
    

    将使第 120 x 300 像素变为白色。并且:

    CurrFrame(120, 300) = [1 0 0]
    

    会使相同的像素变成鲜红色。

    您获得的尺寸是单个帧或图像的尺寸。

    【讨论】:

    • 感谢您的回复。这真的很有帮助。但是,我希望您不介意在这里回答另一个问题。我需要将此 420x560x3 tif 文件转换为 2D tif(或 jpeg)文件,以进行进一步的图像处理,我该怎么做?再次感谢您,我假设它会给我 420x560。你能帮我解决这个问题吗?
    • 如果您的意思是将其保存为文件:imwrite(CurrFrame, 'filename.tif', 'tif') 否则,我不确定您要做什么。该图像实际上不是“3D”,因此不需要任何转换。
    • 另外,您可能需要一些时间来制定您想问的确切问题,并将其作为一个单独的问题提出。我会回答的。
    • 谢谢@Fletch。这是我的问题:stackoverflow.com/questions/24029187/…
    猜你喜欢
    • 2014-07-24
    • 1970-01-01
    • 1970-01-01
    • 2021-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多