Hello,
I have 36,000+ 16-bit greyscale images in two different folders (18,000+ images per folder). I want to subtract all the images in folder 2 from the images in folder one (i.e.* img001 - img002*,* img003 - imag004*, ........). In addition, I want the result of each subtraction to be a 32-bit floating point format as not to clip any pixel values. Each 32-bit image created would then need to be saved in it's own directory. How might I do this so that I do not have to load all the images into ImageJ? I tried approaching this using the Batch > Virtual Stack command but was not able to get it to work. Any suggestions? Cheers, Aaron Hendrickson. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Aaron,
> How might I do this so that I do not have to load all the images into > ImageJ? Here's a quick macro (untested): // inputDir1 = "/path/to/firstInputDir"; inputDir2 = "/path/to/secondInputDir"; outputDir = "/path/to/outputDir"; fileList1 = getFileList(inputDir1); fileList2 = getFileList(inputDir2); if (fileList1.length != fileList2.length) { exit("Input directories must have same number of files."); } for (i = 0; i < fileList1.length; i++) { file1 = fileList1[i]; file2 = fileList2[i]; open(file1); id1 = getImageID(); open(file2); id2 = getImageID(); imageCalculator("Subtract create 32-bit", id1, id2); outName = File.getName(file1) + "-" + File.getName(file2); saveAs("Tiff", outputDir + "/" + outName); } // For more details, see the list of built-in macro functions: http://imagej.nih.gov/ij/developer/macro/functions.html It is also helpful to use the Macro Recorder (Plugins > Macros > Record) to easily determine what the line of code should be corresponding to an operation in the GUI. Regards, Curtis On Tue, Mar 19, 2013 at 6:40 AM, Aaron Hendrickson <[hidden email]>wrote: > Hello, > > I have 36,000+ 16-bit greyscale images in two different folders (18,000+ > images per folder). I want to subtract all the images in folder 2 from the > images in folder one (i.e.* img001 - img002*,* img003 - imag004*, > ........). In addition, I want the result of each subtraction to be a > 32-bit floating point format as not to clip any pixel values. Each 32-bit > image created would then need to be saved in it's own directory. How might > I do this so that I do not have to load all the images into ImageJ? I > tried approaching this using the Batch > Virtual Stack command but was not > able to get it to work. Any suggestions? > > Cheers, > Aaron Hendrickson. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thank you Curtis. I will give it a try.
Cheers, Aaron Hendrickson. On Tue, Mar 19, 2013 at 11:28 AM, Curtis Rueden <[hidden email]> wrote: > Hi Aaron, > > > How might I do this so that I do not have to load all the images into > > ImageJ? > > Here's a quick macro (untested): > > // > inputDir1 = "/path/to/firstInputDir"; > inputDir2 = "/path/to/secondInputDir"; > outputDir = "/path/to/outputDir"; > fileList1 = getFileList(inputDir1); > fileList2 = getFileList(inputDir2); > if (fileList1.length != fileList2.length) { > exit("Input directories must have same number of files."); > } > for (i = 0; i < fileList1.length; i++) { > file1 = fileList1[i]; > file2 = fileList2[i]; > open(file1); > id1 = getImageID(); > open(file2); > id2 = getImageID(); > imageCalculator("Subtract create 32-bit", id1, id2); > outName = File.getName(file1) + "-" + File.getName(file2); > saveAs("Tiff", outputDir + "/" + outName); > } > // > > For more details, see the list of built-in macro functions: > http://imagej.nih.gov/ij/developer/macro/functions.html > > It is also helpful to use the Macro Recorder (Plugins > Macros > Record) to > easily determine what the line of code should be corresponding to an > operation in the GUI. > > Regards, > Curtis > > > On Tue, Mar 19, 2013 at 6:40 AM, Aaron Hendrickson <[hidden email] > >wrote: > > > Hello, > > > > I have 36,000+ 16-bit greyscale images in two different folders (18,000+ > > images per folder). I want to subtract all the images in folder 2 from > the > > images in folder one (i.e.* img001 - img002*,* img003 - imag004*, > > ........). In addition, I want the result of each subtraction to be a > > 32-bit floating point format as not to clip any pixel values. Each > 32-bit > > image created would then need to be saved in it's own directory. How > might > > I do this so that I do not have to load all the images into ImageJ? I > > tried approaching this using the Batch > Virtual Stack command but was > not > > able to get it to work. Any suggestions? > > > > Cheers, > > Aaron Hendrickson. > > > > -- > > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |