title: How to convert three 3D numpy arrays to RGB matrix in python
body: <p>I'm not even sure if it is possible, but I am pretty new to python.</p>
  
  <p>I have three 3D datasets, each is a 64 x 64 x 50 numpy array. I am trying to combine each 3D dataset into a single 3D RGB image, where each cell is represented by an RGB value, and each color channel represents values for a single dataset.  </p>
  
  <p>For example, my data is three different isotopes measured in a rock, so I would like R to represent the values for oxygen-16, G = sulfur-32, and B = magnesium-24.</p>
  
  <p>I have figured out how to normalize each isotope array to a discretized value between 0-255 with the following generalized equation:</p>
  
  <pre><code>new_arr = ((arr - arr.min()) * (1/(arr.max() - arr.min()) * 255).astype('uint8')
  </code></pre>
  
  <p>More specifically for my data, I have the following:</p>
  
  <pre><code>O16R = ((O16.get_data() - np.min(O16.get_data())) * (1/(np.max(O16.get_data()) - np.min(O16.get_data())) * 255).astype('uint8'))
  
  S32G = ((S32.get_data() - np.min(S32.get_data())) * (1/(np.max(S32.get_data()) - np.min(S32.get_data())) * 255).astype('uint8'))
  
  Mg24B = ((Mg24.get_data() - np.min(Mg24.get_data())) * (1/(np.max(Mg24.get_data()) - np.min(Mg24.get_data())) * 255).astype('uint8'))
  </code></pre>
  
  <p>Now, I would like to create another 64 x 64 x 50 3D array, with each index in the array defined by the RGB values corresponding to the indexed values defined above. </p>
  
  <p>For a simplified example, if I had small 2 x 1 arrays of:</p>
  
  <pre><code>O16R = (151, 3)
  
  S32G = (2 , 57)
  
  Mg24B = (0, 111)
  </code></pre>
  
  <p>Then I need a resulting RGB nested matrix with values:</p>
  
  <pre><code>RGB = ( [151,2,0] , [3,57,111] )
  </code></pre>
  
  <p>I figure that I need to create a for loop, but I haven't been able to figure it out. This is what I have so far, but it doesn't parse the data.</p>
  
  <pre><code>RGB = np.zeros(shape=(64,64,50)) 
  for i in RGB:
      RGB = ([O16R, S32G, Mg24B])
  </code></pre>
  
  <p>Any help would be appreciated.</p>