public static BufferedImage brightness(BufferedImage input, double factor) {

        BufferedImage result = new BufferedImage(input.getWidth(), input.getHeight(), input.getType());


        for (int i = 0; i < result.getWidth(); i++) {
            for (int j = 0; j < result.getHeight(); j++) {

                Color c = new Color(input.getRGB(i, j));

                int r = c.getRed() * factor > 255 ? 255 : (int) (c.getRed() * factor);
                int g = c.getGreen() * factor > 255 ? 255 : (int) (c.getGreen() * factor);
                int b = c.getBlue() * factor > 255 ? 255 : (int) (c.getBlue() * factor);

                result.setRGB(i, j,
                        new Color(r, g, b).getRGB());
            }
        }
        return result;
    }