import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.filter.*; public class Sobel_2018_10_31 implements PlugInFilter { ImagePlus imp; public int setup(String arg, ImagePlus imp) { this.imp = imp; return DOES_ALL; } public void run(ImageProcessor ip) { int width = ip.getWidth(); int height = ip.getHeight(); ImageProcessor copy = ip.duplicate(); int[][] H ={{1,0,-1},{2,0,-2},{1,0,-1}}; for(int v = 1; v <= height-2; v++) { for(int u = 1; u <= width-2; u++) { int k = 0; for(int j =-1; j <= 1; j++) { for(int i =-1; j <= 1; j++) { int I = copy.getPixel(u-i,v-j); k = k + I * H[i+1][j+1]; } } ip.putPixel(u,v,k); } } } }