Skip to content

Commit 14d595c

Browse files
Add exif reading of LinearResponseLimit
The electronic circuit of a camera and/or the sensor might not work in a linear/correct way above certain values. This information might be provided in vendor-tags or `Exif.Image.LinearResponseLimit`. We can't make use of that info in modules like temperature or demosaic as there is no generic correction algorithm but highlights reconstruction could use it as a threshold. The single float value is now available in dt_image_t defaulting to 1.0 if there is no exif tag.
1 parent c098ad5 commit 14d595c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/common/exif.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,25 @@ static bool _check_usercrop(Exiv2::ExifData &exifData,
858858
return FALSE;
859859
}
860860

861+
static void _check_linear_response_limit(Exiv2::ExifData &exifData,
862+
dt_image_t *img)
863+
{
864+
bool found_one = false;
865+
866+
Exiv2::ExifData::const_iterator linr =
867+
exifData.findKey(Exiv2::ExifKey("Exif.Image.LinearResponseLimit"));
868+
if(linr != exifData.end() && linr->count() == 1)
869+
{
870+
img->linear_response_limit = linr->toFloat();
871+
found_one = true;
872+
}
873+
874+
// currently this only reads the dng tag, could also be used for other raws
875+
if(found_one)
876+
dt_print(DT_DEBUG_IMAGEIO, "[exif] `%s` has LinearResponseLimit %.4f",
877+
img->filename, img->linear_response_limit);
878+
}
879+
861880
static gboolean _check_dng_opcodes(Exiv2::ExifData &exifData,
862881
dt_image_t *img)
863882
{
@@ -1074,13 +1093,14 @@ void dt_exif_img_check_additional_tags(dt_image_t *img,
10741093
_check_usercrop(exifData, img);
10751094
_check_dng_opcodes(exifData, img);
10761095
_check_lens_correction_data(exifData, img);
1096+
_check_linear_response_limit(exifData, img);
10771097
}
10781098
return;
10791099
}
10801100
catch(Exiv2::AnyError &e)
10811101
{
10821102
const char *errstring = e.what();
1083-
dt_print(DT_DEBUG_IMAGEIO, "[exiv2 reading DefaultUserCrop] %s: %s", filename, errstring);
1103+
dt_print(DT_DEBUG_IMAGEIO, "[exiv2 reading additional exif tags] %s: %s", filename, errstring);
10841104
return;
10851105
}
10861106
}

src/common/image.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,7 @@ void dt_image_init(dt_image_t *img)
21322132
img->colorspace = DT_IMAGE_COLORSPACE_NONE;
21332133
img->fuji_rotation_pos = 0;
21342134
img->pixel_aspect_ratio = 1.0f;
2135+
img->linear_response_limit = 1.0f;
21352136
img->wb_coeffs[0] = NAN;
21362137
img->wb_coeffs[1] = NAN;
21372138
img->wb_coeffs[2] = NAN;

src/common/image.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,9 @@ typedef struct dt_image_t
336336
uint32_t fuji_rotation_pos;
337337
float pixel_aspect_ratio;
338338

339+
/* might help to improve highlights reconstruction module */
340+
float linear_response_limit;
341+
339342
/* White balance coeffs from the raw */
340343
dt_aligned_pixel_t wb_coeffs;
341344

0 commit comments

Comments
 (0)