Reputation: 1364
I'm using RescaleOp
to brighten my image, my problem is, if I use black(0,0,0) and white(255,255,255) they come back exactly the same.
I can guess why, 0(black RGB values) x 1.3 (brightness factor) = 0, and the white pixels can't go higher than 255 so they remain the same, and I'm satisfied with the white pixels remaining the same.
On the other end, if I darken the image, I get desired results because the white pixels get darker, 255(white RGB values) * .8 (brightness factor) =/= 255, and the black pixels can't go lower than 0 so they remain the same.
How do I make the black pixels get lighter in the same way the white pixels get darker with a BufferedImageOp?
Here is the rescale operation
float scale = 1.3f;//This is the aformentioned "Brightness Factor"
RescaleOp op = new RescaleOp(new float[] {scale,scale,scale, 1}, new float[4], null);
BufferedImage brightImage = op.filter(...);
Thanks for the current answers, but I don't see how to apply them to my problem.
Upvotes: 2
Views: 901
Reputation: 1303
Options:
Upvotes: 0
Reputation: 8465
Anything multiplied by 0 would be 0. Use negative approach.
Maxvalue - (maxvalue/brightness factor).
255-255/1.3 in ur case.
Store that in an integer.
Upvotes: 1
Reputation: 46239
You will have to go from the max value instead. It's not obvious what the brightness factor would represent, so you will probably have to do some trial & error research here. One way could be:
int newValue = (int) (255 - (255 / 1.3));
Upvotes: 2