Created
August 22, 2011 09:12
-
-
Save mhansen/1161987 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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