01: import java.awt.*;
02: import java.awt.event.*;
03: import JSci.awt.*;
04: import JSci.maths.wavelet.*;
05: import JSci.maths.wavelet.cdf2_4.*;
06:
07: /**
08: * Launch the following code on an image having odd dimensions
09: * and you'll have a visual example.
10: * @author Daniel Lemire
11: */
12: public final class WaveletImageTransform extends Frame {
13: public static void main(String[] arg) {
14: if (arg.length == 0) {
15: System.err
16: .println("Please specify an image with odd dimensions.");
17: return;
18: }
19: new WaveletImageTransform(arg[0]);
20: }
21:
22: public WaveletImageTransform(String filename) {
23: super ("Fast Wavelet Transform");
24: addWindowListener(new WindowAdapter() {
25: public void windowClosing(WindowEvent evt) {
26: dispose();
27: System.exit(0);
28: }
29: });
30:
31: System.err.println("Opening \"" + filename + "\"");
32: PixelArray pa1 = new PixelArray(filename);
33: ImageCanvas ic1 = new ImageCanvas(pa1.rebuildImage());
34: System.err
35: .println("Please wait... This could take a few minutes...");
36:
37: PixelArray[][] paa = pa1.greenFWT(new CDF2_4());
38:
39: ImageCanvas ic0_0 = new ImageCanvas(paa[0][0].rebuildImage());
40:
41: ImageCanvas ic1_0 = new ImageCanvas(paa[1][0].rebuildImage());
42: ImageCanvas ic0_1 = new ImageCanvas(paa[0][1].rebuildImage());
43: ImageCanvas ic1_1 = new ImageCanvas(paa[1][1].rebuildImage());
44:
45: setLayout(new GridLayout(2, 0, 2, 2));
46: add(ic1);
47: Panel p2 = new Panel();
48: p2.setLayout(new GridLayout(0, 2, 1, 1));
49: p2.add(ic0_0);
50: p2.add(ic1_0);
51: p2.add(ic0_1);
52: p2.add(ic1_1);
53: add(p2);
54: setBounds(0, 0, 400, 400);
55: show();
56: }
57: }
|