As Berak said, it's not a good idea to combine these images into a single 3 channel image. You make unnecessary memory operations and disk writing.
For vodeo files (avi or similar) there are no 16 bit codecs. You can save a series of 8 and 16 bit TIF files, but I think it's quite slow, so it won't work at 25+ fps.
The best way to do this (especially if the image size is known) would be to dump directly the data to the disk. Something like (c++ code, only with two frames to keep things simple):
ofstream myfile;
myfile.open ("video.dat",ios::binary);
uchar *frame1=new uchar[w*h];
ushort *frame2=new ushort[w*h];
Mat i1(w,h,frame1,CV_8UC1);
Mat i2(w,h,frame2,CV_16UC1);
....
myfile.write(frame1,w*h);
myfile.write(frame2,w*h*2);
...//repeat for every frame
myfile.close();
When reading the data, just do the opposite operations:
while(!myfile.eof()){
myfile.read(frame1,w*h);
myfile.read(frame2,w*h*2);
}
By knowing the size of a data chunk (sizeof(frame1)+sizeof(frame2)+...
), you can jump directly to a given frame, too.
If the image size can vary, you can write these parameters as the first bytes of the file.
why on earth would you need that ? also, you cannot save different datatypes in the same image, you you'd have to convert them to a common type anyway.
Need to store different data types to hold multiple data sources for each frame. All the data have the same resolution. Yep I was converting them to 16S before merging anyway.