From kde-commits Fri Nov 30 23:55:48 2007 From: Emanuele Tamponi Date: Fri, 30 Nov 2007 23:55:48 +0000 To: kde-commits Subject: playground/graphics/tamponi/painterlyframework/utilities/src/ipg Message-Id: <1196466948.332178.13960.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=119646695704843 SVN commit 743449 by tamponi: Another little step to the new mixer: initial implementation of the new ProfileGenerator. I hope to get it finished for tomorrow. An important idea on this side: this relies on the Chromatic Adaptation algorithm used while converting a sRGB color to a generic Reflectance rappresentation for a certain illuminant. The algorithm I use is that of Bradford, but I recently (today...) noticed that there are some free patents about chromatic adaptation and it should be good to both consider them and write the ProfileGenerator in a adaptation-algorithm-indipendent way. Goodnight! D Makefile D ipg.pro M +43 -3 profile_generator.cpp M +9 -5 profile_generator.h --- trunk/playground/graphics/tamponi/painterlyframework/utilities/src/ipg/profile_generator.cpp #743448:743449 @@ -2,14 +2,54 @@ #include "profile_generator.h" +#include + +#include "function.h" + #include #include -#include "function.h" +#include +#include +#include -ProfileGenerator::ProfileGenerator(unsigned int num, const Function &hFunct) - : m_num(num), m_hFunct(hFunct) +ProfileGenerator::ProfileGenerator(unsigned int N, const Function &H) + : m_N(N), m_H(H) { + // 1- Load CMFs + // 2- Generate GQ for each CMF*m_hFunct + // 3- Build the H matrix + // 4- Build Chromaticity Adaptation matrix + // 5- Build R as M^-1 * A^-1 * H + // 6- Order wavelenghts + // 7- Save matrix and wavelenght order ( in save() ) + + // 1 + Function x("resources/CMFs/2deg_x.txt"); + Function y("resources/CMFs/2deg_y.txt"); + Function z("resources/CMFs/2deg_z.txt"); + + // 2 + GaussianQuadrature wx(N, x*H); + GaussianQuadrature wy(N, y*H); + GaussianQuadrature wz(N, z*H); + + // 3 + m_T = gsl_matrix_alloc(3, 3*N); + gsl_matrix_set_zero(m_T); + + double k = 0; + for (int j = 0; j < N; j++) + k += wy.weights()[j]; + for (int j = 0; j < N; j++) { + gsl_matrix_set(m_T, 0, 0*N, wx.weights()[j]); + gsl_matrix_set(m_T, 1, 1*N, wy.weights()[j]); + gsl_matrix_set(m_T, 2, 2*N, wz.weights()[j]); + } + gsl_matrix_scale(m_T, 1.0/k); + + // 4 + } ProfileGenerator::~ProfileGenerator() --- trunk/playground/graphics/tamponi/painterlyframework/utilities/src/ipg/profile_generator.h #743448:743449 @@ -3,24 +3,28 @@ #ifndef PROFILE_GENERATOR_H_ #define PROFILE_GENERATOR_H_ -#include #include "function.h" +#include + +#include + class Function; class QString; class ProfileGenerator { public: - ProfileGenerator(unsigned int num, const Function &hFunct); + ProfileGenerator(unsigned int N, const Function &H); ~ProfileGenerator(); bool save(const QString &filename); private: - unsigned int m_num; - Function m_hFunct; - QVector m_sortedWL; + unsigned int m_N; // TODO can we remove this? + Function m_H; // TODO can we remove this? + gsl_matrix *m_T; // Transformation matrix + QVector m_sortedWL; };