01: import JSci.instruments.*;
02: import java.awt.*;
03: import javax.swing.*;
04:
05: /**
06: An example of image processing in real time.
07: A simulated image source is created; it is passed through a
08: filter, that adds some rectangles, and a ROI selection is added.
09: Finally, a Player is added and started.
10: */
11:
12: public class Test {
13: public static void main(String[] args) {
14: ROI r = new RectangularROI(10, 10, 30, 30);
15: JSci.instruments.ImageFilter f = new MyFilter();
16: Player p = new Player();
17: JSci.instruments.ImageSource fs = new TestImageSource();
18: fs.setSink(f);
19: f.setSink(p);
20: p.addROI(r);
21: p.start();
22: }
23: }
24:
25: class MyFilter extends JSci.instruments.ImageFilterAdapter {
26: public void filter(JSci.instruments.Image f) {
27: f.addOverlay(new JSci.instruments.Overlay() {
28: public void paint(Graphics g) {
29: g.setColor(Color.YELLOW);
30: ((Graphics2D) g).draw(new Rectangle(3, 3, 100, 70));
31: }
32: });
33: }
34:
35: public Component getFilterControlComponent() {
36: return new JLabel("FILTER");
37: }
38:
39: public String getName() {
40: return "Mio filtro";
41: }
42: }
|