I would like to access the intensity of individual color pixels within the RGGB-Bayer pattern of my Sony camera. With the rawpy package it seems like I can obtain the raw_image, but it is a 2D-array of the shape (4024, 6048), which is the size of the sensor. Shouldn't the array contain RGGB-data for each pixel, and therefore have the shape (8048, 12096)?
import rawpy
im_raw = rawpy.imread('Test.ARW').raw_image
print(np.shape(im_raw))
The
RawPy
object created byrawpy.imread
has, in parallel to the pixel values in the.raw_image
array you are looking at, another.raw_colors
attribute: a second array with a number corresponding to each pixel - in the case of your sample image, they go from 0 to 3 - I assume each of these numbers is a color channel.Maybe the other attributes of the
RawPy
object have more information about how to map these indices to color channels - otherwise, just checking the libraw or Sony resources for information on this raw format, or, otherwise experimenting with the channels.As for the sensor size X image pixel size: it is just that - you have this color info for this subpixel, and Sony, pyraw and other software have the means to build an RGB image out of that. (call the .postprocess() method on the RawPy object to get a uint8 4k x 6k RGB image)