Digital Signal Processing Reference
In-Depth Information
D.2 Kombinierte
Regionenmarkierung-Konturverfolgung
D.2 Kombinierte
Regionenmarkierung-
Konturverfolgung
Vollstandiger Quellcode als Erganzung zur Beschreibung in Abschn.11.2.
D.2.1 File ContourTracingPlugin .java
1 import ij.IJ;
2 import ij.ImagePlus;
3 import ij.gui.ImageWindow;
4 import ij.plugin.filter.PlugInFilter;
5 import ij.process.ImageProcessor;
6
7 // Uses the ContourTracer class to create an ordered list
8 // of points representing the internal and external contours
9 // of each region in the binary image. Instead of drawing
10 // directly into the image, we make use of ImageJ's ImageCanvas
11 // to draw the contours in a layer ontop of the image.
12 // Illustrates how to use the Java2D api to draw the
13 // polygons and scale and transform them to match ImageJ's
14 // zooming.
15
16 public class ContourTracingPlugin_ implements PlugInFilter {
17
18
public int setup(String arg, ImagePlus imp) {
return DOES_8G + NO_CHANGES;
19
}
20
21
22
public void run(ImageProcessor ip) {
ImageProcessor ip2 = ip.duplicate();
23
// trace the contours and get the ArrayList
24
ContourTracer tracer = new ContourTracer(ip2);
25
ContourSet cs = tracer.getContours();
26
//contours.print();
27
28
29
// change lookup-table to show gray regions
ip2.setMinAndMax(0,512);
30
31
32
ImagePlus imp =
new ImagePlus("Contours of " + IJ.getImage().getTitle(),
ip2);
33
34
35
ContourOverlay cc = new ContourOverlay(imp, cs);
new ImageWindow(imp, cc);
36
}
37
38 }
Search WWH ::




Custom Search