Jean Claude Abela
Jean Claude Abela

Reputation: 907

Darkening Image

I am trying to darken an image in java but instead it is turning plain black.

Here is the code that i am 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 am doing wrong?

Upvotes: 3

Views: 955

Answers (1)

I think you are missing the right number for the factor, a really good way to experiment with this is with the Gimp, you can go to filters -> generic -> convolution matrix and try out different factors, I can darken my image with a factor 0.7 and very low becomes too black.

Let me know how it went.

Upvotes: 2

Related Questions