Skip to content

Commit c9b54c2

Browse files
authored
cleanup public interfaces (#173)
* cleanup public interfaces Signed-off-by: Anton Dukhovnikov <[email protected]>
1 parent 5f3b5bc commit c9b54c2

28 files changed

+173
-114
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
run: >
173173
cmake
174174
-B build_config_test
175-
-S ./unittest/config_tests
175+
-S ./tests/config_tests
176176
-D RAWTOACES_DIR=${{ github.workspace }}/install/lib/cmake/RAWTOACES
177177
-D CMAKE_CXX_STANDARD=${{matrix.cxx_std}}
178178
@@ -262,7 +262,7 @@ jobs:
262262
run: >
263263
cmake
264264
-B build_config_test
265-
-S ${{ github.workspace }}/unittest/config_tests
265+
-S ${{ github.workspace }}/tests/config_tests
266266
-D RAWTOACES_DIR=${{ github.workspace }}/install/lib/cmake/RAWTOACES
267267
-D CMAKE_TOOLCHAIN_FILE="${{ matrix.toolchain_file }}"
268268
-D CMAKE_CXX_STANDARD=17

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ add_subdirectory("src/${RAWTOACES_UTIL_LIB}")
8282
add_subdirectory("src/rawtoaces")
8383

8484
enable_testing()
85-
add_subdirectory(unittest)
85+
add_subdirectory(tests)
8686

8787
#################################################
8888
##

include/rawtoaces/acesrender.h renamed to include/rawtoaces/image_converter.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ namespace rta
1111
namespace util
1212
{
1313

14-
void create_key( std::unordered_map<std::string, char> &keys );
15-
1614
/// Collect all files from a given`path` into batchs. If the `path` is a
1715
/// directory, create an entry in `batches` and fill it with the file names
1816
/// from that directory. If the `path` is a file, add its name to the first
@@ -27,18 +25,6 @@ bool collect_image_files(
2725
class ImageConverter
2826
{
2927
public:
30-
// TODO:
31-
// Removed options comparing to v1.1:
32-
// -P - bad pixels
33-
// -K - dark frame
34-
// -j - fuji-rotate
35-
// -m - median filter
36-
// -f - four-colour RGB
37-
// -T - print Libraw-supported cameras
38-
// -F - use big file
39-
// -E - mmap-ed IO
40-
// -s - image index in the file
41-
// -G - green_matching() filter
4228
struct Settings
4329
{
4430
/// The white balancing method to use for conversion can be specified
@@ -92,7 +78,7 @@ class ImageConverter
9278
Soft,
9379
/// Write out only the crop area.
9480
Hard
95-
} crop_mode = CropMode::Soft;
81+
} crop_mode = CropMode::Hard;
9682

9783
/// An illuminant to use for white balancing and/or colour matrix
9884
/// calculation. Only used when `wbMethod` ==
@@ -137,8 +123,6 @@ class ImageConverter
137123

138124
} settings;
139125

140-
static void usage( const char *prog );
141-
142126
/// Initialise the parser object with all the command line parameters
143127
/// used by this tool. The method also sets the help and usage strings.
144128
/// The parser object can be amended by the calling code afterwards if

include/rawtoaces/rawtoaces_core.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ namespace rta
1010
namespace core
1111
{
1212

13+
// clang-format off
14+
15+
static const std::vector<std::vector<double>> XYZ_to_ACES = {
16+
{ 1.0498110175, 0.0000000000, -0.0000974845 },
17+
{ -0.4959030231, 1.3733130458, 0.0982400361 },
18+
{ 0.0000000000, 0.0000000000, 0.9912520182 }
19+
};
20+
21+
/// Colour adaptation from D65 to the ACES white point
22+
static const std::vector<std::vector<double> > CAT_D65_to_ACES = {
23+
{ 1.0097583639200136, 0.0050178093846550455, -0.015058389092388141 },
24+
{ 0.0036602813378778347, 1.0030138169214682, -0.0059802329456399824 },
25+
{ -0.00029980928869024906, -0.0010516909063249997, 0.92820279627476576 }
26+
};
27+
28+
// clang-format on
29+
1330
/// Calculate spectral power distribution of a daylight illuminant of given CCT
1431
/// - parameter cct: correlated colour temperature of the requested illuminant.
1532
/// - parameter spectrum: a reference to a `Spectrum` object to full with the

src/rawtoaces/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright Contributors to the rawtoaces Project.
33

4-
#include <rawtoaces/acesrender.h>
4+
#include <rawtoaces/image_converter.h>
55

66
#include <set>
77

src/rawtoaces_core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.12)
22
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}" )
33

44
set( CORE_PUBLIC_HEADER
5-
../../include/rawtoaces/define.h
6-
../../include/rawtoaces/mathOps.h
75
../../include/rawtoaces/rawtoaces_core.h
86
../../include/rawtoaces/spectral_data.h
97
)
@@ -15,6 +13,8 @@ add_library( ${RAWTOACES_CORE_LIB} ${DO_SHARED}
1513
# Make the headers visible in IDEs. This should not affect the builds.
1614
${CORE_PUBLIC_HEADER}
1715
rawtoaces_core_priv.h
16+
define.h
17+
mathOps.h
1818
)
1919

2020
target_link_libraries(

include/rawtoaces/define.h renamed to src/rawtoaces_core/define.h

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,6 @@ static const double d50 [3] = {0.9642, 1.0000, 0.8250};
7272
static const double d60 [3] = {0.952646074569846, 1.0000, 1.00882518435159};
7373
static const double d65 [3] = {0.9547, 1.0000, 1.0883};
7474

75-
static const std::vector<double> ACES_white_XYZ = {
76-
0.952646074569846, 1.0, 1.00882518435159
77-
};
78-
79-
static const std::vector<double> D65_white_XYZ = {
80-
0.9547, 1.0000, 1.0883
81-
};
82-
8375
static const double neutral3[3][3] = {
8476
{1.0, 0.0, 0.0},
8577
{0.0, 1.0, 0.0},
@@ -166,13 +158,6 @@ static const double XYZ_acesrgb_3[3][3] = {
166158
{ 0.0000000000, 0.0000000000, 0.9912520182 }
167159
};
168160

169-
170-
static const std::vector<std::vector<double>> XYZ_to_ACES = {
171-
{ 1.0498110175, 0.0000000000, -0.0000974845 },
172-
{ -0.4959030231, 1.3733130458, 0.0982400361 },
173-
{ 0.0000000000, 0.0000000000, 0.9912520182 }
174-
};
175-
176161
static const double XYZ_acesrgb_4[4][4] = {
177162
{ 1.0498110175, 0.0000000000, -0.0000974845, 0.0 },
178163
{ -0.4959030231, 1.3733130458, 0.0982400361, 0.0 },
@@ -243,13 +228,19 @@ static const double bradford[3][3] = {
243228
{ 0.0389, -0.0685, 1.0296}
244229
};
245230

246-
// Color Adaptation Matrices - Cat02 (default)
247-
static const double cat02[3][3] = {
231+
// Color Adaptation Matrices - CAT02 (default)
232+
static const std::vector<std::vector<double>> CAT02 = {
248233
{ 0.7328, 0.4296, -0.1624 },
249234
{ -0.7036, 1.6975, 0.0061 },
250235
{ 0.0030, 0.0136, 0.9834 }
251236
};
252237

238+
static const std::vector<std::vector<double>> CAT02_inv = {
239+
{ 1.0961238208355142, -0.27886900021828726, 0.18274517938277304 },
240+
{ 0.45436904197535921, 0.47353315430741177, 0.072097803717229125 },
241+
{ -0.0096276087384293551, -0.0056980312161134198, 1.0153256399545427 }
242+
};
243+
253244
// clang-format on
254245

255246
// Function to Open Directories

include/rawtoaces/mathOps.h renamed to src/rawtoaces_core/mathOps.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifndef _MATHOPS_h__
55
#define _MATHOPS_h__
66

7-
#include <rawtoaces/define.h>
7+
#include "define.h"
88

99
#include <cfloat>
1010

@@ -520,24 +520,22 @@ template <typename T> vector<T> XYZTouv( const vector<T> &XYZ )
520520
};
521521

522522
template <typename T>
523-
vector<vector<T>> getCAT( const vector<T> &src, const vector<T> &des )
523+
std::vector<std::vector<T>> calculate_CAT(
524+
const std::vector<T> &src_white_XYZ, const std::vector<T> &dst_white_XYZ )
524525
{
525-
assert( src.size() == des.size() );
526+
assert( src_white_XYZ.size() == 3 );
527+
assert( dst_white_XYZ.size() == 3 );
526528

527-
vector<vector<T>> vcat( 3, vector<T>( 3 ) );
528-
// cat02 or bradford
529-
FORIJ( 3, 3 ) vcat[i][j] = cat02[i][j];
529+
std::vector<double> src_white_LMS = mulVector( src_white_XYZ, CAT02 );
530+
std::vector<double> dst_white_LMS = mulVector( dst_white_XYZ, CAT02 );
530531

531-
vector<T> wSRC = mulVector( src, vcat );
532-
vector<T> wDES = mulVector( des, vcat );
533-
vector<vector<T>> vkm =
534-
solveVM( vcat, diagVM( divVectorElement( wDES, wSRC ) ) );
535-
vkm = mulVector( vkm, transposeVec( vcat ) );
532+
std::vector<std::vector<double>> mat( 3, std::vector<double>( 3, 0 ) );
533+
for ( size_t i = 0; i < 3; i++ )
534+
mat[i][i] = dst_white_LMS[i] / src_white_LMS[i];
536535

537-
clearVM( wSRC );
538-
clearVM( wDES );
539-
540-
return vkm;
536+
mat = mulVector( mat, transposeVec( CAT02 ) );
537+
mat = mulVector( CAT02_inv, transposeVec( mat ) );
538+
return mat;
541539
}
542540

543541
template <typename T> vector<vector<T>> XYZtoLAB( const vector<vector<T>> &XYZ )

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
#include <rawtoaces/rawtoaces_core.h>
55
#include "rawtoaces_core_priv.h"
6-
#include <rawtoaces/mathOps.h>
7-
#include <rawtoaces/define.h> // for cmp_str
6+
#include "mathOps.h"
7+
#include "define.h"
88

99
using namespace ceres;
1010

@@ -575,7 +575,7 @@ std::vector<std::vector<double>> calXYZ(
575575
ww[1] = 1.0;
576576
ww[2] = ( cmf_z * illum ).integrate() / y;
577577

578-
XYZ = mulVector( XYZ, getCAT( ww, w ) );
578+
XYZ = mulVector( XYZ, calculate_CAT( ww, w ) );
579579

580580
return XYZ;
581581
}
@@ -1061,7 +1061,7 @@ vector<vector<double>> MetadataSolver::calculate_CAT_matrix()
10611061
vector<double> outputXYZWhitePoint =
10621062
mulVector( outputRGBtoXYZMtx, deviceWhiteV );
10631063
vector<vector<double>> chadMtx =
1064-
getCAT( camera_XYZ_white_point, outputXYZWhitePoint );
1064+
calculate_CAT( camera_XYZ_white_point, outputXYZWhitePoint );
10651065

10661066
return chadMtx;
10671067
}

src/rawtoaces_util/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.12)
22
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}" )
33

44
set( UTIL_PUBLIC_HEADER
5-
../../include/rawtoaces/acesrender.h
5+
../../include/rawtoaces/image_converter.h
66
../../include/rawtoaces/usage_timer.h
77
)
88

99
add_library ( ${RAWTOACES_UTIL_LIB} ${DO_SHARED}
10-
acesrender.cpp
10+
image_converter.cpp
1111
usage_timer.cpp
1212

1313
# Make the headers visible in IDEs. This should not affect the builds.
@@ -18,10 +18,6 @@ target_link_libraries ( ${RAWTOACES_UTIL_LIB}
1818
PUBLIC
1919
${RAWTOACES_CORE_LIB}
2020
OpenImageIO::OpenImageIO
21-
# INTERFACE
22-
# Eigen3::Eigen
23-
# Imath::Imath
24-
# Imath::ImathConfig
2521
)
2622

2723
target_compile_definitions( rawtoaces_util PRIVATE RAWTOACES_VERSION="${RAWTOACES_VERSION}" )

0 commit comments

Comments
 (0)