My_Inverter.java
资源名称:ch03.zip [点击查看]
上传用户:scmyqay
上传日期:2021-10-16
资源大小:1k
文件大小:1k
源码类别:
Applet
开发平台:
Java
- /**
- * This sample code is made available as part of the book "Digital Image
- * Processing - An Algorithmic Introduction using Java" by Wilhelm Burger
- * and Mark J. Burge, Copyright (C) 2005-2008 Springer-Verlag Berlin,
- * Heidelberg, New York.
- * Note that this code comes with absolutely no warranty of any kind.
- * See http://www.imagingbook.com for details and licensing conditions.
- *
- * Date: 2007/11/10
- */
- 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 accepts 8-bit grayscale images
- }
- public void run(ImageProcessor ip) {
- int w = ip.getWidth();
- int h = ip.getHeight();
- // iterate over all image coordinates
- 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);
- }
- }
- }
- }