http://imagej.273.s1.nabble.com/Merge-4-color-channels-tp5012905p5012912.html
green, blue, yellow and magenta are variable names that hold the titles of your images. In your version of the code, the code looks for images called 'green', 'blue', etc.
> I'm trying to 4 color image ND2 files into separate color, adjust each color
> with different parameters, and re-merge them into a single file in a batch
> mode. The script I wrote is below. At the end of macro, it stops with a
> dialog box saying " Merge Channels There must be at least one source image
> or stack [OK]". Could anyone help me to fix it?
>
>
> dir1 = getDirectory('Choose Directory ');
> list = getFileList(dir1);
> dir2 = dir1+"JPG"+File.separator;
> File.makeDirectory(dir2);
>
> setBatchMode(true);
> for (i=0; i<list.length; i++) {
> print(dir1 + list[i]);
> showProgress(i, list.length);
> name = dir1 + list[i];
>
> run("Bio-Formats Importer", "open=name view=Hyperstack stack_order=XYCZT
> Color mode=Default split_channels");
> name1 = list[i];
> index = lastIndexOf(name1, ".");
> if (index!=-1) name2 = substring(name1, 0, index);
> path = dir2 + name2;
> print(path);
>
> selectWindow(name1 + ' - C=0');
> run("Channels Tool...");
> run("Green");
> run("RGB Color");
> run("Brightness/Contrast...");
> setMinAndMax(8, 50);
> call("ij.ImagePlus.setDefault16bitRange", 8);
> selectWindow("B&C");
> run("Close");
>
> selectWindow(name1 + ' - C=1');
> run("Channels Tool...");
> run("Blue");
> run("RGB Color");
> run("Brightness/Contrast...");
> setMinAndMax(8, 150);
> call("ij.ImagePlus.setDefault16bitRange", 8);
> selectWindow("B&C");
> run("Close");
>
> selectWindow(name1 + ' - C=2');
> run("Channels Tool...");
> run("Yellow");
> run("RGB Color");
> run("Brightness/Contrast...");
> setMinAndMax(8, 35);
> call("ij.ImagePlus.setDefault16bitRange", 8);
> selectWindow("B&C");
> run("Close");
>
> selectWindow(name1 + ' - C=3');
> run("Channels Tool...");
> run("Magenta");
> run("RGB Color");
> run("Brightness/Contrast...");
> setMinAndMax(8, 100);
> call("ij.ImagePlus.setDefault16bitRange", 8);
> selectWindow("B&C");
> run("Close");
> selectWindow("Channels");
> run("Close");
>
> selectWindow(name1 + ' - C=0');
> green = getTitle;
> selectWindow(name1 + ' - C=1');
> blue = getTitle;
> selectWindow(name1 + ' - C=2');
> yellow = getTitle;
> selectWindow(name1 + ' - C=3');
> magenta = getTitle;
>
> print(green);
> print(blue);
> print(yellow);
> print(magenta);
>
> run("Merge Channels...",
> "C2=green C3=blue C6=yellow C7=magenta keep");
> saveAs("jpeg", path + ".jpg");
> run("Close");
> }
>
>
>
>
>
>
>
> --
> View this message in context:
http://imagej.1557.x6.nabble.com/Merge-4-color-channels-tp5012905.html> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html