print("Before: ", img.get_pixel(1,1))
img.div(2)
print("After: ", img.get_pixel(1,1))
Before: 166
After: 255
Are we missing a division after multipling with pScale
int pScale = COLOR_GRAYSCALE_MAX - COLOR_GRAYSCALE_MIN; // <--------------- see this
for (int i = 0, j = img->w; i < j; i++) {
if ((!mask) || image_get_mask_pixel(mask, i, line)) {
int dataPixel = IMAGE_GET_GRAYSCALE_PIXEL_FAST(data, i);
int otherPixel = IMAGE_GET_GRAYSCALE_PIXEL_FAST(((uint8_t *) other), i);
int p = IM_DIV((invert?otherPixel:dataPixel) * pScale, (invert?dataPixel:otherPixel)); <------- And here
p = IM_MIN(p, COLOR_GRAYSCALE_MAX);