Login  Register

Re: How can I write a similar plugin that opens a file from a specified path?

Posted by Avital Steinberg on Aug 06, 2014; 10:13am
URL: http://imagej.273.s1.nabble.com/How-can-I-write-a-similar-plugin-that-opens-a-file-from-a-specified-path-tp5009034p5009044.html

Thank you for your answer - I'm getting an error message that is related to
the first line: package gui. I tried commenting it out, and then it allowed
me to choose a file interactively, but it didn't seem to do anything else.
In this case, I didn't see an error message.

Do you have any suggestions how to fix it?

Thanks,
Avital




On Tue, Aug 5, 2014 at 3:20 PM, vcaldas <[hidden email]> wrote:

> Didn't test for small bugs, but this should work.
>
> Cheers.
> Victor
>
>
> package gui;
> import ij.IJ;
> import ij.ImagePlus;
> import ij.plugin.PlugIn;
> import ij.process.ImageProcessor;
>
> public class My_Inverter implements PlugIn {
>         String FileName;
>     private static final int DOES_8G = 0;
>
>         public int setup (String arg, ImagePlus imp) {
>         return DOES_8G; // This plugin accepts 8-bit grayscale images
>     }
>
>         public void run(String arg0) {
>
>                 FileName = IJ.getFilePath("Choose the file");
>                 ImagePlus imp= IJ.openImage(FileName );
>                 ImageProcessor ip = imp.getProcessor();
>                 Inverter(ip);
>                 imp.draw();
>         }
>
>     public void Inverter(ImageProcessor ip) {
>         int w = ip.getWidth();
>         int h = ip.getHeight();
>
>         for (int u = 0; u < w; u++) {
>             for (int v = 0; v < h; v++) {
>                 int p = ip.getPixel(u, v);
>                 ip.putPixel(u, v, 255-p);
>             }
>         }
>     }
> }
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/How-can-I-write-a-similar-plugin-that-opens-a-file-from-a-specified-path-tp5009034p5009035.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html