ImageJ is saving my grayscale AVI files as RED?
Posted by Chris Richie on Sep 08, 2010; 8:18pm
URL: http://imagej.273.s1.nabble.com/ImageJ-is-saving-my-grayscale-AVI-files-as-RED-tp3686921.html
I have a Bio-formats macro that opens up my Nikon Elements AVI files (which has an incorrect FPS header) and then saves them as uncompressed AVI with 15FPS.
the input and output files are the same size, however my input is a grayscale image and the output is somehow being converted as a red image (perhaps an 8-bit image with Red LUT?).
I have experimented with different kinds of image modes and hyperstacks, but this is as close as I have gotten.
I can supply a small sample (input and output) if that would be helpful.
This whole thing is because my Nikon Elements (AVI capture) always saves the files with 100FPS. The objective of this macro is to produce a file with the correct 15FPS in the header, a prerequisite for analyzing the movie with some other software. Is there a way to edit the header information directly without opening the file?
Thanks for your assistance
Chris
// start Macro
// batch process to re-header the .AVI files captured by April on the Nikon Elements
// hacked together from by crichie on 09-08-10.
// bfOpenAsHyperstack.txt Written by Wayne Rasband
// and another macro from a forum post by Dr K.R. Straatman
requires("1.41c");
///
///
dir1 = getDirectory("Choose Source Directory ");
list = getFileList(dir1);
dir2 = dir1+"analysed"+File.separator;
File.makeDirectory(dir2);
for (f=0; f<list.length; f++)
{
if (File.isDirectory(dir1+list[f])){}
else{
path = dir1+list[f];
if (endsWith(path, ".db")){}
else{
name = list[f];
run("Bio-Formats Macro Extensions");
Ext.setId(path);
Ext.getCurrentFile(file);
Ext.getSizeX(sizeX);
Ext.getSizeY(sizeY);
Ext.getSizeC(sizeC);
Ext.getSizeZ(sizeZ);
Ext.getSizeT(sizeT);
Ext.getImageCount(n);
setBatchMode(true);
for (i=0; i<n; i++) {
showProgress(i, n);
Ext.openImage("plane "+i, i);
if (i==0)
stack = getImageID;
else {
run("Copy");
close;
selectImage(stack);
run("Add Slice");
run("Paste");
}
}
rename(name);
if (nSlices>1) {
Stack.setDimensions(sizeC, sizeZ, sizeT);
if (sizeC>1) {
if (sizeC==3&&sizeC==nSlices) mode = "Composite";
else mode = "Color";
run("Make Composite", "display="+mode);
}
}
//run("AVI... ", "compression=Uncompressed frame=15 save="+path+"_15fps.avi");
newname = dir2 +"\\"+ name +"_15fps.avi";
print (newname);
run("AVI... ", "compression=Uncompressed frame=15 save="+ dir2 +"\\"+ name +"_15fps.avi");
}
setBatchMode(false);
// Ext.close(); //remming this out to see if verbose error list goes away.
close();
}
}
///
///
// end macro