mardi 12 août 2014

Faussé le résultat de la création d'un fichier avi dans matlab à partir d'une matrice de trames d'images (distorsion : cadres tourné vers la droite)-Stack Overflow


I have a 192x334x106 matrix which I would to convert to an avi file, however after multiple efforts I am still encountering a distorted output.


My problem is similar to that reported here:


However the fix suggested there, doesn't work for me. Here is the code:


aviobj = avifile('MOVIE2.avi');
fig = figure;
for frame_idx = 1:size(imstack,3)
image = double(imstack(:,:,frame_idx));
rgb = repmat(image,[1 1 3]);
imshow(rgb);
axis off;
aviobj = addframe( aviobj, getframe( fig ) );
end;
aviobj = close( aviobj );
implay( 'MOVIE2.avi' );

Inspired from this post: I also tried the following using instead the VideoWriter function:


f = figure();
a = axes('Parent',f);
axis(a,'tight');
set(a,'nextplot','replacechildren');
aviobj = VideoWriter('MOVIEN.avi','Uncompressed AVI');
vid.Quality = 100;
aviobj.FrameRate = 8;

open(aviobj)

for frame_idx = 1:size(imstack,3)
image = double(imstack(:,:,frame_idx));
rgb = repmat(image,[1 1 3]);
%imshow(rgb);
f = imagesc(rgb);
axis off;
writeVideo(aviobj ,rgb)
end;

But the result was the same: right-ward `shearing' effect.


(extra information: My data is the output of an 3D image processing algorithm, it was not produced on a frame by frame basis)


Matlab version R2012a (7.14.0.739) Size of input matrix: <192x334x106> (Making the matrix square does not effect the output) Size of output avi file: 43MB


Thanks in advance,


Neil.


An addendum: Strange things are happening; when I view the movie using VLC, the distortion is evident, when I uploaded the avi to vimeo to demonstrate it here, the movie plays perfectly. I am extremely confused.



I have a 192x334x106 matrix which I would to convert to an avi file, however after multiple efforts I am still encountering a distorted output.


My problem is similar to that reported here:


However the fix suggested there, doesn't work for me. Here is the code:


aviobj = avifile('MOVIE2.avi');
fig = figure;
for frame_idx = 1:size(imstack,3)
image = double(imstack(:,:,frame_idx));
rgb = repmat(image,[1 1 3]);
imshow(rgb);
axis off;
aviobj = addframe( aviobj, getframe( fig ) );
end;
aviobj = close( aviobj );
implay( 'MOVIE2.avi' );

Inspired from this post: I also tried the following using instead the VideoWriter function:


f = figure();
a = axes('Parent',f);
axis(a,'tight');
set(a,'nextplot','replacechildren');
aviobj = VideoWriter('MOVIEN.avi','Uncompressed AVI');
vid.Quality = 100;
aviobj.FrameRate = 8;

open(aviobj)

for frame_idx = 1:size(imstack,3)
image = double(imstack(:,:,frame_idx));
rgb = repmat(image,[1 1 3]);
%imshow(rgb);
f = imagesc(rgb);
axis off;
writeVideo(aviobj ,rgb)
end;

But the result was the same: right-ward `shearing' effect.


(extra information: My data is the output of an 3D image processing algorithm, it was not produced on a frame by frame basis)


Matlab version R2012a (7.14.0.739) Size of input matrix: <192x334x106> (Making the matrix square does not effect the output) Size of output avi file: 43MB


Thanks in advance,


Neil.


An addendum: Strange things are happening; when I view the movie using VLC, the distortion is evident, when I uploaded the avi to vimeo to demonstrate it here, the movie plays perfectly. I am extremely confused.


0 commentaires:

Enregistrer un commentaire