понедельник, 1 сентября 2014 г.

Simple HDR with Linux: Hugin, Enblend and Python script.

All credits about this method are to http://photoblog.edu-perez.com/2009/02/hdr-and-linux.html , I just make a python script to make it more 'auto'.
Initial photos:


Final image:
Just put initial images and the script into the same dir (Hugin and Enblend should be installed in the system) and run script (do not forget to make it executable with 'chmod +x'), script is preconfigured for Nikon file name convention:

 #!/usr/bin/env python  
 # Credits to http://photoblog.edu-perez.com/2009/02/hdr-and-linux.html  
 # File is in public domain written by Konstantin Ladutenko  
 #  
 # Usage: Copy source image files and script to the new folder, check  
 # files_mask variable is correct, run script. Hugin tools (or Hugin  
 # itself with enblend) are needed to be preinstalled.  
 #  
   
 import sys,os,shutil,glob,subprocess  
 files_mask='DSC*' #Nikon default, e.g. DSC_2616.JPG  
 #file_mask='IMG' #Canon default  
   
 print 'Files to fuse using mask "'+files_mask+'":'  
 files=[]  
 files_string=''  
 call_align = ['align_image_stack','-a', 'aligned_']  
 for fname in glob.iglob(files_mask):  
   print fname  
   files.append(fname)  
   call_align.append(fname)  
   files_string+= fname + ' '  
 files.sort()  
 final_name = files[0][:-4]+'-'+files[-1][:-4]+'-fused.jpg'  
 print call_align  
   
 try:   
   subprocess.call(call_align)  
 except:   
   sys.exit("Problems with 'align_image_stack'! Install Hugin program!")  
   
 call_enfuse=['enfuse', '-o',final_name]  
 for fname in glob.iglob('aligned_*'):  
   call_enfuse.append(fname)  
   print fname  
 print call_enfuse  
   
 try:   
   subprocess.call(call_enfuse)  
 except:   
   sys.exit("Problems with 'enfuse'! Install Hugin program!")  
 print 'Clean up: remove *.tif files'  
 call_rm=['rm', '-f']  
 for fname in glob.iglob('*.tif'):  
   call_rm.append(fname)  
 print call_rm  
 subprocess.call(call_rm)