SHARE
TWEET

whatnick

a guest Sep 28th, 2010 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!python
  2.  
  3. """
  4. This script is designed to register RGB and IR
  5. images acquired from different cameras with different
  6. orientation and produce a 4-band subset.
  7. """
  8.  
  9. import pylab as plt
  10. import numpy as np
  11. import PIL.Image as im
  12. import sys
  13.  
  14. def register_images(ir_image,rgb_image):
  15.     """
  16.    Implement some sort of global registration
  17.    """
  18.     t_xsize = 600
  19.     t_ysize = 385
  20.    
  21.     f_xsize = 640
  22.     f_ysize = 480
  23.     return t_xsize,t_ysize,f_xsize,f_ysize
  24.  
  25. if __name__=="__main__":
  26.    
  27.     if(len(sys.argv)==3):
  28.         ir_image = plt.imread(sys.argv[1])
  29.         rgb_image = plt.imread(sys.argv[2])
  30.     else:
  31.         ir_image = plt.imread("0.jpg")
  32.         rgb_image = plt.imread("1.jpg")
  33.        
  34.     t_xsize,t_ysize,f_xsize,f_ysize = register_images(ir_image, rgb_image)
  35.    
  36.     cir_image = np.zeros((t_ysize,t_xsize,3),dtype="int8")
  37.    
  38.     ir_subset = ir_image[f_ysize-t_ysize:f_xsize,0:t_xsize,:]
  39.     rgb_subset = rgb_image[0:t_ysize,f_xsize-t_xsize:f_xsize,:]  
  40.    
  41.     cir_image[:,:,0] = ir_subset[:,:,0]
  42.     cir_image[:,:,1] = rgb_subset[:,:,0]
  43.     cir_image[:,:,2] = rgb_subset[:,:,1]
  44.    
  45.     ir_im = im.fromarray(ir_subset)
  46.     rgb_im = im.fromarray(rgb_subset)
  47.     cir_im = im.fromarray(cir_image)
  48.    
  49.     cir_im = cir_im.transpose(im.FLIP_TOP_BOTTOM)
  50.     ir_im = ir_im.transpose(im.FLIP_TOP_BOTTOM)
  51.     rgb_im = rgb_im.transpose(im.FLIP_TOP_BOTTOM)
  52.    
  53.     ir_im.save("ir_image.png")
  54.     rgb_im.save("rgb_image.png")
  55.     cir_im.save("cir_image.png")
RAW Paste Data
Top