Linked red and blue exponent adjuster to the green adjuster, in order to maintain the ratio between exponents if the user moves the green adjuster (master).

Switched back to vector sort for median calculations: the results of the histogram search function diverge more and more from the simple median calculation as the exponents increase.
At 2.0 the test picture is already impossible to WB as the multipliers are too far off (2.78226e+08 histo vs 9.7927e+11 sort), and the normal WB sliders can't compensate for those huge factors.
This commit is contained in:
rom9 2019-06-10 22:05:54 +02:00
parent 91565728e5
commit b95bdb1aea
3 changed files with 36 additions and 15 deletions

View File

@ -104,8 +104,8 @@ bool RawImageSource::getFilmNegativeExponents (Coord2D spotA, Coord2D spotB, int
std::swap(clearVals, denseVals); std::swap(clearVals, denseVals);
if (settings->verbose) { if (settings->verbose) {
printf("Clear film values: R=%f G=%f B=%f\n", clearVals[0], clearVals[1], clearVals[2]); printf("Clear film values: R=%g G=%g B=%g\n", clearVals[0], clearVals[1], clearVals[2]);
printf("Dense film values: R=%f G=%f B=%f\n", denseVals[0], denseVals[1], denseVals[2]); printf("Dense film values: R=%g G=%g B=%g\n", denseVals[0], denseVals[1], denseVals[2]);
} }
float denseGreenRatio = clearVals[1] / denseVals[1]; float denseGreenRatio = clearVals[1] / denseVals[1];
@ -119,7 +119,7 @@ bool RawImageSource::getFilmNegativeExponents (Coord2D spotA, Coord2D spotB, int
newExps[ch] = CLAMP(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 3.f); newExps[ch] = CLAMP(logBase(clearVals[ch] / denseVals[ch], denseGreenRatio), 0.3f, 3.f);
if (settings->verbose) if (settings->verbose)
printf("New exponents: R=%f G=%f B=%f\n", newExps[0], newExps[1], newExps[2]); printf("New exponents: R=%g G=%g B=%g\n", newExps[0], newExps[1], newExps[2]);
return true; return true;
} }
@ -230,20 +230,23 @@ void RawImageSource::filmNegativeProcess(const procparams::FilmNegativeParams &p
float mults[3] = { 1.f }; // Channel normalization multipliers float mults[3] = { 1.f }; // Channel normalization multipliers
for (int c=0; c<3; c++) { for (int c=0; c<3; c++) {
// Find median values for each channel using a histogram search function // Find median values for each channel
findMinMaxPercentile(&cvs[c][0], cvs[c].size(), 0.5f, medians[c], 0.5f, medians[c], true); if(cvs[c].size() > 0) {
// Determine the channel multipler so that N times the median becomes 65k. This clips away std::sort(cvs[c].begin(), cvs[c].end());
// the values in the dark border surrounding the negative (due to the film holder, for example), medians[c] = cvs[c].at(cvs[c].size() / 2);
// the reciprocal of which have blown up to stellar values. // Determine the channel multipler so that N times the median becomes 65k. This clips away
mults[c] = MAX_OUT_VALUE / (medians[c] * 24); // the values in the dark border surrounding the negative (due to the film holder, for example),
// the reciprocal of which have blown up to stellar values.
mults[c] = MAX_OUT_VALUE / (medians[c] * 24);
}
} }
t4.set(); t4.set();
if (settings->verbose) { if (settings->verbose) {
printf("Sample count : %lu, %lu, %lu\n", cvs[0].size(), cvs[1].size(), cvs[2].size()); printf("Sample count : %lu, %lu, %lu\n", cvs[0].size(), cvs[1].size(), cvs[2].size());
printf("Medians : %f %f %f\n", medians[0], medians[1], medians[2] ); printf("Medians : %g %g %g\n", medians[0], medians[1], medians[2] );
printf("Computed multipliers : %f %f %f\n", mults[0], mults[1], mults[2] ); printf("Computed multipliers : %g %g %g\n", mults[0], mults[1], mults[2] );
printf("Median calc time us: %d\n", t4.etime(t3)); printf("Median calc time us: %d\n", t4.etime(t3));
} }

View File

@ -34,7 +34,7 @@ FilmNegative::FilmNegative () : FoldableToolPanel(this, "filmnegative", M("TP_FI
{ {
auto mkExponentAdjuster = [this](Glib::ustring label, double defaultVal) { auto mkExponentAdjuster = [this](Glib::ustring label, double defaultVal) {
Adjuster *adj = Gtk::manage(new Adjuster (label, 0.3, 3, 0.01, defaultVal)); //exponent Adjuster *adj = Gtk::manage(new Adjuster (label, 0.3, 5, 0.001, defaultVal)); //exponent
adj->setAdjusterListener (this); adj->setAdjusterListener (this);
if (adj->delay < options.adjusterMaxDelay) { if (adj->delay < options.adjusterMaxDelay) {
@ -49,6 +49,9 @@ FilmNegative::FilmNegative () : FoldableToolPanel(this, "filmnegative", M("TP_FI
greenExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_GREEN"), 1.0); greenExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_GREEN"), 1.0);
blueExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_BLUE"), 0.86); blueExp = mkExponentAdjuster(M("TP_FILMNEGATIVE_BLUE"), 0.86);
redRatio = redExp->getValue() / greenExp->getValue();
blueRatio = blueExp->getValue() / greenExp->getValue();
auto m = ProcEventMapper::getInstance(); auto m = ProcEventMapper::getInstance();
EvFilmNegativeEnabled = m->newEvent(ALL, "HISTORY_MSG_FILMNEGATIVE_ENABLED"); EvFilmNegativeEnabled = m->newEvent(ALL, "HISTORY_MSG_FILMNEGATIVE_ENABLED");
EvFilmNegativeExponents = m->newEvent(ALL, "HISTORY_MSG_FILMNEGATIVE_EXPONENTS"); EvFilmNegativeExponents = m->newEvent(ALL, "HISTORY_MSG_FILMNEGATIVE_EXPONENTS");
@ -139,10 +142,23 @@ void FilmNegative::enabledChanged()
void FilmNegative::adjusterChanged(Adjuster* a, double newval) void FilmNegative::adjusterChanged(Adjuster* a, double newval)
{ {
if (listener && getEnabled()) { if (listener) {
if(a == redExp || a == greenExp || a == blueExp) { if(a == redExp || a == greenExp || a == blueExp) {
listener->panelChanged (EvFilmNegativeExponents, Glib::ustring::compose ( disableListener();
"R=%1 ; G=%2 ; B=%3", redExp->getTextValue(), greenExp->getTextValue(), blueExp->getTextValue())); if(a == greenExp) {
redExp->setValue(a->getValue() * redRatio);
blueExp->setValue(a->getValue() * blueRatio);
} else if(a == redExp) {
redRatio = newval / greenExp->getValue();
} else if(a == blueExp) {
blueRatio = newval / greenExp->getValue();
}
enableListener();
if(getEnabled()) {
listener->panelChanged (EvFilmNegativeExponents, Glib::ustring::compose (
"R=%1 ; G=%2 ; B=%3", redExp->getTextValue(), greenExp->getTextValue(), blueExp->getTextValue()));
}
} }
} }
} }

View File

@ -54,6 +54,8 @@ private:
Gtk::ToggleButton* spotbutton; Gtk::ToggleButton* spotbutton;
sigc::connection spotConn; sigc::connection spotConn;
double redRatio, blueRatio;
void editToggled (); void editToggled ();
public: public: