So I'm trying to create an image out of the mean pixel values from images that have been saved as 2d arrays. With the dark frames this was fairly easy, I just had to create a running average. With exposure time it's a bit more complicated because I have to separate images using RGB masks. I'm having trouble combining those masks back into a coherent image. Here's the code for the creation of the mean value array:
def set_bright_mean_array(self, directories):
green_composite= np.zeros((self.rows, self.columns))
red_composite=blue_composite=green_composite
n=0
for k in range (len(directories)):
exposure_file_names = self.set_exposure_file_names(self.exposure_directories[k])
for i in range(len(exposure_file_names)):
print ('directory: %s -- loop: %s' % (directories[k], n))
temp_array=np.load(exposure_file_names[i])
green_delta = np.ma.masked_array(temp_array, self.green_mask_whole)-green_composite
blue_delta = np.ma.masked_array(temp_array, self.blue_mask_whole)-blue_composite
red_delta = np.ma.masked_array(temp_array, self.red_mask_whole)-red_composite
n=n+1
green_composite=green_composite+green_delta/n
blue_composite=blue_composite+blue_delta/n
red_composite=red_composite+red_delta/n
return np.concatenate((green_composite, blue_composite, red_composite))
np.concatenate
doesn't work, because the shape of the array is (7392, 3280) as opposed to the original image size: (2464, 3280). zip
didn't work because it returns a zip object, and I have to plot this afterwards.
Edit:
For clarification, the masked arrays are the same shape as the original array, with blank values (--, not sure on dtype) in place of actual numbers in the pixels that aren't the right color. What I need to do is figure out how to join them together, while replacing the empty values with the values from the other masked arrays to create an actual RGGB image.