[英]How can I stop ImageJ's Non-Local Means denoising algorithm from making all the edges in an image orange?
My code for running the ImageJ plugin is as follows: 我运行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");
}
}
After running the remove noise macro, all of the edges of my images are turned orange. 运行删除噪声宏后,图像的所有边缘变为橙色。 how can I stop this from happening?
我该如何阻止这种情况的发生?
Edit: This also happens when I use the actual ImageJ.jar program 编辑:当我使用实际的ImageJ.jar程序时,也会发生这种情况
I needed to split the channels first, there is a bug in the plugin when working with a composite. 我需要首先拆分渠道,使用复合材料时插件中存在错误。
I ended up fixing it working with the following code in my run method: 我最终在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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.