Write images from matrices in a cell array? Error?!

1 view (last 30 days)
Hi,
I have a cell in which several 320*320*3 matrices a stored. I would like to convert these matrices into images or even more preferably into a movie. I tried imwrite:
>> cleaned_img{1,k}=imwrite(cleaned{1,k},'jpg')
With the error:
Error using imwrite. Too many output arguments.
What am I doing wrong?
Another question:
Is there a way to view the matrices in the 1*360 cell with the imshow command in a way that I can skip from one image to the other without having to type imshow(cleaned{1,1}) to imshow(cleaned{1,360})? I would like to use imshow or another tool just like for example irfanview, just for the image data stored in the matrices.
Thank you!

Answers (4)

Wayne King
Wayne King on 5 Oct 2012
imwrite does not output any arguments. If you want to make a video, why are you needing to use imwrite? See the help for VideoWriter

Julian
Julian on 5 Oct 2012
Edited: Julian on 5 Oct 2012
I tried that before. My whole code looks like that.
jpegFiles = dir('*.jpg');
blank=imread('Tablette_PHAN_596_17 001.jpg');
white=255*ones(320,320,3);
white_uint8=uint8(white);
negative=white_uint8-blank;
numfiles = length(jpegFiles);
mydata = cell(1, numfiles);
for k = 1:numfiles;
mydata{1,k} = imread(jpegFiles(k).name);
cleaned{1,k}=mydata{1,k}+negative;
gray_level{1,k}=graythresh(cleaned{1,k});
binaries{1,k}=im2bw(cleaned{1,k},gray_level{1,k});
end
tab1=VideoWriter('tab1.avi','Archival')
open(tab1)
writeVideo('tab1',cleaned{1,k})
close(tab1)
end
When I run it I get "Undefined function 'writeVideo' for input arguments of type 'uint8'.
Error in batch_image_cleaning (line 19) writeVideo('tab1',cleaned{1,k})"?!

Image Analyst
Image Analyst on 5 Oct 2012
imwrite does not return ANY value. So you can't do that.
By the way, you didn't give it a filename, unless cleaned{1,k} was the name, in which case you didn't give it a numerical image array. Plus, like Wayne said, imwrite is no way to write videos.

Julian
Julian on 5 Oct 2012
Ok, I got that. That's why I posted the code for my try to make a video via VideoWriter in my last post.
tab1=VideoWriter('tab1.avi','Archival')
open(tab1)
writeVideo('tab1',cleaned{1,k})
close(tab1)
With the error
"Undefined function 'writeVideo' for input arguments of type 'uint8'.
I don't have any experiences with MATLAB and studied something not related to image analysis at all. I hope my questions are not too idiotic. I googled and looked up the help but still can't figure out why it doesn't work.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!