Some modifications for Fuji S5 patch from Francisco
This commit is contained in:
parent
69bf3c0500
commit
d475a2875d
@ -8863,13 +8863,16 @@ int loadFujiRaw (const char* fname, struct RawImage *ri) {
|
|||||||
int row;
|
int row;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
// Valores de saturacion escalados entre 0 y 1 sobre 2^14
|
ushort max_val = pow(2, 14) - 1;
|
||||||
int max_val = pow(2, 14) - 1;
|
|
||||||
float sat_s;
|
float sat_s;
|
||||||
float sat_r;
|
|
||||||
|
|
||||||
// Factores entre los diferentes canales
|
ushort *pvalue_r;
|
||||||
const float factor_canal[] = {4.32, 3.84, 4.46, 3.84};
|
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] =
|
static const double xyzd50_srgb[3][3] =
|
||||||
{ { 0.436083, 0.385083, 0.143055 },
|
{ { 0.436083, 0.385083, 0.143055 },
|
||||||
@ -8899,7 +8902,7 @@ dcrMutex->lock ();
|
|||||||
highlight = 1;
|
highlight = 1;
|
||||||
half_size = 0;
|
half_size = 0;
|
||||||
|
|
||||||
//Sensor R
|
// Load image belonging to the R captors
|
||||||
shot_select = 1;
|
shot_select = 1;
|
||||||
|
|
||||||
identify ();
|
identify ();
|
||||||
@ -8927,13 +8930,12 @@ dcrMutex->lock ();
|
|||||||
fseek (ifp, data_offset, SEEK_SET);
|
fseek (ifp, data_offset, SEEK_SET);
|
||||||
(*load_raw)();
|
(*load_raw)();
|
||||||
|
|
||||||
// Copiaremos la imagen en otra ubicacion y la liberaremos
|
|
||||||
memcpy(image_r, image, height*width*sizeof *image + meta_length);
|
memcpy(image_r, image, height*width*sizeof *image + meta_length);
|
||||||
height_r = height;
|
height_r = height;
|
||||||
width_r = width;
|
width_r = width;
|
||||||
free(image);
|
free(image);
|
||||||
|
|
||||||
// Cargaremos la otra imagen
|
// Load image belonging to the S captors
|
||||||
exif_base = -1;
|
exif_base = -1;
|
||||||
ciff_base = -1;
|
ciff_base = -1;
|
||||||
ciff_len = -1;
|
ciff_len = -1;
|
||||||
@ -8942,9 +8944,8 @@ dcrMutex->lock ();
|
|||||||
ri->data = NULL;
|
ri->data = NULL;
|
||||||
ri->allocation = NULL;
|
ri->allocation = NULL;
|
||||||
ri->profile_data = 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;
|
shot_select = 0;
|
||||||
|
|
||||||
use_camera_wb = 0;
|
use_camera_wb = 0;
|
||||||
@ -8975,7 +8976,7 @@ dcrMutex->lock ();
|
|||||||
fseek (ifp, data_offset, SEEK_SET);
|
fseek (ifp, data_offset, SEEK_SET);
|
||||||
(*load_raw)();
|
(*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){
|
switch((int)iso_speed){
|
||||||
case 100:
|
case 100:
|
||||||
sat_s = 0.82;
|
sat_s = 0.82;
|
||||||
@ -8984,70 +8985,24 @@ dcrMutex->lock ();
|
|||||||
sat_s = 0.96;
|
sat_s = 0.96;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Segun los valores de iso establecemos los valores de saturacion de R
|
ushort saturacion = sat_s * max_val;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Los valores de saturacion son: %f(S), %f(R)", sat_s, sat_r);
|
// Scale values
|
||||||
|
|
||||||
// Escalamos los valores
|
|
||||||
ushort *pvalue_r;
|
|
||||||
ushort *pvalue_s;
|
|
||||||
float svalue;
|
|
||||||
float rvalue;
|
|
||||||
float value;
|
|
||||||
for (int row = 0; row < height_r; row++)
|
for (int row = 0; row < height_r; row++)
|
||||||
for (int col = 0; col < width_r; col++)
|
for (int col = 0; col < width_r; col++)
|
||||||
FORC4 {
|
FORC4 {
|
||||||
pvalue_r = &image_r[row*width_r+col][c];
|
pvalue_r = &image_r[row*width_r+col][c];
|
||||||
pvalue_s = &image[(row+1)*width+col][c];
|
pvalue_s = &image[(row+1)*width+col][c];
|
||||||
rvalue = *pvalue_r/(float)max_val;
|
rvalue = *pvalue_r;
|
||||||
svalue = *pvalue_s/(float)max_val;
|
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 */
|
*pvalue_s = (ushort) CLIP(svalue);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("Concluido");
|
|
||||||
|
|
||||||
ri->profile_len = 0;
|
ri->profile_len = 0;
|
||||||
ri->profile_data = NULL;
|
ri->profile_data = NULL;
|
||||||
if (profile_length) {
|
if (profile_length) {
|
||||||
@ -9064,10 +9019,8 @@ dcrMutex->lock ();
|
|||||||
ri->green_multiplier = pre_mul[1];
|
ri->green_multiplier = pre_mul[1];
|
||||||
ri->blue_multiplier = pre_mul[2];
|
ri->blue_multiplier = pre_mul[2];
|
||||||
|
|
||||||
// Establecemos el maximo en 65535 con el fin de que no se escalen
|
// We set up the max value to 65535 for don't scale values. However
|
||||||
// los valores, ya que estos han sido ya escalados previamente por
|
// we should execute "scale_colors" to apply the white balance
|
||||||
// nosotros. No obstante deberemos seguir ejecutando scale_colors,
|
|
||||||
// ya que dicha funcion aplica el balance de blancos
|
|
||||||
maximum = 65535;
|
maximum = 65535;
|
||||||
|
|
||||||
scale_colors();
|
scale_colors();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user