0

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.

Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
  • why wouldn't [`np.concatenate`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html) work when the 1-axis length is the same? Just use `axis = 1`. – Daniel F Jul 26 '17 at 06:04
  • @DanielF I followed what you said, but now it's having the opposite problem. where the values are right in terms of row, but the column size has tripled. would `axis=(0,1)` work? – Spider Jerusalem Jul 26 '17 at 13:21
  • the answer to that last question is a big nope... just tested it and it's saying an integer is required. – Spider Jerusalem Jul 26 '17 at 13:33

0 Answers0