public BufferedImage getDitheredImage(BufferedImage image, int colorChannel) {
        checkNotNull(image, "Image to be dithered is null!");
        int width = image.getWidth();
        int height = image.getHeight();
        BufferedImage ditheredImage = new BufferedImage(width, height, ColorSpace.TYPE_RGB);

        for (int i = 0; i   < width; i++) {
            for (int j = 0; j < height; j++) {
                int oldPixel = image.getRGB(i, j);
                int newPixel = PixelConverter.getRgbIntFromColor(getRoundedColorValue(oldPixel, colorChannel), colorChannel);

                int quantizedError = getQuantizationError(oldPixel, newPixel, colorChannel);

                if (i + 1 < width - 1)
                    image.setRGB(i + 1, j,
                            getDitheredPixel(image.getRGB(i + 1, j), quantizedError, (double) 7 / 16, colorChannel));
                if (i - 1 >= 0 && j + 1 < height - 1)
                    image.setRGB(i - 1, j + 1,
                            getDitheredPixel(image.getRGB(i - 1, j + 1), quantizedError, (double) 3 / 16, colorChannel));
                if (j + 1 < height - 1)
                    image.setRGB(i, j + 1,
                            getDitheredPixel(image.getRGB(i, j + 1), quantizedError, (double) 5 / 16, colorChannel));
                if (i + 1 < width - 1 && j + 1 < height - 1)
                    image.setRGB(i + 1, j + 1,
                            getDitheredPixel(image.getRGB(i + 1, j + 1), quantizedError, (double) 1 / 16, colorChannel));

                ditheredImage.setRGB(i, j, newPixel);
            }
        }

        return ditheredImage;
    }