Merge branch 'dev' into spot-removal-tool (#2239)

This commit is contained in:
Hombre
2018-01-25 20:41:10 +01:00
183 changed files with 9182 additions and 5571 deletions

View File

@@ -154,10 +154,24 @@ void Imagefloat::getScanline (int row, unsigned char* buffer, int bps)
int ix = 0;
float* sbuffer = (float*) buffer;
// agriggio -- assume the image is normalized to [0, 65535]
for (int i = 0; i < width; i++) {
sbuffer[ix++] = r(row, i);
sbuffer[ix++] = g(row, i);
sbuffer[ix++] = b(row, i);
sbuffer[ix++] = r(row, i) / 65535.f;
sbuffer[ix++] = g(row, i) / 65535.f;
sbuffer[ix++] = b(row, i) / 65535.f;
}
} else if (bps == 16) {
unsigned short *sbuffer = (unsigned short *)buffer;
for (int i = 0, ix = 0; i < width; i++) {
sbuffer[ix++] = CLIP(r(row, i));
sbuffer[ix++] = CLIP(g(row, i));
sbuffer[ix++] = CLIP(b(row, i));
}
} else if (bps == 8) {
for (int i = 0, ix = 0; i < width; i++) {
buffer[ix++] = rtengine::uint16ToUint8Rounded(CLIP(r(row, i)));
buffer[ix++] = rtengine::uint16ToUint8Rounded(CLIP(g(row, i)));
buffer[ix++] = rtengine::uint16ToUint8Rounded(CLIP(b(row, i)));
}
}
}
@@ -189,17 +203,22 @@ void Imagefloat::getStdImage (ColorTemp ctemp, int tran, Imagefloat* image, cons
{
// compute channel multipliers
double drm, dgm, dbm;
ctemp.getMultipliers (drm, dgm, dbm);
float rm = drm, gm = dgm, bm = dbm;
float rm = 1.f, gm = 1.f, bm = 1.f;
if (ctemp.getTemp() >= 0) {
double drm, dgm, dbm;
ctemp.getMultipliers (drm, dgm, dbm);
rm = drm;
gm = dgm;
bm = dbm;
rm = 1.0 / rm;
gm = 1.0 / gm;
bm = 1.0 / bm;
float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm;
rm /= mul_lum;
gm /= mul_lum;
bm /= mul_lum;
rm = 1.0 / rm;
gm = 1.0 / gm;
bm = 1.0 / bm;
float mul_lum = 0.299 * rm + 0.587 * gm + 0.114 * bm;
rm /= mul_lum;
gm /= mul_lum;
bm /= mul_lum;
}
int sx1, sy1, sx2, sy2;
@@ -525,3 +544,51 @@ void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform)
} // End of parallelization
}
}
// Parallized transformation; create transform with cmsFLAGS_NOCACHE!
void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform, const LabImage &labImage, int cx, int cy)
{
// LittleCMS cannot parallelize planar Lab float images
// so build temporary buffers to allow multi processor execution
#ifdef _OPENMP
#pragma omp parallel
#endif
{
AlignedBuffer<float> bufferLab(width * 3);
AlignedBuffer<float> bufferRGB(width * 3);
#ifdef _OPENMP
#pragma omp for schedule(static)
#endif
for (int y = cy; y < cy + height; y++)
{
float *pRGB, *pR, *pG, *pB;
float *pLab, *pL, *pa, *pb;
pLab= bufferLab.data;
pL = labImage.L[y] + cx;
pa = labImage.a[y] + cx;
pb = labImage.b[y] + cx;
for (int x = 0; x < width; x++) {
*(pLab++) = *(pL++) / 327.68f;
*(pLab++) = *(pa++) / 327.68f;
*(pLab++) = *(pb++) / 327.68f;
}
cmsDoTransform (hTransform, bufferLab.data, bufferRGB.data, width);
pRGB = bufferRGB.data;
pR = r(y - cy);
pG = g(y - cy);
pB = b(y - cy);
for (int x = 0; x < width; x++) {
*(pR++) = *(pRGB++);
*(pG++) = *(pRGB++);
*(pB++) = *(pRGB++);
}
} // End of parallelization
}
}