From 6dcb5b0d0d3ca58612f84df9f2eef2b9fe8eab07 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 14 Mar 2020 22:24:45 +0100 Subject: [PATCH] vectorize --- python/damask/colormaps.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/python/damask/colormaps.py b/python/damask/colormaps.py index 4bade18f9..f86ac7d79 100644 --- a/python/damask/colormaps.py +++ b/python/damask/colormaps.py @@ -192,9 +192,9 @@ class Color: HSL[0] = HSL[0]*60.0 # scaling to 360 might be dangerous for small values if (HSL[0] < 0.0): HSL[0] = HSL[0] + 360.0 - for i in range(2): - HSL[i+1] = min(HSL[i+1],1.0) - HSL[i+1] = max(HSL[i+1],0.0) + + HSL[1:] = np.mimimum(HSL[1:],1.0) + HSL[1:] = np.maximum(HSL[1:],0.0) converted = Color('HSL', HSL) self.model = converted.model @@ -220,8 +220,7 @@ class Color: if (self.color[i] > 0.04045): RGB_lin[i] = ((self.color[i]+0.0555)/1.0555)**2.4 else: RGB_lin[i] = self.color[i] /12.92 XYZ = np.dot(convert,RGB_lin) - for i in range(3): - XYZ[i] = max(XYZ[i],0.0) + XYZ = np.maximum(XYZ,0.0) converted = Color('XYZ', XYZ) self.model = converted.model @@ -246,9 +245,9 @@ class Color: for i in range(3): if (RGB_lin[i] > 0.0031308): RGB[i] = ((RGB_lin[i])**(1.0/2.4))*1.0555-0.0555 else: RGB[i] = RGB_lin[i] *12.92 - for i in range(3): - RGB[i] = min(RGB[i],1.0) - RGB[i] = max(RGB[i],0.0) + + RGB = np.minimum(RGB,1.0) + RGB = np.maximum(RGB,0.0) maxVal = max(RGB) # clipping colors according to the display gamut if (maxVal > 1.0): RGB /= maxVal