def _get_pattern_1d(preset): """ Get string pattern considering sampling types (float / int) Args: preset (dict): lut generic and sampling informations Returns: .str """ is_int = presets.is_int(preset[OUT_RANGE]) if is_int: pattern = "{0}\n" else: pattern = "{0:.6f}\n" return pattern
def _get_pattern(preset, separator=' '): """ Get string pattern considering sampling types (float / int) Args: preset (dict): lut generic and sampling informations Returns: .str """ is_int = presets.is_int(preset[OUT_RANGE]) if is_int: pattern = "{0}" + separator + "{1}" + separator + "{2}\n" else: pattern = ("{0:.6f}" + separator + "{1:.6f}" + separator + "{2:.6f}\n") return pattern
def _get_1d_data(self, process_function, preset): """ Process 1D/2D data considering LUT params Args: process_function (func): could be a processor.applyRGB (PyOpenColorIO.config.Processor) or a function that took a range of values and return the modified values. Ex: colorspace gradation functions preset (dict): lut generic and sampling informations Returns: .[Rgb] """ self.check_preset(preset) if not presets.is_1d_or_2d_preset(preset): raise AbstractLUTException(("Preset isn't valid for 1D / 2D LUT:" " {0}").format(preset)) input_range = preset[presets.IN_RANGE] output_range = preset[presets.OUT_RANGE] smooth_size = None if presets.SMOOTH in preset and not preset[presets.SMOOTH] is None: smooth_size = preset[presets.SMOOTH] if smooth_size: samples_count = smooth_size else: samples_count = pow(2, preset[presets.OUT_BITDEPTH]) is_int = presets.is_int(preset[OUT_RANGE]) compute_range = linspace(input_range[0], input_range[1], samples_count) data = [] for code_value in compute_range: norm_value = code_value if is_int: norm_value = (code_value - input_range[0]) / input_range[1] res = process_function([norm_value, norm_value, norm_value]) res = [(x * output_range[1]) + output_range[0] for x in res] if is_int: res = [int(x) for x in res] data.append(Rgb(res[0], res[1], res[2])) if smooth_size: data = self.__smooth_1d_data(data, preset) return data