Test.java :  » Science » JSci » examples » ImageProcessing » Java Open Source

Java Open Source » Science » JSci 
JSci » examples » ImageProcessing » Test.java
import JSci.instruments.*;
import java.awt.*;
import javax.swing.*;

/** 
    An example of image processing in real time.
    A simulated image source is created; it is passed through a
    filter, that adds some rectangles, and a ROI selection is added.
    Finally, a Player is added and started.
*/

public class Test {
    public static void main(String[] args) {
  ROI r = new RectangularROI(10,10,30,30);
  JSci.instruments.ImageFilter f = new MyFilter();
  Player p = new Player();
  JSci.instruments.ImageSource fs = new TestImageSource();
  fs.setSink(f);
  f.setSink(p);
  p.addROI(r);
  p.start();
    }
}

class MyFilter extends JSci.instruments.ImageFilterAdapter {
    public void filter(JSci.instruments.Image f) { 
  f.addOverlay(new JSci.instruments.Overlay() {
    public void paint(Graphics g) {
        g.setColor(Color.YELLOW);
        ((Graphics2D)g).draw(new Rectangle(3,3,100,70));
    }
      });
    } 
    public Component getFilterControlComponent() {
  return new JLabel("FILTER");
    }
    public String getName() { return "Mio filtro"; }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.