I’m just learning OpenCV. The book I’m reading recommends that for operations where I need to touch every pixel, I use a double for loop with pointer arithmetic, stepWidth, etc to go from one to the next.
I’m having a hard time visualizing exactly what the IplImage looks like in memory, is it RGBRGB or RRRGGGBBB, are these all numbers, do they pack them into larger 32 bit if there are 8 bit images…etc, etc.
Does anyone know of a visual or can explain the underlying way that OpenCV images are allocated and which datatypes go where? I realize it depeneds on whether pixels or planing, etc but it would be cool to see visually a few examples spelled out with byte counts to be able to better understand how to iterate through
thanks!
The internal format is 3x8bytes, one for each pixel in BGR order.
row0: BGR(column0) BGR(column1) …….
If the width of the image * 3bytes isn’t a multiple of 4 the next row of the image will begin on the next 4byte boundary. This is because memory access is normally faster on 32bit boundaries on most modern machines
See Fastest way to extract individual pixel data?