From 52957e9eabc9c56c47e965cdfee0cfd6a4f38a02 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Wed, 17 Jan 2018 01:41:28 +0100 Subject: [PATCH] further experiments with histogram matching --- rtengine/histmatching.cc | 13 ++++++++++--- rtengine/rtthumbnail.cc | 11 ++++++++--- rtengine/rtthumbnail.h | 2 +- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/rtengine/histmatching.cc b/rtengine/histmatching.cc index a38ad4687..6d8856958 100644 --- a/rtengine/histmatching.cc +++ b/rtengine/histmatching.cc @@ -79,7 +79,7 @@ void mappingToCurve(const std::vector &mapping, std::vector &curve) { curve.clear(); - const int npoints = 20; + const int npoints = 8; int idx = 1; for (; idx < int(mapping.size()); ++idx) { if (mapping[idx] >= idx) { @@ -133,10 +133,17 @@ void RawImageSource::getAutoMatchedToneCurve(std::vector &outCurve) source.reset(thumb->quickProcessImage(neutral, rheight, TI_Nearest)); } std::unique_ptr target; - { + if (true) { + neutral.icm.working = "RT_sRGB"; + // faster, but has problems likely due to color space transformations that I do not properly understand... double scale; std::unique_ptr thumb(Thumbnail::loadFromRaw(getFileName(), rml, sensor_type, w, h, 1, 0.0, false)); - target.reset(thumb->processImage(neutral, sensor_type, rheight, TI_Nearest, getMetaData(), scale)); + target.reset(thumb->processImage(neutral, sensor_type, rheight, TI_Nearest, getMetaData(), scale, false)); + } else { + ProcessingJob *job = ProcessingJob::create(this, neutral, true); + int err = 0; + std::unique_ptr tmp(processImage(job, err, nullptr, false)); + target.reset(static_cast(tmp.get())->to8()); } if (target->getWidth() != source->getWidth() || target->getHeight() != source->getHeight()) { Image8 *tmp = new Image8(source->getWidth(), source->getHeight()); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index e84214bd4..59d19cc15 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -915,7 +915,7 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int } // Full thumbnail processing, second stage if complete profile exists -IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& myscale) +IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& myscale, bool forMonitor) { unsigned int imgNum = 0; if (isRaw) { @@ -1293,8 +1293,13 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, eSensorT //ipf.colorCurve (labView, labView); // obtain final image - Image8* readyImg = new Image8 (fw, fh); - ipf.lab2monitorRgb (labView, readyImg); + Image8* readyImg = nullptr; + if (forMonitor) { + readyImg = new Image8 (fw, fh); + ipf.lab2monitorRgb (labView, readyImg); + } else { + readyImg = ipf.lab2rgb(labView, 0, 0, fw, fh, params.icm); + } delete labView; delete baseImg; diff --git a/rtengine/rtthumbnail.h b/rtengine/rtthumbnail.h index 2ee08de50..902f264fc 100644 --- a/rtengine/rtthumbnail.h +++ b/rtengine/rtthumbnail.h @@ -71,7 +71,7 @@ public: void init (); - IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale); + IImage8* processImage (const procparams::ProcParams& pparams, eSensorType sensorType, int rheight, TypeInterpolation interp, const FramesMetaData *metadata, double& scale, bool forMonitor=true); IImage8* quickProcessImage (const procparams::ProcParams& pparams, int rheight, TypeInterpolation interp); int getImageWidth (const procparams::ProcParams& pparams, int rheight, float &ratio); void getDimensions (int& w, int& h, double& scaleFac);