title: How to merge channel images into RGB image
body: <p>I read image data arrays respectively from three datasets(blue,green,red channel) in a HDF5 file,which is a format of file for storing data.the data type are uint16,the arrays are 2D with length of 2748*2748.The py code is as below(maybe some tricky but I don't know the reason behind it):</p>
  <pre><code>from pyhdf.SD import SD, SDC
  from PIL import Image
  import h5py
  
  hdf5File = h5py.File('channelImgData.HDF', 'r')
  ...
  # Channel01,02,03 are all arrays reading from a .HDF file,i.e,[65535,65535,...,65535] for length of 2748*2748
  # the confusions here are multiply the data by 0.1 and convert the generated image into gray...
  r = Image.fromarray(Channel03*0.1).convert('L')
  g = Image.fromarray(Channel02*0.1).convert('L')
  b = Image.fromarray(Channel01*0.1).convert('L')
  
  # merge the gray images into a RGB image...
  image_output = Image.merge(&quot;RGB&quot;, (r, g, b))
  image_output.save(&quot;map_picture.bmp)
  </code></pre>
  <p>And the result is as below:
  <a href="https://i.stack.imgur.com/zFq0Q.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I tried the following with Go in my own way :</p>
  <pre><code>    rect := image.Rect(0, 0, 2748, 2748)
      imgSet := image.NewRGBA64(rect)
  
      for i := 0; i &lt; length; i++ {
          x := i % 2748
          y := i / 2748
          pixel := color.RGBA64{
              // channel1,2,3 are the same with the above py code
              R: channel3[i], 
              G: channel2[i],
              B: channel1[i],
              A: 0,
          }
          imgSet.Set(x, y, color.RGBA64Model.Convert(pixel))
      }
  
      outFile, err := os.Create(&quot;hybrid.bmp&quot;)
      if err != nil {
          t.Error(err)
          return
      }
      defer outFile.Close()
      err = bmp.Encode(outFile, imgSet)
      if err != nil {
          t.Error(err)
          return
      }
  }
  </code></pre>
  <p>The result image is recognizable but very lossy...<a href="https://i.stack.imgur.com/v9YVV.jpg" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I find the problem lies in I wrongly implemented the the py function image.fromarray.
  So how to implement the same behaviour as image.fromarray using go?</p>