First steps to allow border = 0, issue #4642

This commit is contained in:
heckflosse 2018-06-27 22:34:53 +02:00
parent 6af47bb8d7
commit 5c04e6308f
17 changed files with 73 additions and 11 deletions

View File

@ -740,6 +740,7 @@ HISTORY_MSG_PIXELSHIFT_DEMOSAIC;PS - Demosaic method for motion
HISTORY_MSG_PREPROCESS_LINEDENOISE_DIRECTION;Line noise filter direction
HISTORY_MSG_PREPROCESS_PDAFLINESFILTER;PDAF lines filter
HISTORY_MSG_PRSHARPEN_CONTRAST;PRS - Contrast threshold
HISTORY_MSG_RAW_BORDER;Raw border
HISTORY_MSG_SHARPENING_CONTRAST;Sharpening - Contrast threshold
HISTORY_MSG_TM_FATTAL_ANCHOR;DRC - Anchor
HISTORY_NEWSNAPSHOT;Add
@ -1769,6 +1770,7 @@ TP_RAW_4PASS;3-pass+fast
TP_RAW_AHD;AHD
TP_RAW_AMAZE;AMaZE
TP_RAW_AMAZEVNG4;AMaZE+VNG4
TP_RAW_BORDER;Border
TP_RAW_DCB;DCB
TP_RAW_DCBVNG4;DCB+VNG4
TP_RAW_DCBENHANCE;DCB enhancement

View File

@ -714,7 +714,7 @@ void RawImageSource::border_interpolate(unsigned int border, float (*image)[4],
}
}
void RawImageSource::border_interpolate2( int winw, int winh, int lborders)
void RawImageSource::border_interpolate2( int winw, int winh, int lborders, const array2D<float> &rawData, array2D<float> &red, array2D<float> &green, array2D<float> &blue)
{
int bord = lborders;
int width = winw;
@ -1657,7 +1657,7 @@ void RawImageSource::igv_interpolate(int winw, int winh)
chr[2] = hdif;
chr[3] = vdif;
border_interpolate2(winw, winh, 7);
border_interpolate2(winw, winh, 7, rawData, red, green, blue);
if (plistener) {
plistener->setProgressStr (Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::IGV)));
@ -2047,7 +2047,7 @@ void RawImageSource::igv_interpolate(int winw, int winh)
vdif = (float (*)) calloc(width * height / 2, sizeof * vdif);
hdif = (float (*)) calloc(width * height / 2, sizeof * hdif);
border_interpolate2(winw, winh, 7);
border_interpolate2(winw, winh, 7, rawData, red, green, blue);
if (plistener) {
plistener->setProgressStr (Glib::ustring::compose(M("TP_RAW_DMETHOD_PROGRESSBAR"), RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::IGV)));

View File

@ -80,6 +80,7 @@ public:
virtual bool isRGBSourceModified () const = 0; // tracks whether cached rgb output of demosaic has been modified
virtual void setBorder (unsigned int border) {}
virtual void setCurrentFrame (unsigned int frameNum) = 0;
virtual int getFrameCount () = 0;

View File

@ -243,6 +243,10 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall)
highDetailRawComputed = false;
}
if(imgsrc->getSensorType() == ST_BAYER && params.raw.bayersensor.method != RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::PIXELSHIFT)) {
imgsrc->setBorder(params.raw.bayersensor.border);
}
if (params.retinex.enabled) {
lhist16RETI (32768);
lhist16RETI.clear();

View File

@ -2345,6 +2345,7 @@ bool FilmSimulationParams::operator !=(const FilmSimulationParams& other) const
RAWParams::BayerSensor::BayerSensor() :
method(getMethodString(Method::AMAZE)),
border(4),
imageNum(0),
ccSteps(0),
black0(0.0),
@ -2381,6 +2382,7 @@ bool RAWParams::BayerSensor::operator ==(const BayerSensor& other) const
{
return
method == other.method
&& border == other.border
&& imageNum == other.imageNum
&& ccSteps == other.ccSteps
&& black0 == other.black0
@ -3345,6 +3347,7 @@ int ProcParams::save(const Glib::ustring& fname, const Glib::ustring& fname2, bo
saveToKeyfile(!pedited || pedited->raw.deadPixelFilter, "RAW", "DeadPixelFilter", raw.deadPixelFilter, keyFile);
saveToKeyfile(!pedited || pedited->raw.hotdeadpix_thresh, "RAW", "HotDeadPixelThresh", raw.hotdeadpix_thresh, keyFile);
saveToKeyfile(!pedited || pedited->raw.bayersensor.method, "RAW Bayer", "Method", raw.bayersensor.method, keyFile);
saveToKeyfile(!pedited || pedited->raw.bayersensor.border, "RAW Bayer", "Border", raw.bayersensor.border, keyFile);
saveToKeyfile(!pedited || pedited->raw.bayersensor.imageNum, "RAW Bayer", "ImageNum", raw.bayersensor.imageNum + 1, keyFile);
saveToKeyfile(!pedited || pedited->raw.bayersensor.ccSteps, "RAW Bayer", "CcSteps", raw.bayersensor.ccSteps, keyFile);
saveToKeyfile(!pedited || pedited->raw.bayersensor.exBlack0, "RAW Bayer", "PreBlack0", raw.bayersensor.black0, keyFile);
@ -4673,6 +4676,7 @@ int ProcParams::load(const Glib::ustring& fname, ParamsEdited* pedited)
if (keyFile.has_group ("RAW Bayer")) {
assignFromKeyfile(keyFile, "RAW Bayer", "Method", pedited, raw.bayersensor.method, pedited->raw.bayersensor.method);
assignFromKeyfile(keyFile, "RAW Bayer", "Border", pedited, raw.bayersensor.border, pedited->raw.bayersensor.border);
if (keyFile.has_key ("RAW Bayer", "ImageNum")) {
raw.bayersensor.imageNum = keyFile.get_integer ("RAW Bayer", "ImageNum") - 1;

View File

@ -1255,6 +1255,7 @@ struct RAWParams {
};
Glib::ustring method;
int border;
int imageNum;
int ccSteps;
double black0;

View File

@ -590,8 +590,8 @@ void RawImageSource::transformRect (const PreviewProps &pp, int tran, int &ssx1,
} else {
ssx1 = sx1;
ssy1 = sy1;
width = (sx2 - sx1) / pp.getSkip() + ((sx2 - sx1) % pp.getSkip() > 0);
height = (sy2 - sy1) / pp.getSkip() + ((sy2 - sy1) % pp.getSkip() > 0);
width = (sx2 + 1 - sx1) / pp.getSkip() + ((sx2 - sx1) % pp.getSkip() > 0);
height = (sy2 + 1 - sy1) / pp.getSkip() + ((sy2 - sy1) % pp.getSkip() > 0);
}
}

View File

@ -130,7 +130,7 @@ public:
void HLRecovery_Global (ToneCurveParams hrp);
void refinement_lassus (int PassCount);
void refinement(int PassCount);
void setBorder(unsigned int rawBorder) {border = rawBorder;}
bool isRGBSourceModified() const
{
return rgbSourceModified; // tracks whether cached rgb output of demosaic has been modified
@ -274,7 +274,7 @@ protected:
void ahd_demosaic();
void rcd_demosaic();
void border_interpolate(unsigned int border, float (*image)[4], unsigned int start = 0, unsigned int end = 0);
void border_interpolate2(int winw, int winh, int lborders);
void border_interpolate2(int winw, int winh, int lborders, const array2D<float> &rawData, array2D<float> &red, array2D<float> &green, array2D<float> &blue);
void dcb_initTileLimits(int &colMin, int &rowMin, int &colMax, int &rowMax, int x0, int y0, int border);
void fill_raw( float (*cache )[3], int x0, int y0, float** rawData);
void fill_border( float (*cache )[3], int border, int x0, int y0);

View File

@ -291,7 +291,7 @@ void RawImageSource::rcd_demosaic()
free(PQ_Dir);
}
border_interpolate2(W, H, rcdBorder);
border_interpolate2(W, H, rcdBorder, rawData, red, green, blue);
if (plistener) {
plistener->setProgress(1);

View File

@ -206,6 +206,10 @@ private:
double contrastThresholdDummy;
imgsrc->demosaic (params.raw, false, contrastThresholdDummy);
if(imgsrc->getSensorType() == ST_BAYER && params.raw.bayersensor.method != RAWParams::BayerSensor::getMethodString(RAWParams::BayerSensor::Method::PIXELSHIFT)) {
imgsrc->setBorder(params.raw.bayersensor.border);
}
if (pl) {
pl->setProgress (0.30);
}

View File

@ -336,6 +336,7 @@ void RawImageSource::vng4_demosaic (const array2D<float> &rawData, array2D<float
interpolate_row_rb_mul_pp (rawData, red[i], blue[i], green[i - 1], green[i], green[i + 1], i, 1.0, 1.0, 1.0, 0, W, 1);
}
}
border_interpolate2(W, H, 3, rawData, red, green, blue);
if(plistenerActive) {
plistener->setProgress (1.0);

View File

@ -28,6 +28,7 @@ BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RA
{
auto m = ProcEventMapper::getInstance();
EvDemosaicBorder = m->newEvent(DEMOSAIC, "HISTORY_MSG_RAW_BORDER");
EvDemosaicContrast = m->newEvent(DEMOSAIC, "HISTORY_MSG_DUALDEMOSAIC_CONTRAST");
EvDemosaicPixelshiftDemosaicMethod = m->newEvent(DEMOSAIC, "HISTORY_MSG_PIXELSHIFT_DEMOSAIC");
@ -45,6 +46,18 @@ BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RA
hb1->pack_end (*method, Gtk::PACK_EXPAND_WIDGET, 4);
pack_start( *hb1, Gtk::PACK_SHRINK, 4);
Gtk::HBox* borderbox = Gtk::manage (new Gtk::HBox ());
border = Gtk::manage (new MySpinButton ());
borderbox->set_spacing(3);
borderbox->pack_start (*Gtk::manage (new Gtk::Label (M("TP_RAW_BORDER"))), Gtk::PACK_SHRINK, 0);
borderbox->pack_start (*border);
border->set_digits (0);
border->set_increments (1, 2);
border->set_value (4);
border->set_range (0, 16);
pack_start( *borderbox, Gtk::PACK_SHRINK, 4);
imageNumberBox = Gtk::manage (new Gtk::HBox ());
imageNumberBox->pack_start (*Gtk::manage (new Gtk::Label ( M("TP_RAW_IMAGENUM") + ": ")), Gtk::PACK_SHRINK, 4);
imageNumber = Gtk::manage (new MyComboBoxText ());
@ -234,6 +247,8 @@ BayerProcess::BayerProcess () : FoldableToolPanel(this, "bayerprocess", M("TP_RA
imageNumber->connect(imageNumber->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::imageNumberChanged) ));
pixelShiftMotionMethod->connect(pixelShiftMotionMethod->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::pixelShiftMotionMethodChanged) ));
pixelShiftDemosaicMethod->connect(pixelShiftDemosaicMethod->signal_changed().connect( sigc::mem_fun(*this, &BayerProcess::pixelShiftDemosaicMethodChanged) ));
borderconn = border->signal_value_changed().connect ( sigc::mem_fun(*this, &BayerProcess::borderChanged), true);
}
@ -242,9 +257,11 @@ void BayerProcess::read(const rtengine::procparams::ProcParams* pp, const Params
disableListener ();
method->block (true);
imageNumber->block (true);
borderconn.block(true);
pixelShiftDemosaicMethod->block(true);
//allEnhconn.block (true);
border->set_value (pp->raw.bayersensor.border);
imageNumber->set_active(pp->raw.bayersensor.imageNum);
for (size_t i = 0; i < procparams::RAWParams::BayerSensor::getMethodStrings().size(); ++i) {
@ -356,6 +373,7 @@ void BayerProcess::read(const rtengine::procparams::ProcParams* pp, const Params
method->block (false);
imageNumber->block (false);
borderconn.block (false);
pixelShiftDemosaicMethod->block(false);
//allEnhconn.block (false);
@ -367,7 +385,7 @@ void BayerProcess::write( rtengine::procparams::ProcParams* pp, ParamsEdited* pe
pp->raw.bayersensor.ccSteps = ccSteps->getIntValue();
pp->raw.bayersensor.dcb_iterations = dcbIterations->getIntValue();
pp->raw.bayersensor.dcb_enhance = dcbEnhance->getLastActive ();
//pp->raw.bayersensor.all_enhance = allEnhance->getLastActive ();
pp->raw.bayersensor.border = border->get_value ();
pp->raw.bayersensor.lmmse_iterations = lmmseIterations->getIntValue();
pp->raw.bayersensor.dualDemosaicContrast = dualDemosaicContrast->getValue();
pp->raw.bayersensor.pixelShiftMotionCorrectionMethod = (RAWParams::BayerSensor::PSMotionCorrectionMethod)pixelShiftMotionMethod->get_active_row_number();
@ -705,3 +723,8 @@ void BayerProcess::FrameCountChanged(int n, int frameNum)
// }
// imageNumber->block (false);
}
void BayerProcess::borderChanged ()
{
listener->panelChanged (EvDemosaicBorder, Glib::ustring::format (border->get_value_as_int()));
}

View File

@ -32,6 +32,7 @@ protected:
MyComboBoxText* method;
Gtk::HBox *imageNumberBox;
MySpinButton* border;
MyComboBoxText* imageNumber;
Adjuster* ccSteps;
Gtk::VBox *dcbOptions;
@ -60,6 +61,9 @@ protected:
int oldMethod;
IdleRegister idle_register;
sigc::connection borderconn;
rtengine::ProcEvent EvDemosaicBorder;
rtengine::ProcEvent EvDemosaicContrast;
rtengine::ProcEvent EvDemosaicPixelshiftDemosaicMethod;
public:
@ -80,6 +84,7 @@ public:
void pixelShiftMotionMethodChanged();
void pixelShiftDemosaicMethodChanged();
void FrameCountChanged(int n, int frameNum);
void borderChanged();
};
#endif

View File

@ -392,6 +392,7 @@ void ParamsEdited::set (bool v)
icm.gampos = v;
icm.slpos = v;
raw.bayersensor.method = v;
raw.bayersensor.border = v;
raw.bayersensor.imageNum = v;
raw.bayersensor.ccSteps = v;
raw.bayersensor.exBlack0 = v;
@ -943,6 +944,7 @@ void ParamsEdited::initFrom (const std::vector<rtengine::procparams::ProcParams>
icm.gampos = icm.gampos && p.icm.gampos == other.icm.gampos;
icm.slpos = icm.slpos && p.icm.slpos == other.icm.slpos;
raw.bayersensor.method = raw.bayersensor.method && p.raw.bayersensor.method == other.raw.bayersensor.method;
raw.bayersensor.border = raw.bayersensor.border && p.raw.bayersensor.border == other.raw.bayersensor.border;
raw.bayersensor.imageNum = raw.bayersensor.imageNum && p.raw.bayersensor.imageNum == other.raw.bayersensor.imageNum;
raw.bayersensor.ccSteps = raw.bayersensor.ccSteps && p.raw.bayersensor.ccSteps == other.raw.bayersensor.ccSteps;
raw.bayersensor.exBlack0 = raw.bayersensor.exBlack0 && p.raw.bayersensor.black0 == other.raw.bayersensor.black0;
@ -2460,6 +2462,10 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
toEdit.raw.bayersensor.method = mods.raw.bayersensor.method;
}
if (raw.bayersensor.border) {
toEdit.raw.bayersensor.border = mods.raw.bayersensor.border;
}
if (raw.bayersensor.imageNum) {
toEdit.raw.bayersensor.imageNum = mods.raw.bayersensor.imageNum;
}
@ -3084,7 +3090,7 @@ void ParamsEdited::combine (rtengine::procparams::ProcParams& toEdit, const rten
bool RAWParamsEdited::BayerSensor::isUnchanged() const
{
return method && imageNum && dcbIterations && dcbEnhance && lmmseIterations && dualDemosaicContrast /*&& allEnhance*/ && greenEq
return method && border && imageNum && dcbIterations && dcbEnhance && lmmseIterations && dualDemosaicContrast /*&& allEnhance*/ && greenEq
&& pixelShiftMotionCorrectionMethod && pixelShiftEperIso && pixelShiftSigma && pixelShiftShowMotion && pixelShiftShowMotionMaskOnly
&& pixelShiftHoleFill && pixelShiftMedian && pixelShiftNonGreenCross && pixelShiftDemosaicMethod && pixelShiftGreen && pixelShiftBlur && pixelShiftSmooth && pixelShiftEqualBright && pixelShiftEqualBrightChannel
&& linenoise && linenoiseDirection && pdafLinesFilter && exBlack0 && exBlack1 && exBlack2 && exBlack3 && exTwoGreen;

View File

@ -721,6 +721,7 @@ public:
public:
bool method;
bool border;
bool imageNum;
bool ccSteps;
bool exBlack0;

View File

@ -104,6 +104,7 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren
// Raw Settings:
raw_method = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_DMETHOD")));
raw_imagenum = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_IMAGENUM")));
raw_border = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_BORDER")));
raw_pixelshift = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_PIXELSHIFT")));
raw_ccSteps = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_FALSECOLOR")));
raw_dcb_iterations = Gtk::manage (new Gtk::CheckButton (M("PARTIALPASTE_RAW_DCBITERATIONS")));
@ -215,6 +216,7 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren
vboxes[7]->pack_start (*raw, Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*hseps[7], Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*raw_method, Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*raw_border, Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*raw_imagenum, Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*raw_pixelshift, Gtk::PACK_SHRINK, 2);
vboxes[7]->pack_start (*raw_ccSteps, Gtk::PACK_SHRINK, 2);
@ -359,6 +361,7 @@ PartialPasteDlg::PartialPasteDlg (const Glib::ustring &title, Gtk::Window* paren
// Raw Settings:
raw_methodConn = raw_method->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true));
raw_borderConn = raw_border->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true));
raw_imagenumConn = raw_imagenum->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true));
raw_pixelshiftConn = raw_pixelshift->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true));
raw_ccStepsConn = raw_ccSteps->signal_toggled().connect (sigc::bind (sigc::mem_fun(*raw, &Gtk::CheckButton::set_inconsistent), true));
@ -434,6 +437,7 @@ void PartialPasteDlg::rawToggled ()
{
ConnectionBlocker raw_methodBlocker(raw_methodConn);
ConnectionBlocker raw_borderBlocker(raw_borderConn);
ConnectionBlocker raw_imagenumBlocker(raw_imagenumConn);
ConnectionBlocker raw_pixelshiftBlocker(raw_pixelshiftConn);
ConnectionBlocker raw_ccStepsBlocker(raw_ccStepsConn);
@ -461,6 +465,7 @@ void PartialPasteDlg::rawToggled ()
raw->set_inconsistent (false);
raw_method->set_active (raw->get_active ());
raw_border->set_active (raw->get_active ());
raw_imagenum->set_active (raw->get_active ());
raw_pixelshift->set_active (raw->get_active ());
raw_ccSteps->set_active (raw->get_active ());
@ -812,6 +817,10 @@ void PartialPasteDlg::applyPaste (rtengine::procparams::ProcParams* dstPP, Param
filterPE.raw.xtranssensor.method = falsePE.raw.xtranssensor.method;
}
if (!raw_border->get_active ()) {
filterPE.raw.bayersensor.border = falsePE.raw.bayersensor.border;
}
if (!raw_imagenum->get_active ()) {
filterPE.raw.bayersensor.imageNum = falsePE.raw.bayersensor.imageNum;
}

View File

@ -110,6 +110,7 @@ public:
Gtk::CheckButton* raw_linenoise;
Gtk::CheckButton* raw_greenthresh;
Gtk::CheckButton* raw_method;
Gtk::CheckButton* raw_border;
Gtk::CheckButton* raw_imagenum;
Gtk::CheckButton* raw_ccSteps;
Gtk::CheckButton* raw_dcb_iterations;
@ -134,7 +135,7 @@ public:
sigc::connection coarserotConn, finerotConn, cropConn, resizeConn, prsharpeningConn, perspectiveConn, commonTransConn;
sigc::connection metadataConn, exifchConn, iptcConn, icmConn;
sigc::connection df_fileConn, df_AutoSelectConn, ff_fileConn, ff_AutoSelectConn, ff_BlurRadiusConn, ff_BlurTypeConn, ff_ClipControlConn;
sigc::connection raw_caredblueConn, raw_ca_autocorrectConn, raw_hotpix_filtConn, raw_deadpix_filtConn, raw_pdaf_lines_filterConn, raw_linenoiseConn, raw_greenthreshConn, raw_ccStepsConn, raw_methodConn, raw_imagenumConn, raw_dcb_iterationsConn, raw_lmmse_iterationsConn, raw_pixelshiftConn, raw_dcb_enhanceConn, raw_exposConn, raw_preserConn, raw_blackConn;
sigc::connection raw_caredblueConn, raw_ca_autocorrectConn, raw_hotpix_filtConn, raw_deadpix_filtConn, raw_pdaf_lines_filterConn, raw_linenoiseConn, raw_greenthreshConn, raw_ccStepsConn, raw_methodConn, raw_borderConn, raw_imagenumConn, raw_dcb_iterationsConn, raw_lmmse_iterationsConn, raw_pixelshiftConn, raw_dcb_enhanceConn, raw_exposConn, raw_preserConn, raw_blackConn;
public:
PartialPasteDlg (const Glib::ustring &title, Gtk::Window* parent);