1 package ij.plugin.filter;
16 if (imp!=null && imp.
getStackSize()>1 && arg.equals(
"demo"))
17 {
IJ.
error(
"This demo does not work with stacks.");
return DONE;}
21 public void run(ImageProcessor ip) {
22 if (arg.equals(
"north")) north(ip);
23 else if (arg.equals(
"northeast")) northeast(ip);
24 else if (arg.equals(
"east")) east(ip);
25 else if (arg.equals(
"southeast")) southeast(ip);
26 else if (arg.equals(
"south")) south(ip);
27 else if (arg.equals(
"southwest")) southwest(ip);
28 else if (arg.equals(
"west")) west(ip);
29 else if (arg.equals(
"northwest")) northwest(ip);
34 public void north(ImageProcessor ip) {
35 int[] kernel = {1,2,1, 0,1,0, -1,-2,-1};
36 ip.convolve3x3(kernel);
39 public void south(ImageProcessor ip) {
40 int[] kernel = {-1,-2,-1, 0,1,0, 1,2,1};
41 ip.convolve3x3(kernel);
44 public void east(ImageProcessor ip) {
45 int[] kernel = {-1,0,1, -2,1,2, -1,0,1};
46 ip.convolve3x3(kernel);
49 public void west(ImageProcessor ip) {
50 int[] kernel = {1,0,-1, 2,1,-2, 1,0,-1};
51 ip.convolve3x3(kernel);
54 public void northwest(ImageProcessor ip) {
55 int[] kernel = {2,1,0, 1,1,-1, 0,-1,-2};
56 ip.convolve3x3(kernel);
59 public void southeast(ImageProcessor ip) {
60 int[] kernel = {-2,-1,0, -1,1,1, 0,1,2};
61 ip.convolve3x3(kernel);
64 public void northeast(ImageProcessor ip) {
65 int[] kernel = {0,1,2, -1,1,1, -2,-1,0};
66 ip.convolve3x3(kernel);
69 public void southwest(ImageProcessor ip) {
70 int[] kernel = {0,-1,-2, 1,1,-1, 2,1,0};
71 ip.convolve3x3(kernel);