Fixed progress indication for AHD demosaic; code formatted

This commit is contained in:
Ilia Popov 2010-07-21 22:34:52 +02:00
parent 54bcc00087
commit eb24ebe041

View File

@ -2366,7 +2366,9 @@ void RawImageSource::ahd_demosaic()
const double xyz_rgb[3][3] = { /* XYZ from RGB */
{ 0.412453, 0.357580, 0.180423 },
{ 0.212671, 0.715160, 0.072169 },
{ 0.019334, 0.119193, 0.950227 } };
{ 0.019334, 0.119193, 0.950227 }
};
const float d65_white[3] = { 0.950456, 1, 1.088754 };
if (plistener) {
@ -2383,6 +2385,7 @@ void RawImageSource::ahd_demosaic()
r = i / 65535.0;
cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0;
}
for (i=0; i < 3; i++)
for (j=0; j < colors; j++)
for (xyz_cam[i][j] = k=0; k < 3; k++)
@ -2395,10 +2398,14 @@ void RawImageSource::ahd_demosaic()
lab = (short (*)[TS][TS][3])(buffer + 12*TS*TS);
homo = (char (*)[TS][TS]) (buffer + 24*TS*TS);
// helper variables for progress indication
int n_tiles = ((height-7 + (TS-7))/(TS-6)) * ((width-7 + (TS-7))/(TS-6));
int tile = 0;
for (top=2; top < height-5; top += TS-6)
for (left=2; left < width-5; left += TS-6) {
/* Interpolate green horizontally and vertically: */
/* Interpolate green horizontally and vertically: */
for (row = top; row < top+TS && row < height-2; row++) {
col = left + (FC(row,left) & 1);
for (c = FC(row,col); col < left+TS && col < width-2; col+=2) {
@ -2412,8 +2419,7 @@ void RawImageSource::ahd_demosaic()
}
}
if(plistener) plistener->setProgress (0.33);
/* Interpolate red and blue, and convert to CIELab: */
/* Interpolate red and blue, and convert to CIELab: */
for (d=0; d < 2; d++)
for (row=top+1; row < top+TS-1 && row < height-3; row++)
for (col=left+1; col < left+TS-1 && col < width-3; col++) {
@ -2449,8 +2455,7 @@ void RawImageSource::ahd_demosaic()
lix[0][2] = 64 * 200 * (xyz[1] - xyz[2]);
}
if(plistener) plistener->setProgress (0.5);
/* Build homogeneity maps from the CIELab images: */
/* Build homogeneity maps from the CIELab images: */
memset (homo, 0, 2*TS*TS);
for (row=top+2; row < top+TS-2 && row < height-4; row++) {
tr = row-top;
@ -2474,8 +2479,8 @@ void RawImageSource::ahd_demosaic()
homo[d][tr][tc]++;
}
}
if(plistener) plistener->setProgress (0.8);
/* Combine the most homogenous pixels for the final result: */
/* Combine the most homogenous pixels for the final result: */
for (row=top+3; row < top+TS-3 && row < height-5; row++) {
tr = row-top;
for (col=left+3; col < left+TS-3 && col < width-5; col++) {
@ -2491,7 +2496,13 @@ void RawImageSource::ahd_demosaic()
(rgb[0][tr][tc][c] + rgb[1][tr][tc][c]) >> 1;
}
}
tile++;
if(plistener) {
plistener->setProgress((double)tile / n_tiles);
}
}
if(plistener) plistener->setProgress (1.0);
free (buffer);
red = new unsigned short*[H];