converting DCB and vng4 to float.
This commit is contained in:
parent
8ccf2f2dca
commit
1e31a821e5
@ -604,14 +604,14 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
plistener->setProgress (0.0);
|
plistener->setProgress (0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ushort (*brow[5])[4], *pix;
|
float (*brow[5])[4], *pix;
|
||||||
int prow=7, pcol=1, *ip, *code[16][16], gval[8], gmin, gmax, sum[4];
|
int prow=7, pcol=1, *ip, *code[16][16], gval[8], gmin, gmax, sum[4];
|
||||||
int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag;
|
int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag;
|
||||||
int g, diff, thold, num, c, width=W, height=H, colors=4;
|
int g, diff, thold, num, c, width=W, height=H, colors=4;
|
||||||
ushort (*image)[4];
|
float (*image)[4];
|
||||||
int lcode[16][16][32], shift, i, j;
|
int lcode[16][16][32], shift, i, j;
|
||||||
|
|
||||||
image = (ushort (*)[4]) calloc (H*W, sizeof *image);
|
image = (float (*)[4]) calloc (H*W, sizeof *image);
|
||||||
for (int ii=0; ii<H; ii++)
|
for (int ii=0; ii<H; ii++)
|
||||||
for (int jj=0; jj<W; jj++)
|
for (int jj=0; jj<W; jj++)
|
||||||
image[ii*W+jj][fc(ii,jj)] = rawData[ii][jj];
|
image[ii*W+jj][fc(ii,jj)] = rawData[ii][jj];
|
||||||
@ -629,7 +629,7 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
*ip++ = (width*y + x)*4 + color;
|
*ip++ = (width*y + x)*4 + color;
|
||||||
*ip++ = shift;
|
*ip++ = shift;
|
||||||
*ip++ = color;
|
*ip++ = color;
|
||||||
sum[color] += 1 << shift;
|
sum[color] += (1 << shift);
|
||||||
}
|
}
|
||||||
FORCC
|
FORCC
|
||||||
if (c != fc(row,col)) {
|
if (c != fc(row,col)) {
|
||||||
@ -644,9 +644,9 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
ip = lcode[row & 15][col & 15];
|
ip = lcode[row & 15][col & 15];
|
||||||
memset (sum, 0, sizeof sum);
|
memset (sum, 0, sizeof sum);
|
||||||
for (i=8; i--; ip+=3)
|
for (i=8; i--; ip+=3)
|
||||||
sum[ip[2]] += pix[ip[0]] << ip[1];
|
sum[ip[2]] += pix[ip[0]] * (1 << ip[1]);
|
||||||
for (i=colors; --i; ip+=2)
|
for (i=colors; --i; ip+=2)
|
||||||
pix[ip[0]] = sum[ip[0]] * ip[1] >> 8;
|
pix[ip[0]] = sum[ip[0]] * ip[1] /256;
|
||||||
}
|
}
|
||||||
|
|
||||||
// lin_interpolate();
|
// lin_interpolate();
|
||||||
@ -669,7 +669,7 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
*ip++ = (y2*width + x2)*4 + color;
|
*ip++ = (y2*width + x2)*4 + color;
|
||||||
*ip++ = weight;
|
*ip++ = weight;
|
||||||
for (g=0; g < 8; g++)
|
for (g=0; g < 8; g++)
|
||||||
if (grads & 1<<g) *ip++ = g;
|
if (grads & (1<<g)) *ip++ = g;
|
||||||
*ip++ = -1;
|
*ip++ = -1;
|
||||||
}
|
}
|
||||||
*ip++ = INT_MAX;
|
*ip++ = INT_MAX;
|
||||||
@ -683,7 +683,7 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
*ip++ = 0;
|
*ip++ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
brow[4] = (ushort (*)[4]) calloc (width*3, sizeof **brow);
|
brow[4] = (float (*)[4]) calloc (width*3, sizeof **brow);
|
||||||
for (row=0; row < 3; row++)
|
for (row=0; row < 3; row++)
|
||||||
brow[row] = brow[4] + row*width;
|
brow[row] = brow[4] + row*width;
|
||||||
for (row=2; row < height-2; row++) { /* Do VNG interpolation */
|
for (row=2; row < height-2; row++) { /* Do VNG interpolation */
|
||||||
@ -693,7 +693,7 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
ip = code[row & prow][col & pcol];
|
ip = code[row & prow][col & pcol];
|
||||||
memset (gval, 0, sizeof gval);
|
memset (gval, 0, sizeof gval);
|
||||||
while ((g = ip[0]) != INT_MAX) { /* Calculate gradients */
|
while ((g = ip[0]) != INT_MAX) { /* Calculate gradients */
|
||||||
diff = ABS(pix[g] - pix[ip[1]]) << ip[2];
|
diff = ABS(pix[g] - pix[ip[1]]) * (1<< ip[2]);
|
||||||
gval[ip[3]] += diff;
|
gval[ip[3]] += diff;
|
||||||
ip += 5;
|
ip += 5;
|
||||||
if ((g = ip[-1]) == -1) continue;
|
if ((g = ip[-1]) == -1) continue;
|
||||||
@ -711,13 +711,13 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
memcpy (brow[2][col], pix, sizeof *image);
|
memcpy (brow[2][col], pix, sizeof *image);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
thold = gmin + (gmax >> 1);
|
thold = gmin + (gmax /2);
|
||||||
memset (sum, 0, sizeof sum);
|
memset (sum, 0, sizeof sum);
|
||||||
for (num=g=0; g < 8; g++,ip+=2) { /* Average the neighbors */
|
for (num=g=0; g < 8; g++,ip+=2) { /* Average the neighbors */
|
||||||
if (gval[g] <= thold) {
|
if (gval[g] <= thold) {
|
||||||
FORCC
|
FORCC
|
||||||
if (c == color && ip[1])
|
if (c == color && ip[1])
|
||||||
sum[c] += (pix[c] + pix[ip[1]]) >> 1;
|
sum[c] += (pix[c] + pix[ip[1]]) /2;
|
||||||
else
|
else
|
||||||
sum[c] += pix[ip[0] + c];
|
sum[c] += pix[ip[0] + c];
|
||||||
num++;
|
num++;
|
||||||
@ -744,7 +744,7 @@ void RawImageSource::vng4_demosaic () {
|
|||||||
|
|
||||||
for (int i=0; i<H; i++) {
|
for (int i=0; i<H; i++) {
|
||||||
for (int j=0; j<W; j++)
|
for (int j=0; j<W; j++)
|
||||||
green[i][j] = (image[i*W+j][1] + image[i*W+j][3]) >> 1;
|
green[i][j] = (image[i*W+j][1] + image[i*W+j][3]) /2;
|
||||||
}
|
}
|
||||||
// Interpolate R and B
|
// Interpolate R and B
|
||||||
for (int i=0; i<H; i++) {
|
for (int i=0; i<H; i++) {
|
||||||
@ -835,9 +835,9 @@ void RawImageSource::ppg_demosaic()
|
|||||||
- pix[-d][1] - pix[d][1];
|
- pix[-d][1] - pix[d][1];
|
||||||
}
|
}
|
||||||
if (diff[0] != diff[1])
|
if (diff[0] != diff[1])
|
||||||
pix[0][c] = CLIP(guess[diff[0] > diff[1]] >> 1);
|
pix[0][c] = CLIP(guess[diff[0] > diff[1]] /2);
|
||||||
else
|
else
|
||||||
pix[0][c] = CLIP((guess[0]+guess[1]) >> 2);
|
pix[0][c] = CLIP((guess[0]+guess[1]) /4);
|
||||||
}
|
}
|
||||||
if(plistener) plistener->setProgress(0.67 + 0.33*row/(height-1));
|
if(plistener) plistener->setProgress(0.67 + 0.33*row/(height-1));
|
||||||
}
|
}
|
||||||
@ -1151,7 +1151,7 @@ inline void RawImageSource::dcb_initTileLimits(int &colMin, int &rowMin, int &co
|
|||||||
if( x0+TILESIZE+TILEBORDER >= W-border) colMax = TILEBORDER+W-border-x0;
|
if( x0+TILESIZE+TILEBORDER >= W-border) colMax = TILEBORDER+W-border-x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawImageSource::fill_raw( ushort (*cache )[4], int x0, int y0, float** rawData)
|
void RawImageSource::fill_raw( float (*cache )[4], int x0, int y0, float** rawData)
|
||||||
{
|
{
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
dcb_initTileLimits(colMin,rowMin,colMax,rowMax,x0,y0,0);
|
dcb_initTileLimits(colMin,rowMin,colMax,rowMax,x0,y0,0);
|
||||||
@ -1162,7 +1162,7 @@ void RawImageSource::fill_raw( ushort (*cache )[4], int x0, int y0, float** rawD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawImageSource::fill_border( ushort (*cache )[4], int border, int x0, int y0)
|
void RawImageSource::fill_border( float (*cache )[4], int border, int x0, int y0)
|
||||||
{
|
{
|
||||||
unsigned row, col, y, x, f, c, sum[8];
|
unsigned row, col, y, x, f, c, sum[8];
|
||||||
int colors = 3;
|
int colors = 3;
|
||||||
@ -1190,7 +1190,7 @@ void RawImageSource::fill_border( ushort (*cache )[4], int border, int x0, int y
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// saves red and blue
|
// saves red and blue
|
||||||
void RawImageSource::copy_to_buffer( ushort (*buffer)[3], ushort (*image)[4])
|
void RawImageSource::copy_to_buffer( float (*buffer)[3], float (*image)[4])
|
||||||
{
|
{
|
||||||
for (int indx=0; indx < CACHESIZE*CACHESIZE; indx++) {
|
for (int indx=0; indx < CACHESIZE*CACHESIZE; indx++) {
|
||||||
buffer[indx][0]=image[indx][0]; //R
|
buffer[indx][0]=image[indx][0]; //R
|
||||||
@ -1199,7 +1199,7 @@ void RawImageSource::copy_to_buffer( ushort (*buffer)[3], ushort (*image)[4])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restores red and blue
|
// restores red and blue
|
||||||
void RawImageSource::restore_from_buffer(ushort (*image)[4], ushort (*buffer)[3])
|
void RawImageSource::restore_from_buffer(float (*image)[4], float (*buffer)[3])
|
||||||
{
|
{
|
||||||
for (int indx=0; indx < CACHESIZE*CACHESIZE; indx++) {
|
for (int indx=0; indx < CACHESIZE*CACHESIZE; indx++) {
|
||||||
image[indx][0]=buffer[indx][0]; //R
|
image[indx][0]=buffer[indx][0]; //R
|
||||||
@ -1208,7 +1208,7 @@ void RawImageSource::restore_from_buffer(ushort (*image)[4], ushort (*buffer)[3]
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First pass green interpolation
|
// First pass green interpolation
|
||||||
void RawImageSource::dcb_hid(ushort (*image)[4],ushort (*bufferH)[3], ushort (*bufferV)[3], int x0, int y0)
|
void RawImageSource::dcb_hid(float (*image)[4],float (*bufferH)[3], float (*bufferV)[3], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1278,7 +1278,7 @@ void RawImageSource::dcb_hid(ushort (*image)[4],ushort (*bufferH)[3], ushort (*b
|
|||||||
|
|
||||||
|
|
||||||
// missing colors are interpolated
|
// missing colors are interpolated
|
||||||
void RawImageSource::dcb_color(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_color(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE;
|
const int u=CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1304,7 +1304,7 @@ void RawImageSource::dcb_color(ushort (*image)[4], int x0, int y0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// green correction
|
// green correction
|
||||||
void RawImageSource::dcb_hid2(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_hid2(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1324,7 +1324,7 @@ void RawImageSource::dcb_hid2(ushort (*image)[4], int x0, int y0)
|
|||||||
// 1 = vertical
|
// 1 = vertical
|
||||||
// 0 = horizontal
|
// 0 = horizontal
|
||||||
// saved in image[][3]
|
// saved in image[][3]
|
||||||
void RawImageSource::dcb_map(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_map(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=4*CACHESIZE;
|
const int u=4*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1332,7 +1332,7 @@ void RawImageSource::dcb_map(ushort (*image)[4], int x0, int y0)
|
|||||||
|
|
||||||
for (int row=rowMin; row < rowMax; row++) {
|
for (int row=rowMin; row < rowMax; row++) {
|
||||||
for (int col=colMin, indx=row*CACHESIZE+col; col < colMax; col++, indx++) {
|
for (int col=colMin, indx=row*CACHESIZE+col; col < colMax; col++, indx++) {
|
||||||
ushort *pix = &(image[indx][1]);
|
float *pix = &(image[indx][1]);
|
||||||
if ( *pix > ( pix[-4] + pix[+4] + pix[-u] + pix[+u])/4 )
|
if ( *pix > ( pix[-4] + pix[+4] + pix[-u] + pix[+u])/4 )
|
||||||
image[indx][3] = ((MIN( pix[-4], pix[+4]) + pix[-4] + pix[+4] ) < (MIN( pix[-u], pix[+u]) + pix[-u] + pix[+u]));
|
image[indx][3] = ((MIN( pix[-4], pix[+4]) + pix[-4] + pix[+4] ) < (MIN( pix[-u], pix[+u]) + pix[-u] + pix[+u]));
|
||||||
else
|
else
|
||||||
@ -1343,7 +1343,7 @@ void RawImageSource::dcb_map(ushort (*image)[4], int x0, int y0)
|
|||||||
|
|
||||||
|
|
||||||
// interpolated green pixels are corrected using the map
|
// interpolated green pixels are corrected using the map
|
||||||
void RawImageSource::dcb_correction(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_correction(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1360,7 +1360,7 @@ void RawImageSource::dcb_correction(ushort (*image)[4], int x0, int y0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// R and B smoothing using green contrast, all pixels except 2 pixel wide border
|
// R and B smoothing using green contrast, all pixels except 2 pixel wide border
|
||||||
void RawImageSource::dcb_pp(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_pp(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE;
|
const int u=CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1371,7 +1371,7 @@ void RawImageSource::dcb_pp(ushort (*image)[4], int x0, int y0)
|
|||||||
//int r1 = ( image[indx-1][0] + image[indx+1][0] + image[indx-u][0] + image[indx+u][0] + image[indx-u-1][0] + image[indx+u+1][0] + image[indx-u+1][0] + image[indx+u-1][0])/8;
|
//int r1 = ( image[indx-1][0] + image[indx+1][0] + image[indx-u][0] + image[indx+u][0] + image[indx-u-1][0] + image[indx+u+1][0] + image[indx-u+1][0] + image[indx+u-1][0])/8;
|
||||||
//int g1 = ( image[indx-1][1] + image[indx+1][1] + image[indx-u][1] + image[indx+u][1] + image[indx-u-1][1] + image[indx+u+1][1] + image[indx-u+1][1] + image[indx+u-1][1])/8;
|
//int g1 = ( image[indx-1][1] + image[indx+1][1] + image[indx-u][1] + image[indx+u][1] + image[indx-u-1][1] + image[indx+u+1][1] + image[indx-u+1][1] + image[indx+u-1][1])/8;
|
||||||
//int b1 = ( image[indx-1][2] + image[indx+1][2] + image[indx-u][2] + image[indx+u][2] + image[indx-u-1][2] + image[indx+u+1][2] + image[indx-u+1][2] + image[indx+u-1][2])/8;
|
//int b1 = ( image[indx-1][2] + image[indx+1][2] + image[indx-u][2] + image[indx+u][2] + image[indx-u-1][2] + image[indx+u+1][2] + image[indx-u+1][2] + image[indx+u-1][2])/8;
|
||||||
ushort (*pix)[4] = image+(indx-u-1);
|
float (*pix)[4] = image+(indx-u-1);
|
||||||
int r1 = (*pix)[0];
|
int r1 = (*pix)[0];
|
||||||
int g1 = (*pix)[1];
|
int g1 = (*pix)[1];
|
||||||
int b1 = (*pix)[2];
|
int b1 = (*pix)[2];
|
||||||
@ -1415,7 +1415,7 @@ void RawImageSource::dcb_pp(ushort (*image)[4], int x0, int y0)
|
|||||||
|
|
||||||
// interpolated green pixels are corrected using the map
|
// interpolated green pixels are corrected using the map
|
||||||
// with correction
|
// with correction
|
||||||
void RawImageSource::dcb_correction2(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_correction2(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1433,7 +1433,7 @@ void RawImageSource::dcb_correction2(ushort (*image)[4], int x0, int y0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// image refinement
|
// image refinement
|
||||||
void RawImageSource::dcb_refinement(ushort (*image)[4], int x0, int y0)
|
void RawImageSource::dcb_refinement(float (*image)[4], int x0, int y0)
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE, w=3*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE, w=3*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1476,7 +1476,7 @@ void RawImageSource::dcb_refinement(ushort (*image)[4], int x0, int y0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// missing colors are interpolated using high quality algorithm by Luis Sanz Rodríguez
|
// missing colors are interpolated using high quality algorithm by Luis Sanz Rodríguez
|
||||||
void RawImageSource::dcb_color_full(ushort (*image)[4], int x0, int y0, float (*chroma)[2])
|
void RawImageSource::dcb_color_full(float (*image)[4], int x0, int y0, float (*chroma)[2])
|
||||||
{
|
{
|
||||||
const int u=CACHESIZE, v=2*CACHESIZE, w=3*CACHESIZE;
|
const int u=CACHESIZE, v=2*CACHESIZE, w=3*CACHESIZE;
|
||||||
int rowMin,colMin,rowMax,colMax;
|
int rowMin,colMin,rowMax,colMax;
|
||||||
@ -1539,20 +1539,20 @@ void RawImageSource::dcb_demosaic(int iterations, int dcb_enhance)
|
|||||||
int tilesDone=0;
|
int tilesDone=0;
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
int nthreads = omp_get_max_threads();
|
int nthreads = omp_get_max_threads();
|
||||||
ushort (**image)[4] = (ushort(**)[4]) calloc( nthreads,sizeof( void*) );
|
float (**image)[4] = (float(**)[4]) calloc( nthreads,sizeof( void*) );
|
||||||
ushort (**image2)[3] = (ushort(**)[3]) calloc( nthreads,sizeof( void*) );
|
float (**image2)[3] = (float(**)[3]) calloc( nthreads,sizeof( void*) );
|
||||||
ushort (**image3)[3] = (ushort(**)[3]) calloc( nthreads,sizeof( void*) );
|
float (**image3)[3] = (float(**)[3]) calloc( nthreads,sizeof( void*) );
|
||||||
float (**chroma)[2] = (float (**)[2]) calloc( nthreads,sizeof( void*) );
|
float (**chroma)[2] = (float (**)[2]) calloc( nthreads,sizeof( void*) );
|
||||||
for(int i=0; i<nthreads; i++){
|
for(int i=0; i<nthreads; i++){
|
||||||
image[i] = (ushort(*)[4]) calloc( CACHESIZE*CACHESIZE, sizeof **image);
|
image[i] = (float(*)[4]) calloc( CACHESIZE*CACHESIZE, sizeof **image);
|
||||||
image2[i]= (ushort(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof **image2);
|
image2[i]= (float(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof **image2);
|
||||||
image3[i]= (ushort(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof **image3);
|
image3[i]= (float(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof **image3);
|
||||||
chroma[i]= (float (*)[2]) calloc( CACHESIZE*CACHESIZE, sizeof **chroma);
|
chroma[i]= (float (*)[2]) calloc( CACHESIZE*CACHESIZE, sizeof **chroma);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ushort (*image)[4] = (ushort(*)[4]) calloc( CACHESIZE*CACHESIZE, sizeof *image);
|
float (*image)[4] = (float(*)[4]) calloc( CACHESIZE*CACHESIZE, sizeof *image);
|
||||||
ushort (*image2)[3] = (ushort(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof *image2);
|
float (*image2)[3] = (float(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof *image2);
|
||||||
ushort (*image3)[3] = (ushort(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof *image3);
|
float (*image3)[3] = (float(*)[3]) calloc( CACHESIZE*CACHESIZE, sizeof *image3);
|
||||||
float (*chroma)[2] = (float (*)[2]) calloc( CACHESIZE*CACHESIZE, sizeof *chroma);
|
float (*chroma)[2] = (float (*)[2]) calloc( CACHESIZE*CACHESIZE, sizeof *chroma);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1565,14 +1565,14 @@ void RawImageSource::dcb_demosaic(int iterations, int dcb_enhance)
|
|||||||
|
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
int tid = omp_get_thread_num();
|
int tid = omp_get_thread_num();
|
||||||
ushort (*tile)[4] = image[tid];
|
float (*tile)[4] = image[tid];
|
||||||
ushort (*buffer)[3] = image2[tid];
|
float (*buffer)[3] = image2[tid];
|
||||||
ushort (*buffer2)[3]= image3[tid];
|
float (*buffer2)[3]= image3[tid];
|
||||||
float (*chrm)[2] = chroma[tid];
|
float (*chrm)[2] = chroma[tid];
|
||||||
#else
|
#else
|
||||||
ushort (*tile)[4] = image;
|
float (*tile)[4] = image;
|
||||||
ushort (*buffer)[3] = image2;
|
float (*buffer)[3] = image2;
|
||||||
ushort (*buffer2)[3]= image3;
|
float (*buffer2)[3]= image3;
|
||||||
float (*chrm)[2] = chroma;
|
float (*chrm)[2] = chroma;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -45,12 +45,14 @@ extern const Settings* settings;
|
|||||||
#undef MAX
|
#undef MAX
|
||||||
#undef MIN
|
#undef MIN
|
||||||
#undef DIST
|
#undef DIST
|
||||||
|
#undef CLIP
|
||||||
|
|
||||||
#define ABS(a) ((a)<0?-(a):(a))
|
#define ABS(a) ((a)<0?-(a):(a))
|
||||||
#define MAX(a,b) ((a)<(b)?(b):(a))
|
#define MAX(a,b) ((a)<(b)?(b):(a))
|
||||||
#define MIN(a,b) ((a)>(b)?(b):(a))
|
#define MIN(a,b) ((a)>(b)?(b):(a))
|
||||||
#define DIST(a,b) (ABS(a-b))
|
#define DIST(a,b) (ABS(a-b))
|
||||||
#define MAXVAL 0xffff
|
#define MAXVAL 0xffff
|
||||||
|
#define CLIP(a) ((a)>0?((a)<MAXVAL?(a):MAXVAL):0)
|
||||||
|
|
||||||
#define PIX_SORT(a,b) { if ((a)>(b)) {temp=(a);(a)=(b);(b)=temp;} }
|
#define PIX_SORT(a,b) { if ((a)>(b)) {temp=(a);(a)=(b);(b)=temp;} }
|
||||||
|
|
||||||
@ -1702,17 +1704,12 @@ TMatrix work = iccStore->workingSpaceInverseMatrix (cmp.working);
|
|||||||
for (int j=0; j<im->width; j++) {
|
for (int j=0; j<im->width; j++) {
|
||||||
|
|
||||||
float newr = mat[0][0]*im->r[i][j] + mat[0][1]*im->g[i][j] + mat[0][2]*im->b[i][j];
|
float newr = mat[0][0]*im->r[i][j] + mat[0][1]*im->g[i][j] + mat[0][2]*im->b[i][j];
|
||||||
if (newr<0) newr=0; else if (newr>0xffff) newr=0xffff;
|
|
||||||
|
|
||||||
float newg = mat[1][0]*im->r[i][j] + mat[1][1]*im->g[i][j] + mat[1][2]*im->b[i][j];
|
float newg = mat[1][0]*im->r[i][j] + mat[1][1]*im->g[i][j] + mat[1][2]*im->b[i][j];
|
||||||
if (newg<0) newg=0; else if (newg>0xffff) newg=0xffff;
|
|
||||||
|
|
||||||
float newb = mat[2][0]*im->r[i][j] + mat[2][1]*im->g[i][j] + mat[2][2]*im->b[i][j];
|
float newb = mat[2][0]*im->r[i][j] + mat[2][1]*im->g[i][j] + mat[2][2]*im->b[i][j];
|
||||||
if (newb<0) newb=0; else if (newb>0xffff) newb=0xffff;
|
|
||||||
|
|
||||||
im->r[i][j] = (newr);
|
im->r[i][j] = CLIP((int)newr);
|
||||||
im->g[i][j] = (newg);
|
im->g[i][j] = CLIP((int)newg);
|
||||||
im->b[i][j] = (newb);
|
im->b[i][j] = CLIP((int)newb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -175,19 +175,19 @@ class RawImageSource : public ImageSource {
|
|||||||
void ahd_demosaic(int winx, int winy, int winw, int winh);
|
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 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 dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border);
|
||||||
void fill_raw( ushort (*cache )[4], int x0, int y0, float** rawData);
|
void fill_raw( float (*cache )[4], int x0, int y0, float** rawData);
|
||||||
void fill_border( ushort (*cache )[4], int border, int x0, int y0);
|
void fill_border( float (*cache )[4], int border, int x0, int y0);
|
||||||
void copy_to_buffer(ushort (*image2)[3], ushort (*image)[4]);
|
void copy_to_buffer(float (*image2)[3], float (*image)[4]);
|
||||||
void dcb_hid(ushort (*image)[4], ushort (*bufferH)[3], ushort (*bufferV)[3], int x0, int y0);
|
void dcb_hid(float (*image)[4], float (*bufferH)[3], float (*bufferV)[3], int x0, int y0);
|
||||||
void dcb_color(ushort (*image)[4], int x0, int y0);
|
void dcb_color(float (*image)[4], int x0, int y0);
|
||||||
void dcb_hid2(ushort (*image)[4], int x0, int y0);
|
void dcb_hid2(float (*image)[4], int x0, int y0);
|
||||||
void dcb_map(ushort (*image)[4], int x0, int y0);
|
void dcb_map(float (*image)[4], int x0, int y0);
|
||||||
void dcb_correction(ushort (*image)[4], int x0, int y0);
|
void dcb_correction(float (*image)[4], int x0, int y0);
|
||||||
void dcb_pp(ushort (*image)[4], int x0, int y0);
|
void dcb_pp(float (*image)[4], int x0, int y0);
|
||||||
void dcb_correction2(ushort (*image)[4], int x0, int y0);
|
void dcb_correction2(float (*image)[4], int x0, int y0);
|
||||||
void restore_from_buffer(ushort (*image)[4], ushort (*image2)[3]);
|
void restore_from_buffer(float (*image)[4], float (*image2)[3]);
|
||||||
void dcb_refinement(ushort (*image)[4], int x0, int y0);
|
void dcb_refinement(float (*image)[4], int x0, int y0);
|
||||||
void dcb_color_full(ushort (*image)[4], int x0, int y0, float (*chroma)[2]);
|
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 transLine (float* red, float* green, float* blue, int i, Imagefloat* image, int tran, int imw, int imh, int fw);
|
||||||
void hflip (Imagefloat* im);
|
void hflip (Imagefloat* im);
|
||||||
|
@ -128,13 +128,6 @@ void SHMap::update (Imagefloat* img, float** buffer, double radius, double lumi[
|
|||||||
level += 1;
|
level += 1;
|
||||||
indx = 1-indx;
|
indx = 1-indx;
|
||||||
}
|
}
|
||||||
/*dirpyr_shmap(dirpyrlo[0], dirpyrlo[1], W, H, rangefn, 1, scale );
|
|
||||||
scale = 4;
|
|
||||||
dirpyr_shmap(dirpyrlo[1], dirpyrlo[0], W, H, rangefn, 2, scale );
|
|
||||||
scale = 8;
|
|
||||||
dirpyr_shmap(dirpyrlo[0], dirpyrlo[1], W, H, rangefn, 3, scale );
|
|
||||||
scale = 16;
|
|
||||||
dirpyr_shmap(dirpyrlo[1], map, W, H, rangefn, 3, scale );*/
|
|
||||||
|
|
||||||
dirpyr_shmap(dirpyrlo[1-indx], map, W, H, rangefn, level, scale );
|
dirpyr_shmap(dirpyrlo[1-indx], map, W, H, rangefn, level, scale );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user