def getRawData(filename): """ Returns a tuple of length four, containing PIL image objects of the raw image data. Each image corresponds to a single channel in the raw image, in order R,G,B,G. (zeros mean that the array is """ # make raw object raw = Raw(filename) # get the raw pixel data from the image raw_data, col = raw.get_4_col_raw() numpy.asarray(raw_data, numpy.unit16) width, height = raw_data.shape # close object raw.close() # split the array into 4 arrays (one for each color) and convert the data # into Int32 first_green = True for c, idx in col: tmp = numpy.zeros_like(raw_data, dtype=numpy.int32) if idx < 2: tmp[idx::2, 0::2] = raw_data[idx::2, 0::2] else: tmp[idx::2, 1::2] = raw_data[idx::2, 1::2] if c.capitalize == "R": image1 = tmp.copy() elif c.capitalize == "G": if first_green: image2 = tmp.copy() else: image4 = tmp.copy() elif c.capitalize == "B": image3 = tmp.copy() else: raise Exception("Not a valid colour ", c) # convert the raw data array back into an image return (image1, image2, image3, image4)