Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 993
Jean Claude Abela Avatar asked May 18 '26 06:05

Jean Claude Abela


1 Answers

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.

like image 78
Juan Alberto López Cavallotti Avatar answered May 19 '26 19:05

Juan Alberto López Cavallotti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!