Skip to content

Commit 88a5f9b

Browse files
committed
Add data-dir argument and auto matrix method
- Added --data-dir argument (Fixes #180) - Added auto matrix method (Fixes #181) Signed-off-by: Mikael Sundell <[email protected]>
1 parent c2a61d2 commit 88a5f9b

File tree

7 files changed

+252
-49
lines changed

7 files changed

+252
-49
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ A help message with a description of all command line options can be obtained by
163163
- "custom" uses the custom white balancing coefficients provided using the -"custom-wb" parameter.
164164

165165
Rawtoaces supports the following methods of color matrix computation:
166+
- "auto" (recommended) first tries the "spectral" method if spectral sensitivity data for the camera is available. If not, it falls back to "metadata". This avoids failures when spectral data is missing while still using the most accurate method when possible.
166167
- "spectral" uses the camera sensor's spectral sensitivity data to compute the optimal matrix. This mode requires spectral sensitivity data for the camera model the image comes from. The list of cameras such data is available for, can be seen using the "--list-cameras" parameter.
167168
- "metadata" uses the matrix (matrices) contained in the raw image file metadata. This mode works best with the images using the DNG format, as the DNG standard mandates the presense of such matrices.
168169
- "Adobe" uses the Adobe coefficients provided by LibRaw.
@@ -179,7 +180,7 @@ A help message with a description of all command line options can be obtained by
179180
--help Print help message
180181
--version Print version and exit
181182
--wb-method STR White balance method. Supported options: metadata, illuminant, box, custom. (default: metadata)
182-
--mat-method STR IDT matrix calculation method. Supported options: spectral, metadata, Adobe, custom. (default: spectral)
183+
--mat-method STR IDT matrix calculation method. Supported options: auto, spectral, metadata, Adobe, custom. (default: auto)
183184
--illuminant STR Illuminant for white balancing. (default = D55)
184185
--wb-box X Y W H Box to use for white balancing. (default = (0,0,0,0) - full image)
185186
--custom-wb R G B G Custom white balance multipliers.
@@ -191,6 +192,7 @@ A help message with a description of all command line options can be obtained by
191192
--scale VAL Additional scaling factor to apply to the pixel values. (default: 1)
192193
General options:
193194
--overwrite Allows overwriting existing files. If not set, trying to write to an existing file will generate an error.
195+
--data-dir STR Directory containing rawtoaces spectral sensitivity and illuminant data files. Overrides the default search path and the RAWTOACES_DATA_PATH environment variable.
194196
--output-dir STR The directory to write the output files to. This gets applied to every input directory, so it is better to be used with a single input directory.
195197
--create-dirs Create output directories if they don't exist.
196198
--disable-cache Disable the colour space transform cache.
@@ -270,7 +272,7 @@ If spectral sensitivity data for your camera is included with `rawtoaces` then t
270272

271273
This command is equivalent to :
272274

273-
$ rawtoaces --wb-method metadata --mat-method spectral input.raw
275+
$ rawtoaces --wb-method metadata --mat-method auto input.raw
274276

275277
To process mutiple raw files, you can try:
276278

include/rawtoaces/image_converter.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class ImageConverter
5252

5353
enum class MatrixMethod
5454
{
55+
/// Automatically choose the best available matrix method.
56+
/// - If spectral sensitivity data for the camera is available,
57+
/// use `Spectral`.
58+
/// - Otherwise, fall back to `Metadata`.
59+
Auto,
5560
/// Use the camera spectral sensitivity curves to solve for the colour
5661
/// conversion matrix. In this mode the illuminant is either provided
5762
/// directly in `illuminant` if `WB_method` ==
@@ -67,7 +72,7 @@ class ImageConverter
6772
/// Specify a custom matrix in `colourMatrix`. This mode is useful if
6873
/// the matrix is calculated by an external tool.
6974
Custom
70-
} matrix_method = MatrixMethod::Spectral;
75+
} matrix_method = MatrixMethod::Auto;
7176

7277
/// Cropping mode.
7378
enum class CropMode

src/rawtoaces/main.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,33 @@ int main( int argc, const char *argv[] )
4040
std::vector<std::vector<std::string>> batches =
4141
rta::util::collect_image_files( files );
4242

43-
// Process raw files ...
43+
// Process raw files
4444
bool empty = true;
4545
bool result = true;
46+
47+
size_t file_index = 0;
48+
size_t total_files = 0;
49+
50+
for ( auto const &batch: batches )
51+
total_files += batch.size();
52+
4653
for ( auto const &batch: batches )
4754
{
4855
for ( auto const &input_filename: batch )
4956
{
57+
++file_index;
58+
std::cout << "[" << file_index << "/" << total_files
59+
<< "] Processing file: " << input_filename << std::endl;
60+
5061
empty = false;
5162
result = converter.process_image( input_filename );
5263
if ( !result )
64+
{
65+
std::cerr << "Failed on file [" << file_index << "/"
66+
<< total_files << "]: " << input_filename
67+
<< std::endl;
5368
break;
69+
}
5470
}
5571
if ( !result )
5672
break;

src/rawtoaces_core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ install( TARGETS ${RAWTOACES_CORE_LIB}
5858
LIBRARY DESTINATION ${INSTALL_LIB_DIR}
5959
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
6060
PUBLIC_HEADER DESTINATION include/rawtoaces
61-
)
61+
)

src/rawtoaces_core/rawtoaces_core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,4 +1247,4 @@ bool IDTOptimizationCost::operator()( const T *beta_params, T *residuals ) const
12471247
}
12481248

12491249
} // namespace core
1250-
} // namespace rta
1250+
} // namespace rta

0 commit comments

Comments
 (0)