title: convert IR image to RGB with python
body: <p>The code below is intended to take an infrared image (B&amp;W) and convert it to RGB. It does so successfully, but with significant noise. I have included a few lines for noise reduction but they don't seem to help. I've included the starting/resulting photos below. Any advice/corrections are welcome and thank you in advance!</p>
  
  <pre><code>from skimage import io
  import numpy as np
  import glob, os
  from tkinter import Tk
  from tkinter.filedialog import askdirectory
  import cv2
  
  path = askdirectory(title='Select PNG Folder') # shows dialog box and return the path
  outpath = askdirectory(title='Select SAVE Folder') 
  
  # wavelength in microns
  MWIR = 4.5
  
  R = .642
  G = .532
  B = .44
  
  vector = [R, G, B]
  vectorsum = np.sum(vector)
  vector = vector / vectorsum #normalize
  vector = vector*255 / MWIR #changing this value changes the outcome significantly so I 
  #have been messing with it in the hopes of fixing it but no luck so far.
  vector = np.power(vector, 4)
  
  for file in os.listdir(path):
    if file.endswith(".png"):
      imIn = io.imread(os.path.join(path, file))
      imOut = imIn * vector
      ret,thresh = cv2.threshold(imOut,64,255,cv2.THRESH_BINARY)
      kernel = np.ones((5, 5), np.uint8)
      erode = cv2.erode(thresh, kernel, iterations = 1)
      result = cv2.bitwise_or(imOut, erode)
      io.imsave(os.path.join(outpath, file) + '_RGB.png',imOut.astype(np.uint8))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/biGIs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/biGIs.jpg" alt="starting image"></a>
  <a href="https://i.stack.imgur.com/QVOMJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QVOMJ.jpg" alt="result image"></a></p>