I am trying to create a movie in Matlab using series of functions under VideoWriter function. My code is somewhat like one shown below:
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);
return
This generated a movie called movie.avi. However, the movie (and the tif images generated from command window) has the dimensions of "420x560x3".
edit: the tif's are generated from the movie.avi using the following code:
obj = VideoReader('movie.avi');
vid = read(obj);
frames = obj.NumberOfFrames;
for x = 1 : frames
imwrite(vid(:,:,:,x),strcat('frame-',num2str(x),'.tif'));
end
I am trying to use these images in another software, IDL, following: read Part 1 of this link
However, when runs on IDL, it detects the dimensions as [3x420x560], and therefore generates a really weird image when I run the normalization.
- How do I fix this? Is using imwrite going to help?
- I was able to successfully open the .tif in IDL, but it shows that the 420x560 is actually an image including an external grey boundary.
How do I remove this boundary? I tried seeing through my functions and they were fine. (I think)
I apologize in advance for asking so many questions. I am very new to this and need help. Thank you once again