Skip to content

Commit

Permalink
When testing on multiple images, looks like inverse gamma is not needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-trinh committed Oct 18, 2024
1 parent 6db5198 commit 0533dbf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions modules/imgproc/src/vpImgproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,12 @@ void gammaCorrectionLogMethod(vpImage<unsigned char> &I, const vpImage<bool> *p_
unsigned char inputRange = inputMax - inputMin;

float gamma_computed = static_cast<float>((std::log(128.f) - std::log(256.f)) / (std::log(mean) - std::log(inputRange)));
float inverse_gamma = 1.f / gamma_computed;

// Construct the look-up table
unsigned char lut[256];
float inputRangeAsFloat = static_cast<float>(inputRange);
for (unsigned int i = inputMin; i <= inputMax; ++i) {
lut[i] = vpMath::saturate<unsigned char>(std::pow(static_cast<float>(i - inputMin) / inputRangeAsFloat, inverse_gamma) * 255.f);
lut[i] = vpMath::saturate<unsigned char>(std::pow(static_cast<float>(i - inputMin) / inputRangeAsFloat, gamma_computed) * 255.f);
}

I.performLut(lut);
Expand Down

0 comments on commit 0533dbf

Please sign in to comment.