Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fujifilm RAW Exposure Bias #198

Closed
wants to merge 1 commit into from
Closed
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
3 changes: 3 additions & 0 deletions src/librawspeed/common/RawImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class ImageMetaData {
// corners are when the image is rotated 45 degrees in Fuji rotated sensors.
uint32 fujiRotationPos;

// Fuji RAW exposure offset compared to camera-produced JPEGs.
float fujiExposureBias;

iPoint2D subsampling;
std::string make;
std::string model;
Expand Down
9 changes: 9 additions & 0 deletions src/librawspeed/decoders/RafDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

namespace rawspeed {

const float BASE_RAW_EXPOSURE_BIAS = -0.72;

bool RafDecoder::isRAF(const Buffer* input) {
static const std::array<char, 16> magic = {{'F', 'U', 'J', 'I', 'F', 'I', 'L',
'M', 'C', 'C', 'D', '-', 'R', 'A',
Expand Down Expand Up @@ -304,6 +306,13 @@ void RafDecoder::decodeMetaDataInternal(const CameraMetaData* meta) {
mRaw->metadata.make = id.make;
mRaw->metadata.model = id.model;

if (mRootIFD->hasEntryRecursive(FUJI_RAW_EXPOSURE_BIAS)) {
auto ratio = mRootIFD->getEntryRecursive(FUJI_RAW_EXPOSURE_BIAS);
auto actual_bias = static_cast<float>(ratio->getI16(0)) / ratio->getI16(1);

mRaw->metadata.fujiExposureBias = actual_bias - BASE_RAW_EXPOSURE_BIAS;
}

if (mRootIFD->hasEntryRecursive(FUJI_WB_GRBLEVELS)) {
TiffEntry *wb = mRootIFD->getEntryRecursive(FUJI_WB_GRBLEVELS);
if (wb->count == 3) {
Expand Down
1 change: 1 addition & 0 deletions src/librawspeed/tiff/TiffTag.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ enum TiffTag {
FUJI_STRIPBYTECOUNTS = 0xF008,
FUJI_BLACKLEVEL = 0xF00A,
FUJI_WB_GRBLEVELS = 0xF00E,
FUJI_RAW_EXPOSURE_BIAS = 0x9650,

KODAK_IFD = 0x8290,
KODAK_LINEARIZATION = 0x090D,
Expand Down
1 change: 1 addition & 0 deletions src/utilities/identify/rawspeed-identify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ int main(int argc, char* argv[]) { // NOLINT
fprintf(stdout, "cropOffset: %dx%d\n", cropTL.x, cropTL.y);

fprintf(stdout, "fuji_rotation_pos: %d\n", r->metadata.fujiRotationPos);
fprintf(stdout, "fuji_exposure_bias: %f\n", r->metadata.fujiExposureBias);
fprintf(stdout, "pixel_aspect_ratio: %f\n", r->metadata.pixelAspectRatio);

double sum = 0.0F;
Expand Down
1 change: 1 addition & 0 deletions src/utilities/rstest/rstest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ string img_hash(const RawImage& r) {
APPEND(&oss, "\n");

APPEND(&oss, "fuji_rotation_pos: %d\n", r->metadata.fujiRotationPos);
APPEND(&oss, "fuji_exposure_bias: %f\n", r->metadata.fujiExposureBias);
APPEND(&oss, "pixel_aspect_ratio: %f\n", r->metadata.pixelAspectRatio);

APPEND(&oss, "badPixelPositions: ");
Expand Down