Some modifications for Fuji S5 patch from Francisco

This commit is contained in:
Wyatt Olson 2010-04-23 21:15:35 -06:00
parent 69bf3c0500
commit d475a2875d

View File

@ -8863,13 +8863,16 @@ int loadFujiRaw (const char* fname, struct RawImage *ri) {
int row;
int c;
// Valores de saturacion escalados entre 0 y 1 sobre 2^14
int max_val = pow(2, 14) - 1;
float sat_s;
float sat_r;
ushort max_val = pow(2, 14) - 1;
float sat_s;
// Factores entre los diferentes canales
const float factor_canal[] = {4.32, 3.84, 4.46, 3.84};
ushort *pvalue_r;
ushort *pvalue_s;
float svalue;
float rvalue;
// Factors between S captors and R captors
const double factor_canal[] = {17.71, 15.75, 18.3, 15.75};
static const double xyzd50_srgb[3][3] =
{ { 0.436083, 0.385083, 0.143055 },
@ -8899,7 +8902,7 @@ dcrMutex->lock ();
highlight = 1;
half_size = 0;
//Sensor R
// Load image belonging to the R captors
shot_select = 1;
identify ();
@ -8927,13 +8930,12 @@ dcrMutex->lock ();
fseek (ifp, data_offset, SEEK_SET);
(*load_raw)();
// Copiaremos la imagen en otra ubicacion y la liberaremos
memcpy(image_r, image, height*width*sizeof *image + meta_length);
height_r = height;
width_r = width;
free(image);
// Cargaremos la otra imagen
// Load image belonging to the S captors
exif_base = -1;
ciff_base = -1;
ciff_len = -1;
@ -8942,9 +8944,8 @@ dcrMutex->lock ();
ri->data = NULL;
ri->allocation = NULL;
ri->profile_data = NULL;
fseek (ifp, 0, SEEK_SET); // Podremos el apuntador del fichero en el inicio
fseek (ifp, 0, SEEK_SET);
//Sensor S
shot_select = 0;
use_camera_wb = 0;
@ -8975,7 +8976,7 @@ dcrMutex->lock ();
fseek (ifp, data_offset, SEEK_SET);
(*load_raw)();
// Segun los valores de iso establecemos los valores de saturacion de S
// The saturation of the S captors depends of the ISO value
switch((int)iso_speed){
case 100:
sat_s = 0.82;
@ -8984,70 +8985,24 @@ dcrMutex->lock ();
sat_s = 0.96;
}
// Segun los valores de iso establecemos los valores de saturacion de R
switch((int)iso_speed){
case 100:
sat_r = 0.20;
break;
case 125:
sat_r = 0.28;
break;
case 160:
sat_r = 0.36;
break;
case 200:
sat_r = 0.31;
break;
case 250:
sat_r = 0.4;
break;
case 320:
sat_r = 0.5;
break;
case 400:
sat_r = 0.41;
break;
case 500:
sat_r = 0.52;
break;
case 640:
sat_r = 0.68;
break;
default:
sat_r = 0.96;
}
ushort saturacion = sat_s * max_val;
printf("Los valores de saturacion son: %f(S), %f(R)", sat_s, sat_r);
// Escalamos los valores
ushort *pvalue_r;
ushort *pvalue_s;
float svalue;
float rvalue;
float value;
// Scale values
for (int row = 0; row < height_r; row++)
for (int col = 0; col < width_r; col++)
FORC4 {
pvalue_r = &image_r[row*width_r+col][c];
pvalue_s = &image[(row+1)*width+col][c];
rvalue = *pvalue_r/(float)max_val;
svalue = *pvalue_s/(float)max_val;
rvalue = *pvalue_r;
svalue = *pvalue_s;
value = MIN(svalue/sat_s, 1.0);
// If the captors is saturated
if(svalue > saturacion)
svalue = rvalue * factor_canal[c];
if(value == 1.0) /* Si el pixel esta saturado */
value = MIN(rvalue/sat_r, 1.0) * factor_canal[c];
value /= 4.46;
// Escalamos el valor a 2^16
value *= (pow(2,16) - 1);
// Asignamos el valor a la imagen S
*pvalue_s = (ushort) CLIP(value);
*pvalue_s = (ushort) CLIP(svalue);
}
puts("Concluido");
ri->profile_len = 0;
ri->profile_data = NULL;
if (profile_length) {
@ -9064,10 +9019,8 @@ dcrMutex->lock ();
ri->green_multiplier = pre_mul[1];
ri->blue_multiplier = pre_mul[2];
// Establecemos el maximo en 65535 con el fin de que no se escalen
// los valores, ya que estos han sido ya escalados previamente por
// nosotros. No obstante deberemos seguir ejecutando scale_colors,
// ya que dicha funcion aplica el balance de blancos
// We set up the max value to 65535 for don't scale values. However
// we should execute "scale_colors" to apply the white balance
maximum = 65535;
scale_colors();