is it a bug in image.div

General discussion about topics related to OpenMV.
satbirsoni
Posts: 3
Joined: Thu Dec 13, 2018 1:17 am

is it a bug in image.div

Postby satbirsoni » Thu Dec 13, 2018 11:52 pm

Code: Select all

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

Code: Select all

 
            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);
User avatar
kwagyeman
Posts: 2802
Joined: Sun May 24, 2015 2:10 pm

Re: is it a bug in image.div

Postby kwagyeman » Fri Dec 14, 2018 10:03 am

Hmm, maybe. I remember writing it like that for a reason. It had to do with the fact that if you divide two images with similar values you will end up with a valid image. If I divide by pScale again then you can't divide two images by each other and get a valid result.

Um, given the above. I think I should change the documentation to say the output is multiplied by 255.

Should I add any input scaling on the input when the value to divide by is a scalar? The issue is that the pScale value differs by the image type.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests