WesleyyC / Image-Editor

A command line image editor written in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add darken function.

WesleyyC opened this issue · comments

Brighten function.

So is there any free and magic function we can use like the brighten function :p ?

Never mind. So it can be done in the same fashion as brighten function. I was trying to figure out what your numbers mean here:

double factor = 1.17 + level * 0.03;
double onset = 12 + 3 * level;

RescaleOp rescaleOp = new RescaleOp((float)factor, (int)onset, null);

It doesn't make sense to me why you would add an offset in the brighten function. I think the offset is just for tinting images (yell at me if it is not). And the scale factor you pass in looks really magical... Would you please give some more explanations?

@SerinaTan
So we are really just adjusting the element value using RescaleOp and the pseudo code for the rescaling operation is as follows:

for each pixel from Source object {
    for each band/component of the pixel {
        dstElement = (srcElement*scaleFactor) + offset
    }
}

The number is really just magic, I adjust the number by manually testing since I can't really find a great comprehensive documentation on these values.

For darken function, we can definitely judge if the level is negative or positive and apply a different function.