Apply rotation parameters to reference image for profiling, Issue 2748

This commit is contained in:
Ingo 2015-04-22 14:22:35 +02:00
parent 336a08d605
commit 1d84dd1e7e
8 changed files with 68 additions and 188 deletions

View File

@ -143,14 +143,7 @@ void Crop::update (int todo) {
if (todo & (M_INIT|M_LINDENOISE)) { if (todo & (M_INIT|M_LINDENOISE)) {
MyMutex::MyLock lock(parent->minit); // Also used in improccoord MyMutex::MyLock lock(parent->minit); // Also used in improccoord
int tr = TR_NONE; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
else if (params.coarse.rotate==180) tr |= TR_R180;
else if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
if (!needsinitupdate) if (!needsinitupdate)
setCropSizes (rqcropx, rqcropy, rqcropw, rqcroph, skip, true); setCropSizes (rqcropx, rqcropy, rqcropw, rqcroph, skip, true);
@ -908,12 +901,7 @@ if (settings->verbose) printf ("setcropsizes before lock\n");
ProcParams& params = parent->params; ProcParams& params = parent->params;
parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh); parent->ipf.transCoord (parent->fw, parent->fh, bx1, by1, bw, bh, orx, ory, orw, orh);
int tr = TR_NONE; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
PreviewProps cp (orx, ory, orw, orh, skip); PreviewProps cp (orx, ory, orw, orh, skip);
int orW, orH; int orW, orH;

View File

@ -22,3 +22,22 @@
const char rtengine::sImage8[] = "Image8"; const char rtengine::sImage8[] = "Image8";
const char rtengine::sImage16[] = "Image16"; const char rtengine::sImage16[] = "Image16";
const char rtengine::sImagefloat[] = "Imagefloat"; const char rtengine::sImagefloat[] = "Imagefloat";
int rtengine::getCoarseBitMask( const procparams::CoarseTransformParams &coarse)
{
int tr = TR_NONE;
if (coarse.rotate == 90) {
tr |= TR_R90;
} else if (coarse.rotate == 180) {
tr |= TR_R180;
} else if (coarse.rotate == 270) {
tr |= TR_R270;
}
if (coarse.hflip) {
tr |= TR_HFLIP;
}
if (coarse.vflip) {
tr |= TR_VFLIP;
}
return tr;
}

View File

@ -48,7 +48,7 @@ namespace rtengine {
extern const char sImage8[]; extern const char sImage8[];
extern const char sImage16[]; extern const char sImage16[];
extern const char sImagefloat[]; extern const char sImagefloat[];
int getCoarseBitMask( const procparams::CoarseTransformParams &coarse);
class ProgressListener; class ProgressListener;
class Color; class Color;

View File

@ -255,13 +255,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
params.wb.temperature = currWB.getTemp (); params.wb.temperature = currWB.getTemp ();
params.wb.green = currWB.getGreen (); params.wb.green = currWB.getGreen ();
int tr = TR_NONE; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
else if (params.coarse.rotate==180) tr |= TR_R180;
else if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
imgsrc->getFullSize (fw, fh, tr); imgsrc->getFullSize (fw, fh, tr);
PreviewProps pp (0, 0, fw, fh, scale); PreviewProps pp (0, 0, fw, fh, scale);
@ -754,12 +748,7 @@ void ImProcCoordinator::setScale (int prevscale) {
if (settings->verbose) printf ("setscale before lock\n"); if (settings->verbose) printf ("setscale before lock\n");
tr = TR_NONE; tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
int nW, nH; int nW, nH;
imgsrc->getFullSize (fw, fh, tr); imgsrc->getFullSize (fw, fh, tr);
@ -905,12 +894,9 @@ void ImProcCoordinator::getSpotWB (int x, int y, int rect, double& temp, double&
points.push_back (Coord2D (j, i)); points.push_back (Coord2D (j, i));
ipf.transCoord (fw, fh, points, red, green, blue); ipf.transCoord (fw, fh, points, red, green, blue);
int tr = TR_NONE;
if (params.coarse.rotate==90) tr |= TR_R90; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
ret = imgsrc->getSpotWB (red, green, blue, tr, params.wb.equal); ret = imgsrc->getSpotWB (red, green, blue, tr, params.wb.equal);
currWB = ColorTemp (params.wb.temperature, params.wb.green,params.wb.equal, params.wb.method); currWB = ColorTemp (params.wb.temperature, params.wb.green,params.wb.equal, params.wb.method);
//double rr,gg,bb; //double rr,gg,bb;
@ -961,7 +947,10 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool
MyMutex::MyLock lock(mProcessing); MyMutex::MyLock lock(mProcessing);
int fW, fH; int fW, fH;
imgsrc->getFullSize (fW, fH, 0);
int tr = getCoarseBitMask(params.coarse);
imgsrc->getFullSize (fW, fH, tr);
PreviewProps pp (0, 0, fW, fH, 1); PreviewProps pp (0, 0, fW, fH, 1);
ProcParams ppar = params; ProcParams ppar = params;
ppar.toneCurve.hrenabled = false; ppar.toneCurve.hrenabled = false;
@ -990,7 +979,7 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool
if (!apply_wb) { if (!apply_wb) {
currWB = ColorTemp(); // = no white balance currWB = ColorTemp(); // = no white balance
} }
imgsrc->getImage (currWB, 0, im, pp, ppar.toneCurve, ppar.icm, ppar.raw); imgsrc->getImage (currWB, tr, im, pp, ppar.toneCurve, ppar.icm, ppar.raw);
ImProcFunctions ipf (&ppar, true); ImProcFunctions ipf (&ppar, true);
if (ipf.needsTransform()) { if (ipf.needsTransform()) {
Imagefloat* trImg = new Imagefloat (fW, fH); Imagefloat* trImg = new Imagefloat (fW, fH);
@ -1029,6 +1018,9 @@ void ImProcCoordinator::saveInputICCReference (const Glib::ustring& fname, bool
} }
im16->saveTIFF (fname,16,true); im16->saveTIFF (fname,16,true);
delete im16; delete im16;
if (plistener)
plistener->setProgressState (false);
//im->saveJPEG (fname, 85); //im->saveJPEG (fname, 85);
} }

View File

@ -254,7 +254,7 @@ class ImProcFunctions {
void lab2monitorRgb (LabImage* lab, Image8* image); void lab2monitorRgb (LabImage* lab, Image8* image);
void resize (Image16* src, Image16* dst, float dScale); void resize (Image16* src, Image16* dst, float dScale);
void Lanczos (const LabImage* src, LabImage* dst, float scale); void Lanczos (const LabImage* src, LabImage* dst, float scale);
// void Lanczos (const Image16* src, Image16* dst, float scale); void Lanczos (const Image16* src, Image16* dst, float scale);
void deconvsharpening (LabImage* lab, float** buffer); void deconvsharpening (LabImage* lab, float** buffer);
void deconvsharpeningcam (CieImage* ncie, float** buffer); void deconvsharpeningcam (CieImage* ncie, float** buffer);

View File

@ -41,7 +41,6 @@ static inline float Lanc(float x, float a)
} }
} }
/* This Function is not used anymore
void ImProcFunctions::Lanczos(const Image16* src, Image16* dst, float scale) void ImProcFunctions::Lanczos(const Image16* src, Image16* dst, float scale)
{ {
@ -167,7 +166,7 @@ void ImProcFunctions::Lanczos(const Image16* src, Image16* dst, float scale)
delete[] lb; delete[] lb;
} }
} }
*/
SSEFUNCTION void ImProcFunctions::Lanczos(const LabImage* src, LabImage* dst, float scale) SSEFUNCTION void ImProcFunctions::Lanczos(const LabImage* src, LabImage* dst, float scale)
{ {
@ -381,119 +380,13 @@ void ImProcFunctions::resize (Image16* src, Image16* dst, float dScale) {
#ifdef PROFILE #ifdef PROFILE
time_t t1 = clock(); time_t t1 = clock();
#endif #endif
if(params->resize.method != "Nearest" ) {
Lanczos(src, dst, dScale);
} else {
// Nearest neighbour algorithm // Nearest neighbour algorithm
#ifdef _OPENMP #ifdef _OPENMP
#pragma omp parallel for if (multiThread) #pragma omp parallel for if (multiThread)
#endif #endif
for (int i=0; i<dst->height; i++) {
int sy = i/dScale;
sy = LIM(sy, 0, src->height-1);
for (int j=0; j<dst->width; j++) {
int sx = j/dScale;
sx = LIM(sx, 0, src->width-1);
dst->r(i,j) = src->r(sy,sx);
dst->g(i,j) = src->g(sy,sx);
dst->b(i,j) = src->b(sy,sx);
}
}
/* not used anymore
if(params->resize.method == "Lanczos" ||
params->resize.method == "Downscale (Better)" ||
params->resize.method == "Downscale (Faster)"
) {
Lanczos(src, dst, dScale);
} else {
}
else if (params->resize.method.substr(0,7)=="Bicubic") {
float Av = -0.5f;
if (params->resize.method=="Bicubic (Sharper)")
Av = -0.75f;
else if (params->resize.method=="Bicubic (Softer)")
Av = -0.25f;
#pragma omp parallel for if (multiThread)
for (int i=0; i<dst->height; i++) {
float wx[4], wy[4];
float Dy = i / dScale;
int yc = (int) Dy;
Dy -= (float)yc;
int ys = yc - 1; // smallest y-index used for interpolation
// compute vertical weights
float t1y = -Av*(Dy-1.0f)*Dy;
float t2y = (3.0f - 2.0f*Dy)*Dy*Dy;
wy[3] = t1y*Dy;
wy[2] = t1y*(Dy - 1.0f) + t2y;
wy[1] = -t1y*Dy + 1.0f - t2y;
wy[0] = -t1y*(Dy - 1.0f);
for (int j = 0; j < dst->width; j++) {
float Dx = j / dScale;
int xc = (int) Dx;
Dx -= (float)xc;
int xs = xc - 1; // smallest x-index used for interpolation
if (ys >= 0 && ys < src->height-3 && xs >= 0 && xs <= src->width-3) {
// compute horizontal weights
float t1 = -Av*(Dx-1.0f)*Dx;
float t2 = (3.0f - 2.0f*Dx)*Dx*Dx;
wx[3] = t1*Dx;
wx[2] = t1*(Dx - 1.0f) + t2;
wx[1] = -t1*Dx + 1.0f - t2;
wx[0] = -t1*(Dx - 1.0f);
// compute weighted sum
int r = 0;
int g = 0;
int b = 0;
for (int x=0; x<4; x++)
for (int y=0; y<4; y++) {
float w = wx[x]*wy[y];
r += w*src->r(ys+y,xs+x);
g += w*src->g(ys+y,xs+x);
b += w*src->b(ys+y,xs+x);
}
dst->r(i,j) = CLIP(r);
dst->g(i,j) = CLIP(g);
dst->b(i,j) = CLIP(b);
}
else {
xc = LIM(xc, 0, src->width-1);
yc = LIM(yc, 0, src->height-1);
int nx = xc + 1;
if (nx >= src->width)
nx = xc;
int ny = yc + 1;
if (ny >= src->height)
ny = yc;
dst->r(i,j) = (1-Dx)*(1-Dy)*src->r(yc,xc) + (1-Dx)*Dy*src->r(ny,xc) + Dx*(1-Dy)*src->r(yc,nx) + Dx*Dy*src->r(ny,nx);
dst->g(i,j) = (1-Dx)*(1-Dy)*src->g(yc,xc) + (1-Dx)*Dy*src->g(ny,xc) + Dx*(1-Dy)*src->g(yc,nx) + Dx*Dy*src->g(ny,nx);
dst->b(i,j) = (1-Dx)*(1-Dy)*src->b(yc,xc) + (1-Dx)*Dy*src->b(ny,xc) + Dx*(1-Dy)*src->b(yc,nx) + Dx*Dy*src->b(ny,nx);
}
}
}
}
else if (params->resize.method=="Bilinear") {
#pragma omp parallel for if (multiThread)
for (int i=0; i<dst->height; i++) {
int sy = i/dScale;
sy = LIM(sy, 0, src->height-1);
float dy = i/dScale - sy;
int ny = sy+1;
if (ny>=src->height)
ny = sy;
for (int j=0; j<dst->width; j++) {
int sx = j/dScale;
sx = LIM(sx, 0, src->width-1);
float dx = j/dScale - sx;
int nx = sx+1;
if (nx>=src->width)
nx = sx;
dst->r(i,j) = (1-dx)*(1-dy)*src->r(sy,sx) + (1-dx)*dy*src->r(ny,sx) + dx*(1-dy)*src->r(sy,nx) + dx*dy*src->r(ny,nx);
dst->g(i,j) = (1-dx)*(1-dy)*src->g(sy,sx) + (1-dx)*dy*src->g(ny,sx) + dx*(1-dy)*src->g(sy,nx) + dx*dy*src->g(ny,nx);
dst->b(i,j) = (1-dx)*(1-dy)*src->b(sy,sx) + (1-dx)*dy*src->b(ny,sx) + dx*(1-dy)*src->b(sy,nx) + dx*dy*src->b(ny,nx);
}
}
}
else {
// Nearest neighbour algorithm
#pragma omp parallel for if (multiThread)
for (int i=0; i<dst->height; i++) { for (int i=0; i<dst->height; i++) {
int sy = i/dScale; int sy = i/dScale;
sy = LIM(sy, 0, src->height-1); sy = LIM(sy, 0, src->height-1);
@ -506,7 +399,7 @@ void ImProcFunctions::resize (Image16* src, Image16* dst, float dScale) {
} }
} }
} }
*/
#ifdef PROFILE #ifdef PROFILE
time_t t2 = clock(); time_t t2 = clock();
std::cout << "Resize: " << params->resize.method << ": " std::cout << "Resize: " << params->resize.method << ": "

View File

@ -1181,13 +1181,7 @@ void Thumbnail::getSpotWB (const procparams::ProcParams& params, int xp, int yp,
} }
ImProcFunctions ipf (&params, false); ImProcFunctions ipf (&params, false);
ipf.transCoord (fw, fh, points, red, green, blue); ipf.transCoord (fw, fh, points, red, green, blue);
int tr = TR_NONE; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
// calculate spot wb (copy & pasted from stdimagesource) // calculate spot wb (copy & pasted from stdimagesource)
double reds = 0, greens = 0, blues = 0; double reds = 0, greens = 0, blues = 0;
int rn = 0, gn = 0, bn = 0; int rn = 0, gn = 0, bn = 0;

View File

@ -63,13 +63,7 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// acquire image from imagesource // acquire image from imagesource
ImageSource* imgsrc = ii->getImageSource (); ImageSource* imgsrc = ii->getImageSource ();
int tr = TR_NONE; int tr = getCoarseBitMask(params.coarse);
if (params.coarse.rotate==90) tr |= TR_R90;
if (params.coarse.rotate==180) tr |= TR_R180;
if (params.coarse.rotate==270) tr |= TR_R270;
if (params.coarse.hflip) tr |= TR_HFLIP;
if (params.coarse.vflip) tr |= TR_VFLIP;
int fw, fh; int fw, fh;
imgsrc->getFullSize (fw, fh, tr); imgsrc->getFullSize (fw, fh, tr);