I've written a primative FIJI script which opens up my 16-bit 3 channel images and allows me to crop regions of interest. However, I can't figure out how to set the brightness and contrast automatically. At the moment I have to do this manually by having the picture open, moving the slider to the second channel, then setting min and max. I tried to use setMinAndMax(98, 2696); but this applied it to my first channel, not my second. Can't find any info on specifying which channel other than using setMinAndMax(98, 2696, 2); - but that only works on RGB images it seems.
Here is my code:
outputDir = inputDir + "montage_cropped" + File.separator;
File.makeDirectory(outputDir);
list = getFileList(inputDir);
for (i = 0; i < lengthOf(list); i++) {
if (endsWith(list[i], ".tif")) {
open(inputDir + list[i]);
waitForUser("Adjust brightness and contrast for the second channel and click OK when done.", "");
// Draw a rectangle
makeRectangle(3000, 6720, 1000, 1000);
// Wait for user to move the rectangle
waitForUser("Select the CROP region", "Drag the crop ROI to the desired location, then click <<OK>>");
run("Duplicate...", "duplicate");
run("RGB Color");
// Generate output file name
cropName = replace(list[i], ".tif", "_crop.tif");
// Save the cropped image
saveAs("Tiff", outputDir + cropName);
close();
close();
close();
}
}```
Any ideas? Thank you!
Tried setMinAndMax(98, 2696, 2); but this only works for RGB images.