Commit c34e168b authored by Martin Reinecke's avatar Martin Reinecke
Browse files

tweaks

parent e1ded885
......@@ -133,7 +133,7 @@ class GradientNormController(IterationController):
if self._iteration_limit is not None:
if self._itcount >= self._iteration_limit:
logger.warning(
"{} Iteration limit reached. Assuming convergence"
"{}Iteration limit reached. Assuming convergence"
.format("" if self._name is None else self._name+": "))
return self.CONVERGED
if self._ccount >= self._convergence_level:
......
......@@ -168,17 +168,29 @@ def _rgb_data(spectral_cube):
res[:,i] = lambda2xyz(1./E[i])
return res
def to_logscale(arr, lo, hi):
res = arr.clip(lo, hi)
res = np.log(res/hi)
tmp = np.log(hi/lo)
res += tmp
res /= tmp
return res
spectral_cube = spectral_cube.reshape((-1, spectral_cube.shape[-1]))
xyz = getxyz(spectral_cube.shape[-1])
xyz_data = np.tensordot(spectral_cube, xyz, axes=[-1, -1])
xyz_data /= xyz_data.max()
# vmax = max(xyz_data[:,0].max()/0.9505,
# xyz_data[:,1].max(),
# xyz_data[:,2].max()/1.0890)
vmax = xyz_data.max()
xyz_data /= vmax
xyz_data = to_logscale(xyz_data, 1e-3, 1.)
rgb_data = xyz_data.copy()
it = np.nditer(xyz_data[:,:,0], flags=['multi_index'])
while not it.finished:
rgb_data[it.multi_index] = _gammacorr(
np.matmul(MATRIX_SRGB_D65, xyz_data[it.multi_index]))
it.iternext()
rgb_data = rgb_data.clip(0.,1.)
return rgb_data
it = np.nditer(xyz_data[:,0], flags=['multi_index'])
for x in range(xyz_data.shape[0]):
rgb_data[x] = _gammacorr(np.matmul(MATRIX_SRGB_D65, xyz_data[x]))
rgb_data = rgb_data.clip(1e-13,1.)
return rgb_data.reshape(spectral_cube.shape[:-1]+(-1,))
def _find_closest(A, target):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment