From 892d5115258fe76d99114aaf4e1c53346b7a284f Mon Sep 17 00:00:00 2001 From: Sofus Rose Date: Wed, 25 Jan 2017 18:50:59 -0500 Subject: [PATCH] Solved Mac using CLang instead of gcc --- README.md | 4 ++-- openlut/ColMap.py | 19 +++++++++++++++---- openlut/LUT.py | 1 + openlut/Viewer.py | 2 +- openlut/lib/files.py | 1 + openlut/lib/olOpt.cpp | 38 +++++++++++++++++++++++++++----------- setup.py | 4 ++++ 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d75e01c..c05fb31 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# openlut +# openlut - Open-source tools for practical color management. -## Open-source tools for practical color management. +**Main development happens at https://git.sofusrose.com/so-rose/openlut - take a look! What is it? ----- diff --git a/openlut/ColMap.py b/openlut/ColMap.py index bb15021..46ecdc1 100644 --- a/openlut/ColMap.py +++ b/openlut/ColMap.py @@ -25,12 +25,23 @@ from .LUT import LUT from .Viewer import Viewer class ColMap : - def __init__(self, rgbArr) : + def __init__(self, resX, resY, depth = 16) : + self.depth = depth + self.rgbArr = + + @staticmethod + def fromArray(imgArr, depth = 16) : + self.depth = depth + self.rgbArr = np.array(rgbArr, dtype=np.float32) #Enforce 32 bit floats. Save memory. + @staticmethod def fromIntArray(imgArr) : bitDepth = int(''.join([i for i in str(imgArr.dtype) if i.isdigit()])) - return ColMap(np.divide(imgArr.astype(np.float64), 2 ** bitDepth - 1)) + + self.depth = bitDepth + + return ColMap(np.divide(imgArr.astype(np.float32), 2 ** bitDepth - 1)) #Operations - returns new ColMaps. def apply(self, transform) : @@ -38,7 +49,7 @@ class ColMap : Applies a Transform object by running its apply method. ''' #~ return transform.apply(self) - return ColMap(transform.sample(self.asarray())) + return ColMap.fromArray(transform.sample(self.asarray())) #IO Functions @staticmethod @@ -186,4 +197,4 @@ class ColMap : #Overloads def __repr__(self) : - return 'ColMap( \n\trgbArr = {0}\n)'.format('\n\t\t'.join([line.strip() for line in repr(self.rgbArr).split('\n')])) + return 'ColMap.fromArray( \n\trgbArr = {0}\n)'.format('\n\t\t'.join([line.strip() for line in repr(self.rgbArr).split('\n')])) diff --git a/openlut/LUT.py b/openlut/LUT.py index 1170367..fbf4577 100644 --- a/openlut/LUT.py +++ b/openlut/LUT.py @@ -4,6 +4,7 @@ import types import numpy as np +#scipy is an optional dependency. MOD_SCIPY = False try : from scipy.interpolate import splrep, splev diff --git a/openlut/Viewer.py b/openlut/Viewer.py index f7cc4d1..a679941 100644 --- a/openlut/Viewer.py +++ b/openlut/Viewer.py @@ -1,6 +1,6 @@ import multiprocessing as mp -#Future: Use GLFW +#Future: Use GLFW! import pygame from pygame.locals import * diff --git a/openlut/lib/files.py b/openlut/lib/files.py index 297bceb..ecb60af 100755 --- a/openlut/lib/files.py +++ b/openlut/lib/files.py @@ -21,6 +21,7 @@ import multiprocessing as mp import numpy as np +#Matplotlib is optional. MOD_MATPLOTLIB = False try: import matplotlib.pyplot as plt diff --git a/openlut/lib/olOpt.cpp b/openlut/lib/olOpt.cpp index 83b8a04..0750067 100644 --- a/openlut/lib/olOpt.cpp +++ b/openlut/lib/olOpt.cpp @@ -152,17 +152,25 @@ PYBIND11_PLUGIN(olOpt) { mod.def( "gam", &gam, - "Apply any one-argument C++ function to a flattened numpy array; vectorized & parallel." + "Apply any one-argument C++ function to a flattened numpy array; vectorized & parallel.", + py::arg("arr"), + py::arg("g_func") ); mod.def( "matr", &matr, - "Apply any flattened color matrix to a flattened numpy image array; vectorized & parallel." + "Apply any flattened color matrix to a flattened numpy image array; vectorized & parallel.", + py::arg("img"), + py::arg("mat") ); mod.def( "lut1dlin", &lut1dlin, - "Apply any 1D LUT to a flattened numpy image array; vectorized & parallel." + "Apply any 1D LUT to a flattened numpy image array; vectorized & parallel.", + py::arg("img"), + py::arg("lut"), + py::arg("lBound"), + py::arg("hBound") ); @@ -171,42 +179,50 @@ PYBIND11_PLUGIN(olOpt) { mod.def( "lin", &lin, - "The linear function." + "The linear gamma function.", + py::arg("x") ); mod.def( "sRGB", &sRGB, - "The sRGB function." + "The lin --> sRGB gamma function.", + py::arg("x") ); mod.def( "sRGBinv", &sRGBinv, - "The sRGBinv function." + "The sRGB --> lin function.", + py::arg("x") ); mod.def( "Rec709", &Rec709, - "The Rec709 function." + "The lin --> Rec709 function.", + py::arg("x") ); mod.def( "ReinhardHDR", &ReinhardHDR, - "The ReinhardHDR function." + "The lin --> ReinhardHDR function.", + py::arg("x") ); mod.def( "sLog", &sLog, - "The sLog function." + "The lin --> sLog function.", + py::arg("x") ); mod.def( "sLog2", &sLog2, - "The sLog2 function." + "The lin --> sLog2 function.", + py::arg("x") ); mod.def( "DanLog", &DanLog, - "The DanLog function." + "The lin --> DanLog function.", + py::arg("x") ); return mod.ptr(); diff --git a/setup.py b/setup.py index 3b03a06..20ec465 100755 --- a/setup.py +++ b/setup.py @@ -15,6 +15,10 @@ from setuptools import find_packages #Better - Mac & Linux only. #~ pyPath = '/usr/local/include/python{}'.format(get_python_version())' +#Make sure we're using gcc. +os.environ["CC"] = "g++" +os.environ["CXX"] = "g++" + cpp_args = ['-fopenmp', '-std=gnu++14', '-O3'] link_args = ['-fopenmp']