Fix raw histogram calculation, thanks to @agriggio, #5091

This commit is contained in:
heckflosse
2018-12-12 23:23:02 +01:00
parent 920e9f7a16
commit d47a54fb3d

View File

@@ -4833,20 +4833,27 @@ void RawImageSource::getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LU
} // end of critical region
} // end of parallel region
const auto getidx =
[&](int c, int i) -> int
{
float f = mult[c] * std::max(0.f, i - cblacksom[c]);
return f > 0.f ? (f < 1.f ? 1 : std::min(int(f), 255)) : 0;
};
for(int i = 0; i < histoSize; i++) {
int idx = std::min(255.f, mult[0] * std::max(0.f, i - cblacksom[0]));
int idx = getidx(0, i);
histRedRaw[idx] += hist[0][i];
if (ri->get_colors() > 1) {
idx = std::min(255.f, mult[1] * std::max(0.f, i - cblacksom[1]));
idx = getidx(1, i);
histGreenRaw[idx] += hist[1][i];
if (fourColours) {
idx = std::min(255.f, mult[3] * std::max(0.f, i - cblacksom[3]));
idx = getidx(3, i);
histGreenRaw[idx] += hist[3][i];
}
idx = std::min(255.f, mult[2] * std::max(0.f, i - cblacksom[2]));
idx = getidx(2, i);
histBlueRaw[idx] += hist[2][i];
}
}