我正在从三个通道 .svs 图像中读取裁剪区域并将作物保存为 .tiff 图像。目前,图像使用单独的 RGB 通道保存。
我以这种方式裁剪图像:
var path = currentFolder + "images" + File.separator + imageName;
var options = new ImporterOptions();
options.setId(path);
options.setAutoscale(true);
options.setCrop(true);
options.setCropRegion(0, new Region(X, Y, deltaX, deltaY));
options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE);
var croppedImage= new ImagePlus();
croppedImage= BF.openImagePlus(options);
print("cropped image class: " + croppedImage.getClass());
给
cropped image class: class [Lij.ImagePlus;
然后我保存图像:
IJ.saveAs(cropedImage, "tif", outputFileName);
我最终得到了三个通道图像。
我想合并频道。
我发现了两种可能的方法来做到这一点:
http://javadoc.imagej.net/ImageJ1/ij/plugin/RGBStackMerge.html
http://rsb.info.nih.gov/ij/developer/api/ij/ImagePlus.html#flatten--
我试过croppedImage.flatten()
并得到:
javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: Java class "[Lij.ImagePlus;" has no public instance field or method named "flatten".
我也尝试导入RGBStackMerge
类:
importClass(Packages.ij.plugin.RGBStackMerge);
和做
finalImage = new ImagePlus();
finalImage = RGBStackMerge.mergeChannels(croppedImage, false);
print ("final image class: " + finalImage.getClass() + " length: " + finalImage.length);
但这给出了:
Started svs_to_cropped_tiffs.js at Fri Jan 22 22:58:10 PST 2016 javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot call method "getClass" of null