Skip to content

Commit 2337c1e

Browse files
Your Nameclaude
andcommitted
fix(exposure): convert colorspace on all read paths and guard EV metadata
Address review feedback: - fileIO loadImage: move colorconvert out of the branch chain so the missing and invalid EVComp paths also return the image in the requested colorspace, instead of leaking a LINEAR image to the cache. - main_prepareDenseScene: guard the EV computation as well, so a missing-exposure -1 sentinel no longer writes NaN (log2 of a negative) into AliceVision:EV. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5ec5d75 commit 2337c1e

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/aliceVision/mvsUtils/fileIO.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ void loadImage(const std::string& path, const MultiViewParams& mp, int camId, Im
438438
img(i)[1] *= exposureCompensation;
439439
img(i)[2] *= exposureCompensation;
440440
}
441-
442-
imageAlgo::colorconvert(img, image::EImageColorSpace::LINEAR, colorspace);
443441
}
442+
443+
imageAlgo::colorconvert(img, image::EImageColorSpace::LINEAR, colorspace);
444444
}
445445

446446
// scale chosen by the user and apply during the process

src/software/pipeline/main_prepareDenseScene.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ bool prepareDenseScene(const SfMData& sfmData,
244244

245245
// add exposure values to images metadata
246246
const double cameraExposure = view->getImage().getCameraExposureSetting().getExposure();
247-
const double ev = std::log2(1.0 / cameraExposure);
248-
// only a strictly positive median and camera exposure give a meaningful factor; otherwise getExposure()
249-
// returned the -1 sentinel (missing metadata) and dividing would write a degenerate (-inf) EVComp
247+
// getExposure() returns the -1 sentinel when metadata is missing; guard both derived values so we never
248+
// write a degenerate EV (log2 of a negative -> NaN) or EVComp (division -> -inf) into the image metadata
249+
const double ev = (cameraExposure > 0.0) ? std::log2(1.0 / cameraExposure) : 0.0;
250250
const float exposureCompensation =
251251
(medianCameraExposure > 0.0 && cameraExposure > 0.0) ? float(medianCameraExposure / cameraExposure) : 1.0f;
252252
metadata.push_back(oiio::ParamValue("AliceVision:EV", float(ev)));

0 commit comments

Comments
 (0)