further experiments with histogram matching

This commit is contained in:
Alberto Griggio 2018-01-17 01:41:28 +01:00
parent bb56d73cc8
commit 52957e9eab
3 changed files with 19 additions and 7 deletions

View File

@ -79,7 +79,7 @@ void mappingToCurve(const std::vector<int> &mapping, std::vector<double> &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<double> &outCurve)
source.reset(thumb->quickProcessImage(neutral, rheight, TI_Nearest));
}
std::unique_ptr<IImage8> 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<Thumbnail> 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<IImagefloat> tmp(processImage(job, err, nullptr, false));
target.reset(static_cast<Imagefloat *>(tmp.get())->to8());
}
if (target->getWidth() != source->getWidth() || target->getHeight() != source->getHeight()) {
Image8 *tmp = new Image8(source->getWidth(), source->getHeight());

View File

@ -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;

View File

@ -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);