-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine_images_blue_red.ijm
38 lines (30 loc) · 1.05 KB
/
combine_images_blue_red.ijm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Prompt for input folder selection
inputDir = getDirectory("Choose the input folder");
// Prompt for output folder selection
outputDir = getDirectory("Choose the output folder");
// Get a list of files in the input folder
list = getFileList(inputDir);
// Loop through the files in batches of two
for (i = 0; i < list.length - 1; i += 2) {
// Open the first image in the batch
open(inputDir + list[i]);
// Convert it to 8-bit format
run("8-bit");
// Get the title of the first image
title1 = getTitle();
// Open the second image in the batch
open(inputDir + list[i+1]);
// Convert it to 8-bit format
run("8-bit");
// Get the title of the second image
title2 = getTitle();
// Merge channels
run("Merge Channels...", "c1=" + title2 + " c3=" + title1 + " create");
// Set the composite image type to RGB Color
run("RGB Color");
// Save the merged image with a custom name
saveAs("Tiff", outputDir + "merged_" + title1 + "_" + title2 + "_");
// Close the merged image
close();
close();
}