Posted by
ctrueden on
Sep 14, 2010; 5:53pm
URL: http://imagej.273.s1.nabble.com/ImageJ-is-saving-my-grayscale-AVI-files-as-RED-tp3686921p3686923.html
Hi Chris,
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?).
>
Your macro contains a code snippet that colorizes the images when there is
more than one channel:
if (sizeC>1) {
> if (sizeC==3&&sizeC==nSlices) mode = "Composite";
> else mode = "Color";
> run("Make Composite", "display="+mode);
> }
>
So if as Jacqui Ross suggests your AVIs are actually stored in RGB format,
this code would be invoked.
One option would be to change mode to always be "Grayscale" which should
eliminate the issue regardless of your input data.
Note also that your macro is vastly more complicated than you need merely to
convert images. You can start the Macro Recorder, open an AVI as a
hyperstack using Bio-Formats, and then save it back to disk. The recorder
will then contain a very short macro you can adapt to batch process multiple
AVIs in a loop without needing to use the Bio-Formats Macro Extensions.
HTH,
Curtis
On Wed, Sep 8, 2010 at 3:18 PM, Chris Richie <
[hidden email]> wrote:
> 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
> --
> View this message in context:
>
http://imagej.588099.n2.nabble.com/ImageJ-is-saving-my-grayscale-AVI-files-as-RED-tp5512203p5512203.html> Sent from the ImageJ mailing list archive at Nabble.com.
>