Merge pull request #6256 from radarhere/furthestV

Ensure that furthest v is set in quantize2
This commit is contained in:
Hugo van Kemenade 2022-05-17 20:04:50 +03:00 committed by GitHub
commit ef8cec6185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1519,7 +1519,7 @@ error_0:
typedef struct {
Pixel new;
Pixel furthest;
uint32_t furthestV;
uint32_t furthestDistance;
int secondPixel;
} DistanceData;
@ -1536,7 +1536,7 @@ compute_distances(const HashTable *h, const Pixel pixel, uint32_t *dist, void *u
}
if (oldDist > data->furthestDistance) {
data->furthestDistance = oldDist;
data->furthest.v = pixel.v;
data->furthestV = pixel.v;
}
}
@ -1577,10 +1577,11 @@ quantize2(
data.new.c.b = (int)(.5 + (double)mean[2] / (double)nPixels);
for (i = 0; i < nQuantPixels; i++) {
data.furthestDistance = 0;
data.furthestV = pixelData[0].v;
data.secondPixel = (i == 1) ? 1 : 0;
hashtable_foreach_update(h, compute_distances, &data);
p[i].v = data.furthest.v;
data.new.v = data.furthest.v;
p[i].v = data.furthestV;
data.new.v = data.furthestV;
}
hashtable_free(h);