Log tranform: fix bug in preview mode
This commit is contained in:
parent
52f7c2c531
commit
085c68fc29
@ -84,8 +84,8 @@ class ImProcFunctions
|
|||||||
void calcVignettingParams(int oW, int oH, const procparams::VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul);
|
void calcVignettingParams(int oW, int oH, const procparams::VignettingParams& vignetting, double &w2, double &h2, double& maxRadius, double &v, double &b, double &mul);
|
||||||
|
|
||||||
void transformLuminanceOnly(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH);
|
void transformLuminanceOnly(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int oW, int oH, int fW, int fH);
|
||||||
void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap);
|
void transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap, bool useOriginalBuffer);
|
||||||
void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap);
|
void transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap, bool useOriginalBuffer);
|
||||||
|
|
||||||
bool needsCA() const;
|
bool needsCA() const;
|
||||||
bool needsDistortion() const;
|
bool needsDistortion() const;
|
||||||
@ -156,7 +156,7 @@ public:
|
|||||||
// void colorCurve (LabImage* lold, LabImage* lnew);
|
// void colorCurve (LabImage* lold, LabImage* lnew);
|
||||||
void sharpening(LabImage* lab, const procparams::SharpeningParams &sharpenParam, bool showMask = false);
|
void sharpening(LabImage* lab, const procparams::SharpeningParams &sharpenParam, bool showMask = false);
|
||||||
void sharpeningcam(CieImage* ncie, float** buffer, bool showMask = false);
|
void sharpeningcam(CieImage* ncie, float** buffer, bool showMask = false);
|
||||||
void transform(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const FramesMetaData *metadata, int rawRotationDeg, bool fullImage);
|
void transform(Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const FramesMetaData *metadata, int rawRotationDeg, bool fullImage, bool useOriginalBuffer = false);
|
||||||
float resizeScale(const procparams::ProcParams* params, int fw, int fh, int &imw, int &imh);
|
float resizeScale(const procparams::ProcParams* params, int fw, int fh, int &imw, int &imh);
|
||||||
void lab2monitorRgb(LabImage* lab, Image8* image);
|
void lab2monitorRgb(LabImage* lab, Image8* image);
|
||||||
void resize(Imagefloat* src, Imagefloat* dst, float dScale);
|
void resize(Imagefloat* src, Imagefloat* dst, float dScale);
|
||||||
|
@ -86,25 +86,25 @@ float normn (float a, float b, int n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void logEncode(rtengine::Imagefloat *original, bool multiThread) {
|
void logEncode(rtengine::Imagefloat *src, rtengine::Imagefloat *dest, bool multiThread) {
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel for schedule(dynamic, 16) if(multiThread)
|
#pragma omp parallel for schedule(dynamic, 16) if(multiThread)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (int y = 0; y < original->getHeight(); ++y) {
|
for (int y = 0; y < src->getHeight(); ++y) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
#ifdef __SSE2__
|
#ifdef __SSE2__
|
||||||
for (; x < original->getWidth() - 3; x += 4) {
|
for (; x < src->getWidth() - 3; x += 4) {
|
||||||
STVFU(original->r(y, x), xlogf1(LVFU(original->r(y, x))));
|
STVFU(dest->r(y, x), xlogf1(LVFU(src->r(y, x))));
|
||||||
STVFU(original->g(y, x), xlogf1(LVFU(original->g(y, x))));
|
STVFU(dest->g(y, x), xlogf1(LVFU(src->g(y, x))));
|
||||||
STVFU(original->b(y, x), xlogf1(LVFU(original->b(y, x))));
|
STVFU(dest->b(y, x), xlogf1(LVFU(src->b(y, x))));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (; x < original->getWidth(); ++x) {
|
for (; x < src->getWidth(); ++x) {
|
||||||
original->r(y, x) = xlogf1(original->r(y, x));
|
dest->r(y, x) = xlogf1(src->r(y, x));
|
||||||
original->g(y, x) = xlogf1(original->g(y, x));
|
dest->g(y, x) = xlogf1(src->g(y, x));
|
||||||
original->b(y, x) = xlogf1(original->b(y, x));
|
dest->b(y, x) = xlogf1(src->b(y, x));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ bool ImProcFunctions::transCoord (int W, int H, int x, int y, int w, int h, int&
|
|||||||
|
|
||||||
void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH,
|
void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH,
|
||||||
const FramesMetaData *metadata,
|
const FramesMetaData *metadata,
|
||||||
int rawRotationDeg, bool fullImage)
|
int rawRotationDeg, bool fullImage, bool useOriginalBuffer)
|
||||||
{
|
{
|
||||||
double focalLen = metadata->getFocalLen();
|
double focalLen = metadata->getFocalLen();
|
||||||
double focalLen35mm = metadata->getFocalLen35mm();
|
double focalLen35mm = metadata->getFocalLen35mm();
|
||||||
@ -584,10 +584,10 @@ void ImProcFunctions::transform (Imagefloat* original, Imagefloat* transformed,
|
|||||||
dest = tmpimg.get();
|
dest = tmpimg.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
transformGeneral(highQuality, original, dest, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get());
|
transformGeneral(highQuality, original, dest, cx, cy, sx, sy, oW, oH, fW, fH, pLCPMap.get(), useOriginalBuffer);
|
||||||
|
|
||||||
if (highQuality && dest != transformed) {
|
if (highQuality && dest != transformed) {
|
||||||
transformLCPCAOnly(dest, transformed, cx, cy, pLCPMap.get());
|
transformLCPCAOnly(dest, transformed, cx, cy, pLCPMap.get(), useOriginalBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -976,7 +976,7 @@ void ImProcFunctions::transformLuminanceOnly (Imagefloat* original, Imagefloat*
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap)
|
void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, Imagefloat *transformed, int cx, int cy, int sx, int sy, int oW, int oH, int fW, int fH, const LensCorrection *pLCPMap, bool useOriginalBuffer)
|
||||||
{
|
{
|
||||||
|
|
||||||
// set up stuff, depending on the mode we are
|
// set up stuff, depending on the mode we are
|
||||||
@ -1058,8 +1058,15 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
|||||||
const double centerFactorx = cx - w2;
|
const double centerFactorx = cx - w2;
|
||||||
const double centerFactory = cy - h2;
|
const double centerFactory = cy - h2;
|
||||||
|
|
||||||
|
std::unique_ptr<Imagefloat> tempLog;
|
||||||
if (useLog) {
|
if (useLog) {
|
||||||
logEncode(original, multiThread);
|
if (!useOriginalBuffer) {
|
||||||
|
tempLog.reset(new Imagefloat(original->getWidth(), original->getHeight()));
|
||||||
|
logEncode(original, tempLog.get(), multiThread);
|
||||||
|
original = tempLog.get();
|
||||||
|
} else {
|
||||||
|
logEncode(original, original, multiThread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// main cycle
|
// main cycle
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
@ -1205,7 +1212,7 @@ void ImProcFunctions::transformGeneral(bool highQuality, Imagefloat *original, I
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap)
|
void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *transformed, int cx, int cy, const LensCorrection *pLCPMap, bool useOriginalBuffer)
|
||||||
{
|
{
|
||||||
assert(pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable());
|
assert(pLCPMap && params->lensProf.useCA && pLCPMap->isCACorrectionAvailable());
|
||||||
const bool useLog = params->pdsharpening.enabled;
|
const bool useLog = params->pdsharpening.enabled;
|
||||||
@ -1220,8 +1227,15 @@ void ImProcFunctions::transformLCPCAOnly(Imagefloat *original, Imagefloat *trans
|
|||||||
chTrans[1] = transformed->g.ptrs;
|
chTrans[1] = transformed->g.ptrs;
|
||||||
chTrans[2] = transformed->b.ptrs;
|
chTrans[2] = transformed->b.ptrs;
|
||||||
|
|
||||||
|
std::unique_ptr<Imagefloat> tempLog;
|
||||||
if (useLog) {
|
if (useLog) {
|
||||||
logEncode(original, multiThread);
|
if (!useOriginalBuffer) {
|
||||||
|
tempLog.reset(new Imagefloat(original->getWidth(), original->getHeight()));
|
||||||
|
logEncode(original, tempLog.get(), multiThread);
|
||||||
|
original = tempLog.get();
|
||||||
|
} else {
|
||||||
|
logEncode(original, original, multiThread);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
|
@ -880,7 +880,7 @@ private:
|
|||||||
trImg = new Imagefloat (fw, fh);
|
trImg = new Imagefloat (fw, fh);
|
||||||
}
|
}
|
||||||
ipf.transform (baseImg, trImg, 0, 0, 0, 0, fw, fh, fw, fh,
|
ipf.transform (baseImg, trImg, 0, 0, 0, 0, fw, fh, fw, fh,
|
||||||
imgsrc->getMetaData(), imgsrc->getRotateDegree(), true);
|
imgsrc->getMetaData(), imgsrc->getRotateDegree(), true, true);
|
||||||
if(trImg != baseImg) {
|
if(trImg != baseImg) {
|
||||||
delete baseImg;
|
delete baseImg;
|
||||||
baseImg = trImg;
|
baseImg = trImg;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user