My code for running the ImageJ plugin is as follows:
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
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:
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.