Solved Mac using CLang instead of gcc

master
Sofus Albert Høgsbro Rose 2017-01-25 18:50:59 -05:00
parent 4b29cd4f17
commit 892d511525
Signed by: so-rose
GPG Key ID: 3D01BE95F3EFFEB9
7 changed files with 51 additions and 18 deletions

View File

@ -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? What is it?
----- -----

View File

@ -25,12 +25,23 @@ from .LUT import LUT
from .Viewer import Viewer from .Viewer import Viewer
class ColMap : 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. self.rgbArr = np.array(rgbArr, dtype=np.float32) #Enforce 32 bit floats. Save memory.
@staticmethod
def fromIntArray(imgArr) : def fromIntArray(imgArr) :
bitDepth = int(''.join([i for i in str(imgArr.dtype) if i.isdigit()])) 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. #Operations - returns new ColMaps.
def apply(self, transform) : def apply(self, transform) :
@ -38,7 +49,7 @@ class ColMap :
Applies a Transform object by running its apply method. Applies a Transform object by running its apply method.
''' '''
#~ return transform.apply(self) #~ return transform.apply(self)
return ColMap(transform.sample(self.asarray())) return ColMap.fromArray(transform.sample(self.asarray()))
#IO Functions #IO Functions
@staticmethod @staticmethod
@ -186,4 +197,4 @@ class ColMap :
#Overloads #Overloads
def __repr__(self) : 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')]))

View File

@ -4,6 +4,7 @@ import types
import numpy as np import numpy as np
#scipy is an optional dependency.
MOD_SCIPY = False MOD_SCIPY = False
try : try :
from scipy.interpolate import splrep, splev from scipy.interpolate import splrep, splev

View File

@ -1,6 +1,6 @@
import multiprocessing as mp import multiprocessing as mp
#Future: Use GLFW #Future: Use GLFW!
import pygame import pygame
from pygame.locals import * from pygame.locals import *

View File

@ -21,6 +21,7 @@ import multiprocessing as mp
import numpy as np import numpy as np
#Matplotlib is optional.
MOD_MATPLOTLIB = False MOD_MATPLOTLIB = False
try: try:
import matplotlib.pyplot as plt import matplotlib.pyplot as plt

View File

@ -152,17 +152,25 @@ PYBIND11_PLUGIN(olOpt) {
mod.def( "gam", mod.def( "gam",
&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", mod.def( "matr",
&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", mod.def( "lut1dlin",
&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", mod.def( "lin",
&lin, &lin,
"The linear function." "The linear gamma function.",
py::arg("x")
); );
mod.def( "sRGB", mod.def( "sRGB",
&sRGB, &sRGB,
"The sRGB function." "The lin --> sRGB gamma function.",
py::arg("x")
); );
mod.def( "sRGBinv", mod.def( "sRGBinv",
&sRGBinv, &sRGBinv,
"The sRGBinv function." "The sRGB --> lin function.",
py::arg("x")
); );
mod.def( "Rec709", mod.def( "Rec709",
&Rec709, &Rec709,
"The Rec709 function." "The lin --> Rec709 function.",
py::arg("x")
); );
mod.def( "ReinhardHDR", mod.def( "ReinhardHDR",
&ReinhardHDR, &ReinhardHDR,
"The ReinhardHDR function." "The lin --> ReinhardHDR function.",
py::arg("x")
); );
mod.def( "sLog", mod.def( "sLog",
&sLog, &sLog,
"The sLog function." "The lin --> sLog function.",
py::arg("x")
); );
mod.def( "sLog2", mod.def( "sLog2",
&sLog2, &sLog2,
"The sLog2 function." "The lin --> sLog2 function.",
py::arg("x")
); );
mod.def( "DanLog", mod.def( "DanLog",
&DanLog, &DanLog,
"The DanLog function." "The lin --> DanLog function.",
py::arg("x")
); );
return mod.ptr(); return mod.ptr();

View File

@ -15,6 +15,10 @@ from setuptools import find_packages
#Better - Mac & Linux only. #Better - Mac & Linux only.
#~ pyPath = '/usr/local/include/python{}'.format(get_python_version())' #~ 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'] cpp_args = ['-fopenmp', '-std=gnu++14', '-O3']
link_args = ['-fopenmp'] link_args = ['-fopenmp']