Example #1
0
  def invalidate_by_index(self, index):
    if Configuration.leonhardt_tmo.preview:
      image = Configuration.leonhardt_tmo.processor[index]
    else:
      image = Configuration.sequence[index]

    image = remove_specials(numpy.rollaxis(image, 1) * numpy.exp(self.exposure))

    # Linear to sRGB
    image = numpy.where(image <= 0.0031308,
                        image * 12.92,
                        1.055 * numpy.power(image, 1.0 / 2.4) - 0.055)

    self.image_item.setImage(image, levels=[0, 1])
if __name__ == '__main__':

  filename = "/Volumes/Daten/EXR/Untitled.vtmo"
  with open(filename, 'r') as f:
    config = msgpack.unpack(f)

  sequence = ImageSequence(config['_sequence'])
  frame = sequence[frame_index]
  abs_index = sequence.frame_range.absolutize(frame_index)

  brightness = numpy.zeros(shape=(len(sequence.frame_range), 3))
  key = numpy.zeros(shape=(len(sequence.frame_range), 3))

  for channel_index in range(frame.shape[-1]):
    channel = remove_specials(frame[..., channel_index])
    [min_lum, max_lum] = numpy.percentile(channel, [quantile_lower_parameter * 100.0, quantile_upper_parameter * 100.0])
    channel_percentiled = numpy.clip(channel, min_lum, max_lum)
    min_lum = numpy.log(min_lum)
    max_lum = numpy.log(max_lum)
    world_lum = numpy.mean(numpy.log(channel_percentiled))
    key[abs_index, channel_index] = (max_lum - world_lum) / (max_lum - min_lum + EPSILON)
    brightness[abs_index, channel_index] = math.exp((max_lum + min_lum) / (max_lum - min_lum + EPSILON))

  contrast = numpy.zeros(key.shape)

  for i in range(key.shape[1]):
    # brightness[..., i] = wlsfilter(brightness[..., i], 1.2, 1.0)
    contrast[..., i] = (1 - contrast_parameter) + (contrast_parameter * key[..., i])

  hdr = sequence[frame_index]