1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
int brightness = getIntValue("brightness");
int contrast = getIntValue("contrast");
//on multiplie chaque pixel par alpha*pixel+beta de telle manière que si brightness est nulle, l
// la courbe passe par (128,128)
double alpha;
double beta;
double contrastFactor = 0.01;
if(contrast>=0)
alpha=contrast*contrastFactor+1;
else
alpha=(1/(-contrast*contrastFactor+1));
beta=brightness+128-(128*alpha);
short lutTable[] = new short[256];
for(int i = 0; i<lutTable.length;i++) {
int value = (int) (alpha*i+beta);
if(value>255) value=255;
if(value<0) value = 0;
lutTable[i] = (short) value;
}
LookupOperator op = new LookupOperator(lutTable);
op.compute(output, getInputImage());
return output; |