Skip to content

Instantly share code, notes, and snippets.

@mhansen
Created August 22, 2011 09:12
Show Gist options
  • Save mhansen/1161987 to your computer and use it in GitHub Desktop.
Save mhansen/1161987 to your computer and use it in GitHub Desktop.
import ij.ImagePlus;
import ij.plugin.filter.PlugInFilter;
import ij.process.ImageProcessor;
public class My_Inverter implements PlugInFilter {
public int setup(String arg, ImagePlus im) {
return DOES_8G; // this plugin only works on 8-bit grayscale images
}
public void run(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);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment