public void analyze() {

        try {

            BufferedImage image = ImageIO.read(file);

            int w = image.getWidth();
            int h = image.getHeight();
            map = new HashMap<PixelColor, MutableInt>();
            PixelColor pixelColor = null;

            for (int i = 0; i < w; i++) {

                for (int j = 0; j < h; j++) {

                    int rgb = image.getRGB(i, j);

                    Integer a = (rgb >> 24) & 0xFF;
                    Integer r = (rgb >> 16) & 0xFF;
                    Integer g = (rgb >> 8) & 0xFF;
                    Integer b = (rgb & 0xFF);

                    if (pixelColor == null ||
                            !a.equals(pixelColor.getAlpha()) ||
                            !r.equals(pixelColor.getRed()) ||
                            !g.equals(pixelColor.getGreen()) ||
                            !b.equals(pixelColor.getBlue())) {
                        pixelColor = new PixelColor(a, r, g, b);
                    }

                    MutableInt value = map.get(pixelColor);
                    if (value == null) {
                        value = new MutableInt();
                        map.put(pixelColor, value);
                    } else {
                        value.inc();
                    }

                    map.put(pixelColor, value);

                }

            }

            displayResult();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }