我运行ImageJ插件的代码如下:
import ij.IJ;
import ij.ImagePlus;
import ij.io.FileSaver;
import ij.plugin.PlugIn;
public class Test implements PlugIn {
public static void main(String[] args) {
Test test = new Test();
test.run("Denoise.ijm");
}
@Override
public void run(String arg0) {
String directory = "C:\\Users\\Speedy Octopus\\Desktop\\10Cover Shots\\10.JPG";
ImagePlus imp = IJ.openImage(directory);
FileSaver fileSaver = new FileSaver(imp);
System.setProperty("plugins.dir", "C:\\Users\\Speedy Octopus\\Downloads\\ij150-win-java8\\ImageJ\\plugins");
IJ.run(imp, "Non-local Means Denoising", "sigma=5 smoothing_factor=1");
fileSaver.saveAsJpeg("C:\\Users\\Speedy Octopus\\Desktop\\10Cover Shots\\10edited.JPG");
}
}
运行移除噪点宏后,我的图像的所有边缘都变为橙色。我怎么能阻止这种情况发生?
编辑:当我使用实际的ImageJ.jar程序
时也会发生这种情况答案 0 :(得分:0)
我需要首先拆分通道,使用复合材料时插件中存在错误。
我最终修复了它在我的run方法中使用以下代码:
ImagePlus imp = IJ.openImage(directory);
FileSaver fileSaver = new FileSaver(imp);
System.setProperty("plugins.dir", LocalMethods.readFile("NonLocalMeansDir").get(0));
ImagePlus[] channels = ChannelSplitter.split(imp);
String[] channelTitles = new String[3];
for (int i = 0; i < channels.length; i++) {
ImagePlus channel = channels[i];
channelTitles[i] = channel.getTitle();
IJ.run(channel, "Non-local Means Denoising", "sigma=5 smoothing_factor=1");
}
IJ.run(imp, "Merge Channels...", "c1=[" + imp.getTitle() + " (" + channelTitles[0] + ") " + "] c2=[" + imp.getTitle() + " (" + channelTitles[1] + ") " + "] c3=[" + imp.getTitle() + " (" + channelTitles[2] + ") " + "] create");
IJ.saveAs("jpeg", directory);