Fix average color computation
This commit is contained in:
parent
f5621ac8e1
commit
fbd39cdcdf
1 changed files with 3 additions and 1 deletions
|
@ -463,6 +463,7 @@ unsigned char computeAverageColor(const unsigned char *texture, int16_t excludeC
|
|||
uint32_t sumS = 0;
|
||||
uint32_t sumV = 0;
|
||||
uint32_t pixels = texture[0] * texture[1];
|
||||
uint32_t count = 0;
|
||||
|
||||
for (uint16_t i = 0; i < pixels; ++i)
|
||||
{
|
||||
|
@ -476,9 +477,10 @@ unsigned char computeAverageColor(const unsigned char *texture, int16_t excludeC
|
|||
sumH += h;
|
||||
sumS += s;
|
||||
sumV += v;
|
||||
count++;
|
||||
}
|
||||
|
||||
return encodeHSV(sumH / pixels,sumS / pixels, sumV / pixels);
|
||||
return encodeHSV(sumH / count,sumS / count, sumV / count);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue