/* * This file is part of RawTherapee. * * Copyright (c) 2004-2010 Gabor Horvath * * RawTherapee is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * RawTherapee is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ #ifndef _IMPROCFUN_H_ #define _IMPROCFUN_H_ #include "imagefloat.h" #include "image16.h" #include "image8.h" #include "procparams.h" #include "shmap.h" #include "coord2d.h" #include "color.h" #include "labimage.h" #include "cieimage.h" #include "LUT.h" #include "lcp.h" #include "curves.h" #include #include "cplx_wavelet_dec.h" namespace rtengine { using namespace procparams; class ImProcFunctions { static LUTf gamma2curve; cmsHTRANSFORM monitorTransform; const ProcParams* params; double scale; bool multiThread; void calcVignettingParams(int oW, int oH, const VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul); void transformPreview (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LCPMapper *pLCPMap); void transformLuminanceOnly (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH); void transformHighQuality (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LCPMapper *pLCPMap, bool fullImage); void sharpenHaloCtrl (LabImage* lab, float** blurmap, float** base, int W, int H); void sharpenHaloCtrlcam (CieImage* ncie, float** blurmap, float** base, int W, int H); void firstAnalysisThread(Imagefloat* original, Glib::ustring wprofile, unsigned int* histogram, int row_from, int row_to); void dcdamping (float** aI, float** aO, float damping, int W, int H); bool needsCA (); bool needsDistortion (); bool needsRotation (); bool needsPerspective (); bool needsGradient (); bool needsVignetting (); bool needsLCP (); // static cmsUInt8Number* Mempro = NULL; inline void interpolateTransformCubic (Imagefloat* src, int xs, int ys, double Dx, double Dy, float *r, float *g, float *b, double mul) { const double A=-0.85; double w[4]; { double t1, t2; t1 = -A*(Dx-1.0)*Dx; t2 = (3.0-2.0*Dx)*Dx*Dx; w[3] = t1*Dx; w[2] = t1*(Dx-1.0) + t2; w[1] = -t1*Dx + 1.0 - t2; w[0] = -t1*(Dx-1.0); } double rd, gd, bd; double yr[4], yg[4], yb[4]; for (int k=ys, kx=0; kr(k,i) * w[ix]; gd += src->g(k,i) * w[ix]; bd += src->b(k,i) * w[ix]; } yr[kx] = rd; yg[kx] = gd; yb[kx] = bd; } { double t1, t2; t1 = -A*(Dy-1.0)*Dy; t2 = (3.0-2.0*Dy)*Dy*Dy; w[3] = t1*Dy; w[2] = t1*(Dy-1.0) + t2; w[1] = -t1*Dy + 1.0 - t2; w[0] = -t1*(Dy-1.0); } rd = gd = bd = 0.0; for (int i=0; i<4; i++) { rd += yr[i] * w[i]; gd += yg[i] * w[i]; bd += yb[i] * w[i]; } *r = rd * mul; *g = gd * mul; *b = bd * mul; // if (xs==100 && ys==100) // printf ("r=%g, g=%g\n", *r, *g); } inline void interpolateTransformChannelsCubic (float** src, int xs, int ys, double Dx, double Dy, float *r, double mul) { const double A=-0.85; double w[4]; { double t1, t2; t1 = -A*(Dx-1.0)*Dx; t2 = (3.0-2.0*Dx)*Dx*Dx; w[3] = t1*Dx; w[2] = t1*(Dx-1.0) + t2; w[1] = -t1*Dx + 1.0 - t2; w[0] = -t1*(Dx-1.0); } double rd; double yr[4]; for (int k=ys, kx=0; kdefault // CieImage *ciec; bool transCoord (int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LCPMapper *pLCPMap=NULL); bool transCoord (int W, int H, const std::vector &src, std::vector &red, std::vector &green, std::vector &blue, double ascaleDef = -1, const LCPMapper *pLCPMap=NULL); static void getAutoExp (LUTu & histogram, int histcompr, double defgain, double clip, double& expcomp, int& bright, int& contr, int& black, int& hlcompr, int& hlcomprthresh); static double getAutoDistor (const Glib::ustring& fname, int thumb_size); double getTransformAutoFill (int oW, int oH, const LCPMapper *pLCPMap=NULL); }; } #endif