/Users/lyon/j4p/src/j2d/edge/LoGProcessor.java
|
1 package j2d.edge;
2
3 import j2d.ImageUtils;
4 import ip.transforms.Kernels;
5 import j2d.ImageProcessorInterface;
6 import j2d.ImageProcessorFactory;
7 import j2d.hpp.InvertFilter;
8
9 import java.awt.*;
10
11
12 public class LoGProcessor
13 implements ImageProcessorInterface,
14 ImageProcessorFactory {
15
16 private int kernelWidth;
17 private double sigma;
18
19
20 public LoGProcessor(
21 int _kernelWidth,
22 double _sigma) {
23
24 kernelWidth = _kernelWidth;
25 sigma = _sigma;
26 }
27
28 public ImageProcessorInterface getProcessor(int i) {
29 return
30 new LoGProcessor(
31 kernelWidth,
32 i + 1);
33 }
34
35 public Image process(Image img) {
36 return LoGSobel(img);
37
38 }
39
40
41 private Image LoGSobel(Image img) {
42 System.out.println(
43 "kw=" + kernelWidth +
44 " sigma=" + sigma);
45 ImageProcessorInterface invert = InvertFilter.getProcessor();
46 Image logImage = ImageUtils.convolution(img,
47 Kernels.getLaplaceOfGaussianKernel(
48 kernelWidth,
49 kernelWidth,
50 sigma));
51 return
52 invert.process(logImage);
53 }
54
55 }
56
57