Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ include(FetchContent)
FetchContent_Declare(
rawtoaces_data
GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/rawtoaces-data
GIT_TAG 4db0acc872965ecdbbf578664be20abf17c18e8c # v0.1.0
GIT_TAG 265e0038826572439d23934120f4bc69c19933e3 # v1.0.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏼

)

FetchContent_MakeAvailable(rawtoaces_data)
Expand Down
3 changes: 1 addition & 2 deletions include/rawtoaces/spectral_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ struct SpectralData
/// Header data
std::string manufacturer;
std::string model;
std::string illuminant;
std::string catalog_number;
std::string type;
std::string description;
std::string document_creator;
std::string unique_identifier;
Expand Down
6 changes: 3 additions & 3 deletions src/rawtoaces_core/rawtoaces_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void generate_illuminant(
SpectralData::SpectralChannel( "power", Spectrum( 0 ) ) );
auto &power_spectrum = power_data.second;

illuminant.illuminant = type;
illuminant.type = type;
if ( is_daylight )
{
calculate_daylight_SPD( cct, power_spectrum );
Expand Down Expand Up @@ -335,7 +335,7 @@ bool SpectralSolver::find_illuminant( const std::string &type )
{
if ( !illuminant.load( illuminant_file ) )
continue;
if ( is_not_equal_insensitive( illuminant.illuminant, type ) )
if ( is_not_equal_insensitive( illuminant.type, type ) )
continue;
return true;
}
Expand Down Expand Up @@ -403,7 +403,7 @@ bool SpectralSolver::find_illuminant( const vector<double> &wb )

if ( verbosity > 1 )
std::cerr << "The illuminant calculated to be the best match to the "
<< "camera metadata is '" << illuminant.illuminant << "'."
<< "camera metadata is '" << illuminant.type << "'."
<< std::endl;

return true;
Expand Down
19 changes: 15 additions & 4 deletions src/rawtoaces_core/spectral_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ bool SpectralData::load( const std::string &path, bool reshape )
// Reset all in case the object has been initialised before.
manufacturer.erase();
model.erase();
illuminant.erase();
catalog_number.erase();
type.erase();
description.erase();
document_creator.erase();
unique_identifier.erase();
Expand Down Expand Up @@ -216,8 +215,7 @@ bool SpectralData::load( const std::string &path, bool reshape )
nlohmann::json &h = file_data["header"];
parse_string( h, manufacturer, "manufacturer" );
parse_string( h, model, "model" );
parse_string( h, illuminant, "illuminant" );
parse_string( h, catalog_number, "catalog_number" );
parse_string( h, type, "type" );
parse_string( h, description, "description" );
parse_string( h, document_creator, "document_creator" );
parse_string( h, unique_identifier, "unique_identifier" );
Expand All @@ -227,6 +225,19 @@ bool SpectralData::load( const std::string &path, bool reshape )
parse_string( h, comments, "comments" );
parse_string( h, license, "license" );

// The schema version 1.0.0 replaces 'header/illuminant' with
// 'header/type' in the illuminant files. If both are present, the type
// takes precedence.
if ( type.empty() )
{
std::string schema_version;
parse_string( h, schema_version, "schema_version" );
if ( schema_version == "0.1.0" )
{
parse_string( h, type, "illuminant" );
}
}

nlohmann::json &d = file_data["spectral_data"];
parse_string( d, units, "units" );
parse_string( d, reflection_geometry, "reflection_geometry" );
Expand Down
6 changes: 3 additions & 3 deletions src/rawtoaces_util/image_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ bool prepare_transform_spectral(

if ( settings.verbosity > 0 )
{
std::cerr << "Found illuminant: '" << solver.illuminant.illuminant
<< "'." << std::endl;
std::cerr << "Found illuminant: '" << solver.illuminant.type << "'."
<< std::endl;
}
}
else
Expand Down Expand Up @@ -1180,7 +1180,7 @@ std::vector<std::string> ImageConverter::get_supported_illuminants() const
core::SpectralData data;
if ( data.load( file, false ) )
{
result.push_back( data.illuminant );
result.push_back( data.type );
}
}

Expand Down
30 changes: 15 additions & 15 deletions tests/testIDT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
void testIDT_LoadCameraSpst()
{
std::filesystem::path absolutePath =
std::filesystem::absolute( DATA_PATH "camera/arri_d21_380_780_5.json" );
std::filesystem::absolute( DATA_PATH "camera/ARRI_D21_380_780_5.json" );

rta::core::SpectralData camera;
bool result;

result = camera.load( absolutePath.string() );
OIIO_CHECK_ASSERT( result );
OIIO_CHECK_EQUAL( camera.manufacturer, "arri" );
OIIO_CHECK_EQUAL( camera.model, "d21" );
OIIO_CHECK_EQUAL( camera.manufacturer, "ARRI" );
OIIO_CHECK_EQUAL( camera.model, "D21" );
OIIO_CHECK_EQUAL( camera.data.size(), 1 );
OIIO_CHECK_EQUAL( camera.data.count( "main" ), 1 );
OIIO_CHECK_EQUAL( camera.data.at( "main" ).size(), 3 );
Expand Down Expand Up @@ -163,7 +163,7 @@ void testIDT_LoadIlluminant()
1.0000000000000
};

OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );

vector<double> &illumTestData = illuminant["power"].values;
Expand Down Expand Up @@ -746,7 +746,7 @@ void testIDT_scaleLSC()
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );

rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

scale_illuminant( camera, illuminant );

Expand Down Expand Up @@ -777,7 +777,7 @@ void testIDT_scaleLSC()
const vector<double> illumDataScaled = illuminant["power"].values;

OIIO_CHECK_EQUAL( illumDataScaled.size(), 81 );
OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );
for ( int i = 0; i < 81; i++ )
OIIO_CHECK_EQUAL_THRESH( illumDataScaled[i], scaledIllum[i], 1e-5 );
Expand All @@ -789,7 +789,7 @@ void testIDT_CalCM()
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );

rta::core::SpectralData camera;
load_file( "camera/arri_d21_380_780_5.json", camera );
load_file( "camera/ARRI_D21_380_780_5.json", camera );

vector<double> CM_test = calculate_CM( camera, illuminant );

Expand All @@ -805,7 +805,7 @@ void testIDT_CalWB()
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );

rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

vector<double> WB_test = _calculate_WB( camera, illuminant );

Expand All @@ -826,7 +826,7 @@ void testIDT_ChooseIllumSrc()
solver.find_illuminant( wbv );

const auto &best_illuminant = solver.illuminant;
string illumType_Test = best_illuminant.illuminant;
string illumType_Test = best_illuminant.type;
vector<double> illumData_Test = best_illuminant["power"].values;

double illumData[81] = {
Expand Down Expand Up @@ -864,7 +864,7 @@ void testIDT_ChooseIllumType()
solver.calculate_WB();

const auto &best_illuminant = solver.illuminant;
string illumType_Test = best_illuminant.illuminant;
string illumType_Test = best_illuminant.type;
vector<double> illumData_Test = best_illuminant["power"].values;

double illumData[81] = {
Expand All @@ -887,15 +887,15 @@ void testIDT_ChooseIllumType()
0.1365548815
};

OIIO_CHECK_EQUAL( illumType_Test, "iso7589" );
OIIO_CHECK_EQUAL( illumType_Test, "ISO7589" );
for ( size_t i = 0; i < illumData_Test.size(); i++ )
OIIO_CHECK_EQUAL_THRESH( illumData[i], illumData_Test[i], 1e-5 );
}

void testIDT_CalTI()
{
rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

rta::core::SpectralData illuminant;
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
Expand Down Expand Up @@ -4809,7 +4809,7 @@ void testIDT_CalTI()
void testIDT_CalXYZ()
{
rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

rta::core::SpectralData illuminant;
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
Expand Down Expand Up @@ -5024,7 +5024,7 @@ void testIDT_CalXYZ()
void testIDT_CalRGB()
{
rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

rta::core::SpectralData illuminant;
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
Expand Down Expand Up @@ -5239,7 +5239,7 @@ void testIDT_CalRGB()
void testIDT_CurveFit()
{
rta::core::SpectralData camera;
load_file( "camera/nikon_d200_380_780_5.json", camera );
load_file( "camera/Nikon_D200_380_780_5.json", camera );

rta::core::SpectralData illuminant;
load_file( "illuminant/iso7589_stutung_380_780_5.json", illuminant );
Expand Down
2 changes: 1 addition & 1 deletion tests/testIllum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void testIllum_readSPD()
1.0000000000000
};

OIIO_CHECK_EQUAL( illuminant.illuminant, "iso7589" );
OIIO_CHECK_EQUAL( illuminant.type, "ISO7589" );
OIIO_CHECK_EQUAL( illuminant["power"].shape.step, 5 );

vector<double> &illumTestData = illuminant["power"].values;
Expand Down
12 changes: 5 additions & 7 deletions tests/test_SpectralData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ void init_SpectralData( rta::core::SpectralData &data )
{
data.manufacturer = "manufacturer";
data.model = "model";
data.illuminant = "illuminant";
data.catalog_number = "catalog_number";
data.type = "type";
data.description = "description";
data.document_creator = "document_creator";
data.unique_identifier = "unique_identifier";
Expand Down Expand Up @@ -84,8 +83,7 @@ void check_SpectralData( const rta::core::SpectralData &data )
{
OIIO_CHECK_EQUAL( data.manufacturer, "manufacturer" );
OIIO_CHECK_EQUAL( data.model, "model" );
OIIO_CHECK_EQUAL( data.illuminant, "illuminant" );
OIIO_CHECK_EQUAL( data.catalog_number, "catalog_number" );
OIIO_CHECK_EQUAL( data.type, "type" );
OIIO_CHECK_EQUAL( data.description, "description" );
OIIO_CHECK_EQUAL( data.document_creator, "document_creator" );
OIIO_CHECK_EQUAL( data.unique_identifier, "unique_identifier" );
Expand Down Expand Up @@ -126,15 +124,15 @@ void testSpectralData_Properties()
void testSpectralData_LoadSpst()
{
std::filesystem::path absolutePath =
std::filesystem::absolute( DATA_PATH "camera/arri_d21_380_780_5.json" );
std::filesystem::absolute( DATA_PATH "camera/ARRI_D21_380_780_5.json" );

rta::core::SpectralData camera;
bool result;

result = camera.load( absolutePath.string() );
OIIO_CHECK_ASSERT( result );
OIIO_CHECK_EQUAL( camera.manufacturer, "arri" );
OIIO_CHECK_EQUAL( camera.model, "d21" );
OIIO_CHECK_EQUAL( camera.manufacturer, "ARRI" );
OIIO_CHECK_EQUAL( camera.model, "D21" );
OIIO_CHECK_EQUAL( camera.data.size(), 1 );
OIIO_CHECK_EQUAL( camera.data.count( "main" ), 1 );
OIIO_CHECK_EQUAL( camera.data.at( "main" ).size(), 3 );
Expand Down
Loading