Sync with GIT
This commit is contained in:
@@ -1346,7 +1346,7 @@ bool ImProcFunctions::transCoord (const ProcParams* params, int W, int H, std::v
|
||||
red.clear ();
|
||||
green.clear ();
|
||||
blue.clear ();
|
||||
bool needstransform = fabs(params->rotate.degree)>1e-15 || fabs(params->distortion.amount)>1e-15 || fabs(params->cacorrection.red)>1e-15 || fabs(params->cacorrection.blue)>1e-15;
|
||||
bool needstransform = 0;// fabs(params->rotate.degree)>1e-15 || fabs(params->distortion.amount)>1e-15 || fabs(params->cacorrection.red)>1e-15 || fabs(params->cacorrection.blue)>1e-15;
|
||||
if (!needstransform) {
|
||||
if (clipresize) {
|
||||
// Apply resizing
|
||||
@@ -1533,12 +1533,12 @@ bool ImProcFunctions::transCoord (const ProcParams* params, int W, int H, int x,
|
||||
void ImProcFunctions::transform (Image16* original, Image16* transformed, const ProcParams* params, int cx, int cy, int sx, int sy, int oW, int oH) {
|
||||
|
||||
STemp sizes;
|
||||
sizes.cx = cx;
|
||||
sizes.cy = cy;
|
||||
sizes.cx = 0;//cx;
|
||||
sizes.cy = 0;//cy;
|
||||
sizes.oW = oW;
|
||||
sizes.oH = oH;
|
||||
sizes.sx = sx;
|
||||
sizes.sy = sy;
|
||||
sizes.sx = 0;//sx;
|
||||
sizes.sy = 0;//sy;
|
||||
|
||||
if (params->cacorrection.red==0 && params->cacorrection.blue==0) {
|
||||
if (settings->dualThreadEnabled) {
|
||||
@@ -1565,12 +1565,12 @@ void ImProcFunctions::transform (Image16* original, Image16* transformed, const
|
||||
void ImProcFunctions::simpltransform (Image16* original, Image16* transformed, const ProcParams* params, int cx, int cy, int sx, int sy, int oW, int oH) {
|
||||
|
||||
STemp sizes;
|
||||
sizes.cx = cx;
|
||||
sizes.cy = cy;
|
||||
sizes.cx = 0;//cx;
|
||||
sizes.cy = 0;//cy;
|
||||
sizes.oW = oW;
|
||||
sizes.oH = oH;
|
||||
sizes.sx = sx;
|
||||
sizes.sy = sy;
|
||||
sizes.sx = 0;//sx;
|
||||
sizes.sy = 0;//sy;
|
||||
|
||||
if (settings->dualThreadEnabled) {
|
||||
Glib::Thread *thread1 = Glib::Thread::create(sigc::bind(sigc::mem_fun(*this, &ImProcFunctions::simpltransform_), original, transformed, params, sizes, 0, transformed->height/2), 0, true, true, Glib::THREAD_PRIORITY_NORMAL);
|
||||
@@ -1925,7 +1925,94 @@ void ImProcFunctions::resize (Image16* src, Image16* dst, ResizeParams params) {
|
||||
}
|
||||
|
||||
void ImProcFunctions::resize_ (Image16* src, Image16* dst, ResizeParams params, int row_from, int row_to) {
|
||||
if(params.scale < 0.5)
|
||||
{
|
||||
// small-scale algorithm by Ilia
|
||||
// provides much better quality on small scales
|
||||
// calculates mean value over source pixels which current destination pixel covers
|
||||
// works only for scales < 1
|
||||
// for scales ~1 it is analogous to bilinear
|
||||
// possibly, for even less scale factors (< 0.2 possibly) boundary pixels are not needed, omitting them can give a speedup
|
||||
// this algorithm is much slower on small factors than others, because it uses all pixels of the SOURCE image
|
||||
|
||||
double delta = 1.0 / params.scale;
|
||||
double k = params.scale * params.scale;
|
||||
|
||||
for(int i = row_from; i < row_to; i++)
|
||||
{
|
||||
// top and bottom boundary coordinates
|
||||
double y0 = i * delta;
|
||||
double y1 = (i + 1) * delta;
|
||||
|
||||
int m0 = y0;
|
||||
m0 = CLIPTO(m0, 0, src->height-1);
|
||||
|
||||
int m1 = y1;
|
||||
m1 = CLIPTO(m1, 0, src->height-1);
|
||||
|
||||
// weights of boundary pixels
|
||||
double wy0 = 1.0 - (y0 - m0);
|
||||
double wy1 = y1 - m1;
|
||||
|
||||
for(int j = 0; j < dst->width; j++)
|
||||
{
|
||||
// left and right boundary coordinates
|
||||
double x0 = j * delta;
|
||||
double x1 = (j + 1) * delta;
|
||||
|
||||
int n0 = x0;
|
||||
n0 = CLIPTO(n0, 0, src->width-1);
|
||||
int n1 = x1;
|
||||
n1 = CLIPTO(n1, 0, src->width-1);
|
||||
|
||||
double wx0 = 1.0 - (x0 - n0);
|
||||
double wx1 = x1 - n1;
|
||||
|
||||
double r = 0;
|
||||
double g = 0;
|
||||
double b = 0;
|
||||
|
||||
// integration
|
||||
// corners
|
||||
r += wy0 * wx0 * src->r[m0][n0] + wy0 * wx1 * src->r[m0][n1] + wy1 * wx0 * src->r[m1][n0] + wy1 * wx1 * src->r[m1][n1];
|
||||
g += wy0 * wx0 * src->g[m0][n0] + wy0 * wx1 * src->g[m0][n1] + wy1 * wx0 * src->g[m1][n0] + wy1 * wx1 * src->g[m1][n1];
|
||||
b += wy0 * wx0 * src->b[m0][n0] + wy0 * wx1 * src->b[m0][n1] + wy1 * wx0 * src->b[m1][n0] + wy1 * wx1 * src->b[m1][n1];
|
||||
// top and bottom boundaries
|
||||
for(int n = n0 + 1; n < n1; n++)
|
||||
{
|
||||
r += wy0 * src->r[m0][n] + wy1 * src->r[m1][n];
|
||||
g += wy0 * src->g[m0][n] + wy1 * src->g[m1][n];
|
||||
b += wy0 * src->b[m0][n] + wy1 * src->b[m1][n];
|
||||
}
|
||||
// inner rows
|
||||
for(int m = m0 + 1; m < m1; m++)
|
||||
{
|
||||
// left and right boundaries
|
||||
r += wx0 * src->r[m][n0] + wx1 * src->r[m][n1];
|
||||
g += wx0 * src->g[m][n0] + wx1 * src->g[m][n1];
|
||||
b += wx0 * src->b[m][n0] + wx1 * src->b[m][n1];
|
||||
// inner pixels
|
||||
for(int n = n0 + 1; n < n1; n++)
|
||||
{
|
||||
r += src->r[m][n];
|
||||
g += src->g[m][n];
|
||||
b += src->b[m][n];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// overall weight is equal to the DST pixel area in SRC coordinates
|
||||
r *= k;
|
||||
g *= k;
|
||||
b *= k;
|
||||
|
||||
dst->r[i][j] = CLIP((int)r);
|
||||
dst->g[i][j] = CLIP((int)g);
|
||||
dst->b[i][j] = CLIP((int)b);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(params.method == "Downscale (Better)")
|
||||
{
|
||||
// small-scale algorithm by Ilia
|
||||
|
Reference in New Issue
Block a user