/* * 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 _RAWIMAGESOURCE_ #define _RAWIMAGESOURCE_ #include #include #define HR_SCALE 2 namespace rtengine { template void freeArray (T** a, int H) { //for (int i=0; i T** allocArray (int W, int H) { T** t = new T*[H]; t[0] = new T[H*W]; for (int i=1; i void freeArray2 (T** a, int H) { //for (int i=0; iFC(row,col); } inline void getRowStartEnd (int x, int &start, int &end); public: RawImageSource (); ~RawImageSource (); int load (Glib::ustring fname, bool batch = false); void preprocess (const RAWParams &raw); void demosaic (const RAWParams &raw); void copyOriginalPixels(const RAWParams &raw, RawImage *ri, RawImage *riDark, RawImage *riFlatFile ); void cfaboxblur (RawImage *riFlatFile, float* cfablur, int boxH, int boxW ); void scaleColors (int winx,int winy,int winw,int winh ); void getImage (ColorTemp ctemp, int tran, Imagefloat* image, PreviewProps pp, HRecParams hrp, ColorManagementParams cmp, RAWParams raw); ColorTemp getWB () { return wb; } ColorTemp getAutoWB (); ColorTemp getSpotWB (std::vector red, std::vector green, std::vector& blue, int tran); double getDefGain () { return defGain; } // double getGamma () { return 2.2; } double getGamma () { return 2.4; }//normalize gamma to sRGB void getFullSize (int& w, int& h, int tr = TR_NONE); void getSize (int tran, PreviewProps pp, int& w, int& h); ImageData* getImageData () { return idata; } void setProgressListener (ProgressListener* pl) { plistener = pl; } void getAutoExpHistogram (LUTu & histogram, int& histcompr); void getRAWHistogram (LUTu & histRedRaw, LUTu & histGreenRaw, LUTu & histBlueRaw); static void colorSpaceConversion16 (Image16* im, ColorManagementParams cmp, cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], double& defgain); static void colorSpaceConversion (Imagefloat* im, ColorManagementParams cmp, cmsHPROFILE embedded, cmsHPROFILE camprofile, double cam[3][3], double& defgain); static void inverse33 (double (*coeff)[3], double (*icoeff)[3]); static void HLRecovery_Luminance (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval); static void HLRecovery_CIELab (float* rin, float* gin, float* bin, float* rout, float* gout, float* bout, int width, float maxval, double cam[3][3], double icam[3][3]); protected: typedef unsigned short ushort; void correction_YIQ_LQ (Imagefloat* i, int times); inline void convert_row_to_YIQ (float* r, float* g, float* b, float* Y, float* I, float* Q, int W); inline void convert_row_to_RGB (float* r, float* g, float* b, float* Y, float* I, float* Q, int W); inline void convert_to_cielab_row (float* ar, float* ag, float* ab, float* oL, float* oa, float* ob); inline void interpolate_row_g (float* agh, float* agv, int i); inline void interpolate_row_rb (float* ar, float* ab, float* pg, float* cg, float* ng, int i); inline void interpolate_row_rb_mul_pp (float* ar, float* ab, float* pg, float* cg, float* ng, int i, double r_mul, double g_mul, double b_mul, int x1, int width, int skip); int LinEqSolve( int nDim, float* pfMatr, float* pfVect, float* pfSolution);//Emil's CA auto correction void CA_correct_RT (double cared, double cablue); void ddct8x8s(int isgn, float **a); void exp_bef (float expos, float preser); // exposure before interpolation int cfaCleanFromMap( PixelsMap &bitmapBads ); int findHotDeadPixel( PixelsMap &bpMap, float thresh); void cfa_linedn (float linenoiselevel);//Emil's line denoise void green_equilibrate (float greenthresh);//Emil's green equilibration void nodemosaic(); void eahd_demosaic(); void hphd_demosaic(); void vng4_demosaic(); void ppg_demosaic(); void amaze_demosaic_RT(int winx, int winy, int winw, int winh);//Emil's code for AMaZE void fast_demo(int winx, int winy, int winw, int winh);//Emil's code for fast demosaicing void dcb_demosaic(int iterations, int dcb_enhance); void ahd_demosaic(int winx, int winy, int winw, int winh); void border_interpolate(int border, float (*image)[4], int start = 0, int end = 0); void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border); void fill_raw( float (*cache )[4], int x0, int y0, float** rawData); void fill_border( float (*cache )[4], int border, int x0, int y0); void copy_to_buffer(float (*image2)[3], float (*image)[4]); void dcb_hid(float (*image)[4], float (*bufferH)[3], float (*bufferV)[3], int x0, int y0); void dcb_color(float (*image)[4], int x0, int y0); void dcb_hid2(float (*image)[4], int x0, int y0); void dcb_map(float (*image)[4], int x0, int y0); void dcb_correction(float (*image)[4], int x0, int y0); void dcb_pp(float (*image)[4], int x0, int y0); void dcb_correction2(float (*image)[4], int x0, int y0); void restore_from_buffer(float (*image)[4], float (*image2)[3]); void dcb_refinement(float (*image)[4], int x0, int y0); void dcb_color_full(float (*image)[4], int x0, int y0, float (*chroma)[2]); void transLine (float* red, float* green, float* blue, int i, Imagefloat* image, int tran, int imw, int imh, int fw); void hflip (Imagefloat* im); void vflip (Imagefloat* im); }; }; #endif