@@ -0,0 +1,2968 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0Apackage kanzi.test;%0A%0Aimport java.awt.GraphicsConfiguration;%0Aimport java.awt.GraphicsDevice;%0Aimport java.awt.GraphicsEnvironment;%0Aimport java.awt.Image;%0Aimport java.awt.Transparency;%0Aimport java.awt.image.BufferedImage;%0Aimport java.util.TreeSet;%0Aimport javax.swing.ImageIcon;%0Aimport javax.swing.JFrame;%0Aimport javax.swing.JLabel;%0Aimport kanzi.filter.ColorClusterFilter;%0Aimport kanzi.filter.FastBilateralFilter;%0Aimport kanzi.filter.SobelFilter;%0Aimport kanzi.util.QuadTreeGenerator;%0A%0A%0A/**%0A *%0A * @author fred%0A */%0Apublic class TestQuadTreeGenerator%0A%7B%0A  %0A    public static void main(String%5B%5D args)%0A    %7B%0A        try%0A        %7B%0A            String fileName = (args.length %3E 0) ? args%5B0%5D : %22c:%5C%5Ctemp%5C%5Clena.jpg%22;%0A            ImageIcon icon = new ImageIcon(fileName);%0A            Image image = icon.getImage();%0A            int w = image.getWidth(null) & -7;%0A            int h = image.getHeight(null) & -7;%0A            System.out.println(w+%22x%22+h);%0A            GraphicsDevice gs = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()%5B0%5D;%0A            GraphicsConfiguration gc = gs.getDefaultConfiguration();%0A            BufferedImage img = gc.createCompatibleImage(w, h, Transparency.OPAQUE);%0A            img.getGraphics().drawImage(image, 0, 0, null);%0A            BufferedImage img2 = gc.createCompatibleImage(w, h, Transparency.OPAQUE);%0A            int%5B%5D source = new int%5Bw*h%5D;%0A            int%5B%5D dest = new int%5Bw*h%5D;%0A            TreeSet%3CQuadTreeGenerator.Node%3E nodes = new TreeSet%3CQuadTreeGenerator.Node%3E();            %0A%0A            // Do NOT use img.getRGB(): it is more than 10 times slower than%0A            // img.getRaster().getDataElements()%0A            img.getRaster().getDataElements(0, 0, w, h, source);%0A            System.arraycopy(source, 0, dest, 0, w*h);%0A            img2.getRaster().setDataElements(0, 0, w, h, dest);%0A%0A            int nbNodes = 800;%0A            int minNodeDim = 8;%0A            nodes.clear();%0A            new QuadTreeGenerator(w, h, nbNodes, minNodeDim).decompose(nodes, source);%0A            %0A            for (QuadTreeGenerator.Node node : nodes)%0A               img2.getGraphics().drawRect(node.x, node.y, node.w, node.h);%0A%0A            //icon = new ImageIcon(img);%0A            JFrame frame = new JFrame(%22Original%22);%0A            frame.setBounds(150, 100, w, h);%0A            frame.add(new JLabel(icon));%0A            frame.setVisible(true);%0A            JFrame frame2 = new JFrame(%22Filter%22);%0A            frame2.setBounds(700, 150, w, h);%0A            ImageIcon newIcon = new ImageIcon(img2);%0A            frame2.add(new JLabel(newIcon));%0A            frame2.setVisible(true);%0A%0A            try%0A            %7B%0A                Thread.sleep(45000);%0A            %7D%0A            catch (Exception e)%0A            %7B%0A            %7D%0A        %7D%0A        catch (Exception e)%0A        %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        System.exit(0);%0A    %7D%0A%7D%0A%0A

Test of new QuadTreeGenerator class