feature: added option to use a (fast) neutral RAW rendering in 'inspector mode'
This commit is contained in:
@@ -36,7 +36,10 @@
|
||||
#include "jpeg.h"
|
||||
#include "../rtgui/ppversion.h"
|
||||
#include "improccoordinator.h"
|
||||
#include "settings.h"
|
||||
#include <locale.h>
|
||||
#include "StopWatch.h"
|
||||
#include "median.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -147,6 +150,8 @@ extern Options options;
|
||||
namespace rtengine
|
||||
{
|
||||
|
||||
extern const Settings *settings;
|
||||
|
||||
using namespace procparams;
|
||||
|
||||
Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, int fixwh, double wbEq, bool inspectorMode)
|
||||
@@ -261,13 +266,92 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h,
|
||||
return tpp;
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
Image8 *load_inspector_mode(const Glib::ustring &fname, RawMetaDataLocation &rml, eSensorType &sensorType, int &w, int &h)
|
||||
{
|
||||
BENCHFUN
|
||||
|
||||
RawImageSource src;
|
||||
int err = src.load(fname, true);
|
||||
if (err) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
src.getFullSize(w, h);
|
||||
sensorType = src.getSensorType();
|
||||
|
||||
ProcParams neutral;
|
||||
neutral.raw.bayersensor.method = RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::FAST);
|
||||
neutral.raw.xtranssensor.method = RAWParams::XTransSensor::getMethodString(RAWParams::XTransSensor::Method::FAST);
|
||||
neutral.icm.input = "(camera)";
|
||||
neutral.icm.working = "RT_sRGB";
|
||||
|
||||
src.preprocess(neutral.raw, neutral.lensProf, neutral.coarse, false);
|
||||
src.demosaic(neutral.raw);
|
||||
|
||||
PreviewProps pp(0, 0, w, h, 1);
|
||||
|
||||
Imagefloat tmp(w, h);
|
||||
src.getImage(src.getWB(), TR_NONE, &tmp, pp, neutral.toneCurve, neutral.raw);
|
||||
src.convertColorSpace(&tmp, neutral.icm, src.getWB());
|
||||
|
||||
Image8 *img = new Image8(w, h);
|
||||
const float f = 255.f/65535.f;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for (int y = 0; y < h; ++y) {
|
||||
for (int x = 0; x < w; ++x) {
|
||||
float r = tmp.r(y, x);
|
||||
float g = tmp.g(y, x);
|
||||
float b = tmp.b(y, x);
|
||||
// avoid magenta highlights
|
||||
if (r > MAXVALF && b > MAXVALF) {
|
||||
float v = CLIP((r + g + b) / 3.f) * f;
|
||||
img->r(y, x) = img->g(y, x) = img->b(y, x) = v;
|
||||
} else {
|
||||
img->r(y, x) = Color::gamma_srgbclipped(r) * f;
|
||||
img->g(y, x) = Color::gamma_srgbclipped(g) * f;
|
||||
img->b(y, x) = Color::gamma_srgbclipped(b) * f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataLocation& rml, eSensorType &sensorType, int &w, int &h, int fixwh, bool rotate, bool inspectorMode)
|
||||
{
|
||||
Thumbnail* tpp = new Thumbnail ();
|
||||
tpp->isRaw = 1;
|
||||
memset (tpp->colorMatrix, 0, sizeof (tpp->colorMatrix));
|
||||
tpp->colorMatrix[0][0] = 1.0;
|
||||
tpp->colorMatrix[1][1] = 1.0;
|
||||
tpp->colorMatrix[2][2] = 1.0;
|
||||
|
||||
if (inspectorMode && !forHistogramMatching && settings->thumbnail_inspector_mode == Settings::ThumbnailInspectorMode::RAW) {
|
||||
Image8 *img = load_inspector_mode(fname, rml, sensorType, w, h);
|
||||
if (!img) {
|
||||
delete tpp;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tpp->scale = 1.;
|
||||
tpp->thumbImg = img;
|
||||
|
||||
return tpp;
|
||||
}
|
||||
|
||||
RawImage *ri = new RawImage (fname);
|
||||
unsigned int imageNum = 0;
|
||||
int r = ri->loadRaw (false, imageNum, false);
|
||||
|
||||
if ( r ) {
|
||||
delete tpp;
|
||||
delete ri;
|
||||
sensorType = ST_NONE;
|
||||
return nullptr;
|
||||
@@ -301,24 +385,33 @@ Thumbnail* Thumbnail::loadQuickFromRaw (const Glib::ustring& fname, RawMetaDataL
|
||||
// did we succeed?
|
||||
if ( err ) {
|
||||
printf ("Could not extract thumb from %s\n", fname.data());
|
||||
delete tpp;
|
||||
delete img;
|
||||
delete ri;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Thumbnail* tpp = new Thumbnail ();
|
||||
|
||||
tpp->isRaw = 1;
|
||||
memset (tpp->colorMatrix, 0, sizeof (tpp->colorMatrix));
|
||||
tpp->colorMatrix[0][0] = 1.0;
|
||||
tpp->colorMatrix[1][1] = 1.0;
|
||||
tpp->colorMatrix[2][2] = 1.0;
|
||||
|
||||
if (inspectorMode) {
|
||||
// Special case, meaning that we want a full sized thumbnail image (e.g. for the Inspector feature)
|
||||
w = img->getWidth();
|
||||
h = img->getHeight();
|
||||
tpp->scale = 1.;
|
||||
|
||||
if (!forHistogramMatching && settings->thumbnail_inspector_mode == Settings::ThumbnailInspectorMode::RAW_IF_NOT_JPEG_FULLSIZE && float(std::max(w, h))/float(std::max(ri->get_width(), ri->get_height())) < 0.9f) {
|
||||
delete img;
|
||||
delete ri;
|
||||
|
||||
img = load_inspector_mode(fname, rml, sensorType, w, h);
|
||||
if (!img) {
|
||||
delete tpp;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
tpp->scale = 1.;
|
||||
tpp->thumbImg = img;
|
||||
|
||||
return tpp;
|
||||
}
|
||||
} else {
|
||||
if (fixwh == 1) {
|
||||
w = h * img->getWidth() / img->getHeight();
|
||||
|
Reference in New Issue
Block a user