Improve normalise op with use of histogram #200

This commit is contained in:
Lovell Fuller
2022-09-04 10:31:43 +01:00
parent 9a54a034e1
commit 55c4d8807c
3 changed files with 7 additions and 6 deletions

View File

@@ -68,10 +68,9 @@ namespace sharp {
// Extract luminance
VImage luminance = lab[0];
// Find luminance range
VImage stats = luminance.stats();
double min = stats(0, 0)[0];
double max = stats(1, 0)[0];
if (min != max) {
int const min = luminance.percent(1);
int const max = luminance.percent(99);
if (std::abs(max - min) > 1) {
// Extract chroma
VImage chroma = lab.extract_band(1, VImage::option()->set("n", 2));
// Calculate multiplication factor and addition