Skip to content

Instantly share code, notes, and snippets.

@KelSolaar
Created May 29, 2017 20:47
Show Gist options
  • Save KelSolaar/5e43bdcacb87bfc4f63188a3e89270b0 to your computer and use it in GitHub Desktop.
Save KelSolaar/5e43bdcacb87bfc4f63188a3e89270b0 to your computer and use it in GitHub Desktop.
HDR Merge
import os
import numpy as np
import colour
from colour_hdri import *
RESOURCES_DIRECTORY = '/Users/kelsolaar/Downloads/Tiff'
TIFF_FILES = filter_files(RESOURCES_DIRECTORY, ('tiff',))
def merge_from_tiff_files(
tiff_files,
output_directory,
batch_size=5,
white_balance_multipliers=None,
weighting_function=weighting_function_Debevec1997):
paths = []
for tiff_files in colour.batch(tiff_files, batch_size):
image_stack = ImageStack()
for tiff_file in tiff_files:
image = Image(tiff_file)
image.read_metadata()
image.read_data()
image_stack.append(image)
path = os.path.join(
output_directory,
'{0}_{1}_MRF.{2}'.format(
os.path.splitext(os.path.basename(image_stack.path[0]))[0],
batch_size,
'exr'))
paths.append(path)
image = image_stack_to_radiance_image(image_stack,
weighting_function,
weighting_average=True)
colour.write_image(image, path)
return paths
merge_from_tiff_files(TIFF_FILES, RESOURCES_DIRECTORY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment