Skip to content

Commit

Permalink
[tools/tone mapping v3] temporarily disabled local contrast adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
aferrero2707 committed Jul 29, 2020
1 parent 71fd34e commit 7cdb62d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 18 deletions.
9 changes: 7 additions & 2 deletions src/gui/layerwidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,6 @@ PF::LayerWidget::LayerWidget( Image* img, ImageEditor* ed ):
ADD_TOOL_ITEM( _("Relight"), "relight" );
ADD_TOOL_ITEM( _("Shadows/Highlights"), "shadows_highlights_v2" );
ADD_TOOL_ITEM( _("Tone mapping"), "tone_mapping_v2" );
ADD_TOOL_ITEM( _("Tone mapping V3"), "tone_mapping_v3" );
ADD_TOOL_ITEM( _("Dynamic range compressor"), "dynamic_range_compressor_v2" );
ADD_TOOL_ITEM( _("Shadows/Highlights old"), "shadows_highlights" );
ADD_TOOL_ITEM( _("Tone mapping old"), "tone_mapping" );
Expand Down Expand Up @@ -881,7 +880,6 @@ PF::LayerWidget::LayerWidget( Image* img, ImageEditor* ed ):
ADD_TOOL_ITEM( _("Draw"), "draw" );



item = new Gtk::MenuItem(_("misc"));
tools_menu.append( *item );
submenu = new Gtk::Menu;
Expand All @@ -892,6 +890,13 @@ PF::LayerWidget::LayerWidget( Image* img, ImageEditor* ed ):
ADD_TOOL_ITEM( _("Buffer layer"), "buffer" );
ADD_TOOL_ITEM( _("Digital watermark"), "gmic_watermark_fourier" );


item = new Gtk::MenuItem(_("experimental"));
tools_menu.append( *item );
submenu = new Gtk::Menu;
item->set_submenu( *submenu );
ADD_TOOL_ITEM( _("Tone mapping V3"), "tone_mapping_v3" );

tools_menu.show_all();

/*
Expand Down
18 changes: 9 additions & 9 deletions src/gui/operations/tone_mapping_config_v3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,9 @@ PF::ToneMappingConfigGUI_V3::ToneMappingConfigGUI_V3( PF::Layer* layer ):
LE_frame( _("contrast curve") ),
exposure_slider( this, "exposure", _("exposure (EV)"), 0, 0, 10, 0.1, 0.5, 1 ),
latitude_slider( this, "latitude", _("latitude"), 0, 0, 100, 1, 5, 100 ),
contrast_slider( this, "slope", _("mid-tones"), 0, -100, 100, 5, 20, 100 ),
slope2_slider( this, "slope2", _("highlights"), 0, -100, 100, 5, 20, 100 ),
slope3_slider( this, "slope3", _("shadows"), 0, -100, 100, 5, 20, 100 ),
contrast_slider( this, "slope", _("mid-tones slope"), 0, -100, 100, 5, 20, 100 ),
slope2_slider( this, "slope2", _("highlights slope"), 0, -100, 100, 5, 20, 100 ),
slope3_slider( this, "slope3", _("shadows slope"), 0, -100, 100, 5, 20, 100 ),
white_point_slider( this, "white_point", _("white level (EV)"), 0, 0, 10, 0.1, 0.5, 1 ),
lumi_blend_frac_slider( this, "lumi_blend_frac", _("lumi blend"), 1, 0, 100, 1, 5, 100 ),
tc_frame( _("tone curve") ),
Expand Down Expand Up @@ -429,14 +429,14 @@ PF::ToneMappingConfigGUI_V3::ToneMappingConfigGUI_V3( PF::Layer* layer ):
tc_box.pack_start( latitude_slider, Gtk::PACK_SHRINK );

slope2_slider.set_conversion_functions(contrast_slider_to_prop, cotrast_prop_to_slider);
contrast_box.pack_start( slope2_slider, Gtk::PACK_SHRINK );
tc_box.pack_start( slope2_slider, Gtk::PACK_SHRINK );
contrast_slider.set_conversion_functions(contrast_slider_to_prop, cotrast_prop_to_slider);
contrast_box.pack_start( contrast_slider, Gtk::PACK_SHRINK );
tc_box.pack_start( contrast_slider, Gtk::PACK_SHRINK );
slope3_slider.set_conversion_functions(contrast_slider_to_prop, cotrast_prop_to_slider);
contrast_box.pack_start( slope3_slider, Gtk::PACK_SHRINK );
contrast_frame.add(contrast_box);
tc_box.pack_start( slope3_slider, Gtk::PACK_SHRINK );

tc_box.pack_start( contrast_frame, Gtk::PACK_SHRINK );
contrast_frame.add(contrast_box);
//tc_box.pack_start( contrast_frame, Gtk::PACK_SHRINK );
//tc_frame.add( tc_box );
//controlsBox.pack_start( tc_box, Gtk::PACK_SHRINK, 0 );
notebook.append_page(tc_box, _("Tone mapping"));
Expand All @@ -452,7 +452,7 @@ PF::ToneMappingConfigGUI_V3::ToneMappingConfigGUI_V3( PF::Layer* layer ):
local_contrast_box.pack_start( local_contrast_slider, Gtk::PACK_SHRINK );
local_contrast_box.pack_start( local_contrast_radius_slider, Gtk::PACK_SHRINK );
local_contrast_box.pack_start( local_contrast_threshold_slider, Gtk::PACK_SHRINK );
notebook.append_page(local_contrast_box, _("Local contrast"));
//notebook.append_page(local_contrast_box, _("Local contrast"));

//controlsBox.pack_start( local_contrast_frame, Gtk::PACK_SHRINK, 2 );

Expand Down
29 changes: 22 additions & 7 deletions src/operations/tone_mapping_v3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ PF::ToneMappingParV3::ToneMappingParV3():
void PF::ToneMappingParV3::pre_build( rendermode_t mode )
{
float mid_grey = 0.1845;
std::cout<<"[ToneMappingParV3::pre_build] slopes: "<<get_slope()<<", "<<get_slope2()<<", "<<get_slope3()<<std::endl;
tm.init(get_slope(), get_slope2(), get_slope3(), get_white_point(), get_exposure(), get_latitude());
}

Expand Down Expand Up @@ -546,7 +547,7 @@ VipsImage* PF::ToneMappingParV3::build(std::vector<VipsImage*>& in, int first,
std::cout<<"ToneMappingParV3::build(): radius="<<lc_radius.get()<<std::endl;
#endif

for(int gi = 0; gi < 10; gi++) {
for(int gi = 0; gi < 0; gi++) {
PF::GuidedFilterPar* guidedpar = dynamic_cast<PF::GuidedFilterPar*>( guided[gi]->get_par() );
if( !guidedpar ) break;
if( rv[gi] == 0 ) break;
Expand Down Expand Up @@ -611,7 +612,7 @@ VipsImage* PF::ToneMappingParV3::build(std::vector<VipsImage*>& in, int first,


in2.clear();
in2.push_back(smoothed);
//in2.push_back(smoothed);
in2.push_back(logimg);
in2.push_back(in[0]);

Expand Down Expand Up @@ -665,6 +666,20 @@ class ToneMappingV3< float, BLENDER, PF_COLORSPACE_RGB, CHMIN, CHMAX, has_imap,

TM_V3& tm = opar->get_tm();

VipsRegion* sreg = NULL;
VipsRegion* lreg = NULL;
VipsRegion* inreg = NULL;
if(n == 3) {
sreg = ireg[0];
lreg = ireg[1];
inreg = ireg[2];
}
if(n == 2) {
lreg = ireg[0];
inreg = ireg[1];
}
if(!inreg) return;

float* lin;
float* sin;
float* pin;
Expand Down Expand Up @@ -697,9 +712,9 @@ class ToneMappingV3< float, BLENDER, PF_COLORSPACE_RGB, CHMIN, CHMAX, has_imap,
//std::cout<<"log(gamma+1) / gamma_scale = "<<log(gamma+1) / gamma_scale<<std::endl;

for( y = 0; y < height; y++ ) {
sin = (float*)VIPS_REGION_ADDR( ireg[0], r->left, r->top + y );
lin = (float*)VIPS_REGION_ADDR( ireg[1], r->left, r->top + y );
pin = (float*)VIPS_REGION_ADDR( ireg[2], r->left, r->top + y );
sin = (sreg != NULL) ? (float*)VIPS_REGION_ADDR( sreg, r->left, r->top + y ) : NULL;
lin = (float*)VIPS_REGION_ADDR( lreg, r->left, r->top + y );
pin = (float*)VIPS_REGION_ADDR( inreg, r->left, r->top + y );
pout = (float*)VIPS_REGION_ADDR( oreg, r->left, r->top + y );

for( x = 0, x0 = 0; x < line_size; x+=3, x0++ ) {
Expand All @@ -717,11 +732,11 @@ class ToneMappingV3< float, BLENDER, PF_COLORSPACE_RGB, CHMIN, CHMAX, has_imap,
RGB[1] = pin[x+1];
RGB[2] = pin[x+2];
RGB[3] = lin[x0];
RGB[4] = sin[x0];
RGB[4] = (sin != NULL) ? sin[x0] : lin[x0];
if( RGB[0] < 0 ) RGB[0] = 0;
if( RGB[1] < 0 ) RGB[1] = 0;
if( RGB[2] < 0 ) RGB[2] = 0;
D = (lin[x0] - sin[x0]);
D = (sin != NULL) ? (lin[x0] - sin[x0]) : 0.0f;
//std::cout<<"[TM] [x,y]="<<x0+r->left<<","<<y+r->top<<" l1: "<<lin[x0]<<" l2: "<<sin[x0]<<" delta="<<D<<std::endl;

float min = MIN3(RGB[0], RGB[1], RGB[2]);
Expand Down

0 comments on commit 7cdb62d

Please sign in to comment.