Demo plugin Image_Inverter.java

Posted by Rudolf Oldenbourg on
URL: http://imagej.273.s1.nabble.com/Demo-plugin-Image-Inverter-java-tp3691942.html

What change is needed in the Demo plugin Image_Inverter.java to make  
it invert only the values in a single slice of a stack?
Currently, it is called repeatedly to process all the slices in a  
stack. But I want it to invert the values inside a ROI of only one  
slice in a stack.
Thanks for any help,
Rudolf

plugin Image_Inverter.java:

import ij.*;
import ij.plugin.filter.PlugInFilter;
import ij.process.*;
import java.awt.*;

/** This sample ImageJ plugin filter inverts images.

A few things to note:
        1) Filter plugins must implement the PlugInFilter interface.
        2) User plugins do not use the package statement;
        3) Plugins residing in the "plugins" folder, and with at
        least one underscore in their name, are automatically
        installed in the PlugIns menu.
        4) Plugins can be installed in other menus by
        packaging them as JAR files.
        5) The class name ("Image_Inverter") and file name
        ("Image_Inverter.java") must be the same.
        6) This filter works with selections, including non-rectangular  
selections.
        7) It will be called repeatedly to process all the slices in a stack.
        8) It supports Undo for single images.
        9) "~" is the bitwise complement operator.
*/

public class Image_Inverter implements PlugInFilter {

        public int setup(String arg, ImagePlus imp) {
                if (IJ.versionLessThan("1.37j"))
                        return DONE;
                else
                        return DOES_ALL+DOES_STACKS+SUPPORTS_MASKING;
        }

        public void run(ImageProcessor ip) {
                Rectangle r = ip.getRoi();
                for (int y=r.y; y<(r.y+r.height); y++)
                        for (int x=r.x; x<(r.x+r.width); x++)
                                ip.set(x, y, ~ip.get(x,y));
        }

}


CONFIDENTIALITY NOTICE: This email message is intended only for
the addressee(s) and contains confidential and privileged
material for the sole use of the intended recipient(s). Any
review, use, distribution or disclosure by others is strictly
prohibited. If you have received this communication in error,
please notify the sender immediately by email and delete the
message and any file attachments from your computer.