Image darkening

I am trying to darken an image in java, but instead it turns black.

Here is the code I'm using.

    float[] elements = {factor};

    Kernel kernel = new Kernel(1, 1, elements);
    ConvolveOp op = new ConvolveOp(kernel);

    BufferedImage bufferedImage = new BufferedImage(image.getWidth(), image.getHeight(), image.getType());
    op.filter(image, bufferedImage);

Any ideas what I'm doing wrong?

+3
source share
1 answer

I think you are missing the correct number for the factor, a really good way to experiment with this is with Gimp, you can go to the filters β†’ generic β†’ convolution matrix and try different factors, I can darken my image with a coefficient of 0.7 and very low getting too black.

Let me know how it happened.

+2
source

All Articles