RGB RAW values

I would like to know if it is possible to get the RAW tuple values of a pixel after a snapshot with the “BAYER” mode. I’m am actually using the get_pixel() function with “True” parameter to get the tuple value. However, I noticed that the “Blue” value is always the same as the “Red” one. In “RGB565” mode it works fine, but I would like to do it in “BAYER” mode to get the RAW values. I also noticed that the “BAYER” mode is on 8-bits, is it the reason why it is not working?

Finally, I just want to know if it is possible to do it and how with the IDE. My goal is simply to print each value after that.


In bayer mode there’s no RGB888 tuple. The RAW bayer image is just grayscale basically with color in a bayer pattern. The concept of the RGB888 tuple doesn’t make sense:

int pixel = IMAGE_GET_GRAYSCALE_PIXEL(arg_img, arg_x, arg_y); // Correct!
mp_obj_t pixel_tuple[3];
pixel_tuple[0] = mp_obj_new_int(COLOR_RGB565_TO_R8(COLOR_GRAYSCALE_TO_RGB565(pixel)));
pixel_tuple[1] = mp_obj_new_int(COLOR_RGB565_TO_G8(COLOR_GRAYSCALE_TO_RGB565(pixel)));
pixel_tuple[2] = mp_obj_new_int(COLOR_RGB565_TO_B8(COLOR_GRAYSCALE_TO_RGB565(pixel)));
return mp_obj_new_tuple(3, pixel_tuple);

The current code doesn’t do what you want. What you’d like for it to do is to Debayer the image for that particular pixel and then return the RGB888 tuple for that pixel. And then rgbtuple is not true you’d like the grayscale pixel bayer value right?

If this is correct, please create a github issue ticket for this.

I can create one for you also if this is difficult.

Thanks for fast reply.
Well, I just want to collect RAW value for each pixel. If it’s what you explained, I would be happy if you create a ticket yes.
Thank you.

When you say the red and blue value is always the same, do you mean for every pixel in the image (which would imply a bug that should be fixed), or for some particular pixel or set of pixels? Sounds like you’re looking at the green pixels of the Bayer matrix. When you say you want the RAW value of a pixel, do you mean as close to the original sensor pixel value as possible, which is a single value, not an RGB tuple, namely the intensity of light captured by the pixel after going through a red, green, or blue Bayer filter over that pixel? Or do you mean you want a “raw RGB” value, which isn’t really a meaningful concept, but I can see how one might think it is a thing since a lot of photo software will open a RAW image and then display it in color, giving people the impression that RAW images are color images, when, strictly speaking, they are single channel mosaics of three colors (Bayer patterns)? When RAW software displays a RAW image in color, it is deBayering the image before it displays it to you. The “real RAW” image is grayscale. Which is why, as you pointed out, the Bayer images are 8-bit images. They only contain a single value per pixel.


Thank you Nyamekye.
One last question, how do I update this file to get this modification working?

And Kwiley, I thought RAW image was simply each RGB values of one pixel without any image processing around it. I didn’t think it was grayscale. Thank you.

What camera model do you have? I can generate the firmware binary.

I have the OV7725-M7 and the 3.6.2 firmware version

M7 Firmware.
firmware.zip (1.15 MB)

Thank you.

Do I simply need to copy this new bin and replace it in the firmware folders (\OpenMV IDE\share\qtcreator\firmware\OPENMV4P) or do I also need to execute the bootloarder for this to work?

Tools->Run Bootloader and select the file.