Skip to content

Commit c018d36

Browse files
committed
analysis
Signed-off-by: Anton Dukhovnikov <[email protected]>
1 parent 4d20772 commit c018d36

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -610,14 +610,14 @@ struct IDTOptimizationCost
610610
IDTOptimizationCost(
611611
const std::vector<std::vector<double>> &RGB,
612612
const std::vector<std::vector<double>> &out_LAB )
613-
: _RGB( RGB ), _outLAB( out_LAB )
613+
: _in_RGB( RGB ), _out_LAB( out_LAB )
614614
{}
615615

616616
template <typename T>
617617
bool operator()( const T *beta_params, T *residuals ) const;
618618

619-
const std::vector<std::vector<double>> _RGB;
620-
const std::vector<std::vector<double>> _outLAB;
619+
const std::vector<std::vector<double>> _in_RGB;
620+
const std::vector<std::vector<double>> _out_LAB;
621621
};
622622

623623
/// Perform curve fitting optimization to find optimal IDT matrix parameters.
@@ -977,9 +977,9 @@ vector<double> find_XYZ_to_camera_matrix(
977977
metadata.calibration[1].XYZ_to_RGB_matrix;
978978

979979
double low_mired =
980-
std::max( min_mired, std::min( max_mired, std::min( mir1, mir2 ) ) );
980+
std::clamp( std::min( mir1, mir2 ), min_mired, max_mired );
981981
double high_mired =
982-
std::max( min_mired, std::min( max_mired, std::max( mir1, mir2 ) ) );
982+
std::clamp( std::max( mir1, mir2 ), min_mired, max_mired );
983983
double mirStep = std::max( 5.0, ( high_mired - low_mired ) / 50.0 );
984984

985985
double current_mired = 0.0, last_mired = 0.0, estimated_mired = 0.0,
@@ -1229,16 +1229,16 @@ vector<vector<double>> MetadataSolver::calculate_IDT_matrix()
12291229
template <typename T>
12301230
bool IDTOptimizationCost::operator()( const T *beta_params, T *residuals ) const
12311231
{
1232-
vector<vector<T>> RGB_copy( _RGB.size(), vector<T>( 3 ) );
1233-
for ( size_t i = 0; i < _RGB.size(); i++ )
1232+
vector<vector<T>> RGB_copy( _in_RGB.size(), vector<T>( 3 ) );
1233+
for ( size_t i = 0; i < _in_RGB.size(); i++ )
12341234
for ( size_t j = 0; j < 3; j++ )
1235-
RGB_copy[i][j] = T( _RGB[i][j] );
1235+
RGB_copy[i][j] = T( _in_RGB[i][j] );
12361236

12371237
vector<vector<T>> out_calc_LAB =
12381238
XYZ_to_LAB( getCalcXYZt( RGB_copy, beta_params ) );
1239-
for ( size_t i = 0; i < _RGB.size(); i++ )
1239+
for ( size_t i = 0; i < _in_RGB.size(); i++ )
12401240
for ( size_t j = 0; j < 3; j++ )
1241-
residuals[i * 3 + j] = _outLAB[i][j] - out_calc_LAB[i][j];
1241+
residuals[i * 3 + j] = _out_LAB[i][j] - out_calc_LAB[i][j];
12421242

12431243
return true;
12441244
}

src/rawtoaces_util/image_converter.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ bool prepare_transform_spectral(
317317
if ( attr )
318318
{
319319
for ( int i = 0; i < 4; i++ )
320-
tmp_wb_multipliers[i] = attr->get_float_indexed( i );
320+
tmp_wb_multipliers[i] =
321+
static_cast<double>( attr->get_float_indexed( i ) );
321322
}
322323
}
323324

@@ -428,8 +429,8 @@ bool prepare_transform_DNG(
428429
// Step 1: Extract basic DNG metadata
429430
core::Metadata metadata;
430431

431-
metadata.baseline_exposure =
432-
image_spec.get_float_attribute( "raw:dng:baseline_exposure" );
432+
metadata.baseline_exposure = static_cast<double>(
433+
image_spec.get_float_attribute( "raw:dng:baseline_exposure" ) );
433434

434435
// Step 2: Extract neutral RGB values from camera multipliers
435436
metadata.neutral_RGB.resize( 3 );
@@ -439,7 +440,8 @@ bool prepare_transform_DNG(
439440
if ( attr )
440441
{
441442
for ( int i = 0; i < 3; i++ )
442-
metadata.neutral_RGB[i] = 1.0 / attr->get_float_indexed( i );
443+
metadata.neutral_RGB[i] =
444+
1.0 / static_cast<double>( attr->get_float_indexed( i ) );
443445
}
444446

445447
// Step 3: Extract calibration data for two illuminants
@@ -467,7 +469,8 @@ bool prepare_transform_DNG(
467469
for ( int j = 0; j < 3; j++ )
468470
{
469471
calibration.XYZ_to_RGB_matrix[i * 3 + j] =
470-
matrix1_attr->get_float_indexed( i * 3 + j );
472+
static_cast<double>(
473+
matrix1_attr->get_float_indexed( i * 3 + j ) );
471474
}
472475
}
473476
}
@@ -483,7 +486,8 @@ bool prepare_transform_DNG(
483486
for ( int j = 0; j < 3; j++ )
484487
{
485488
calibration.camera_calibration_matrix[i * 3 + j] =
486-
matrix2_attr->get_float_indexed( i * 4 + j );
489+
static_cast<double>(
490+
matrix2_attr->get_float_indexed( i * 4 + j ) );
487491
}
488492
}
489493
}
@@ -1296,8 +1300,8 @@ bool ImageConverter::configure(
12961300
settings.crop_box );
12971301
}
12981302

1299-
if ( settings.chromatic_aberration[0] != 1.0 &&
1300-
settings.chromatic_aberration[1] != 1.0 )
1303+
if ( settings.chromatic_aberration[0] != 1.0f &&
1304+
settings.chromatic_aberration[1] != 1.0f )
13011305
{
13021306
options.attribute(
13031307
"raw:aber",
@@ -1330,7 +1334,7 @@ bool ImageConverter::configure(
13301334

13311335
_wb_multipliers.resize( 4 );
13321336
for ( size_t i = 0; i < 4; i++ )
1333-
_wb_multipliers[i] = custom_WB[i];
1337+
_wb_multipliers[i] = static_cast<double>( custom_WB[i] );
13341338
}
13351339
break;
13361340
}
@@ -1368,7 +1372,8 @@ bool ImageConverter::configure(
13681372

13691373
_wb_multipliers.resize( 4 );
13701374
for ( size_t i = 0; i < 4; i++ )
1371-
_wb_multipliers[i] = settings.custom_WB[i];
1375+
_wb_multipliers[i] =
1376+
static_cast<double>( settings.custom_WB[i] );
13721377
break;
13731378

13741379
default:
@@ -1428,7 +1433,8 @@ bool ImageConverter::configure(
14281433
_idt_matrix[i].resize( 3 );
14291434
for ( int j = 0; j < 3; j++ )
14301435
{
1431-
_idt_matrix[i][j] = settings.custom_matrix[i][j];
1436+
_idt_matrix[i][j] =
1437+
static_cast<double>( settings.custom_matrix[i][j] );
14321438
}
14331439
}
14341440
break;

0 commit comments

Comments
 (0)