gray fringing on raster edges #1471

Closed
springmeyer opened this Issue Sep 5, 2012 · 5 comments

2 participants

@springmeyer
Mapnik member

Image on right is with current master (and has the problem of a single pixel gray border line). Image on right is using an older Mapnik 2.1-pre - whatever version is included in TileMill 0.9.1.

downstream report: http://support.mapbox.com/discussions/tilemill/1514-tilemill-shows-black-lines-around-raster-layers

See also #1369

@springmeyer
Mapnik member

Looks like I can workaround by avoiding premultiplying the input raster (which also avoids darkening when using bilinear scaling). No other methods I found can workaround it.

diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp
index ec4fdc9..a5acf45 100644
--- a/src/agg/process_raster_symbolizer.cpp
+++ b/src/agg/process_raster_symbolizer.cpp
@@ -93,7 +93,7 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
                                                    filter_radius);
                 }
             }
-            composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, true);
+            composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, false);
         }
     }
 }
@springmeyer springmeyer added a commit that referenced this issue Sep 12, 2012
@springmeyer springmeyer add failing testcase for #1471 (expected image generated with patch f…
…rom #1471 that disables premultiplication of data raster before blending)
12f2661
@springmeyer
Mapnik member

Just added a testcase that compares current output to what I think should be expected (or nearly) which is achievable by applying the above patch. To recap - I've also tried adding/removing ceil calls for start_* and end_* in src/agg/process_raster_symbolizer.cpp - but changing those just moves the problem gray lines around (from the left side to the right). The only thing that removes them altogether (and avoids them when using bilinear scaling (and I assume others)) is avoiding the premultiplication - which seems odd (and not the right solution) so needs a deeper look.

@artemp artemp added a commit that referenced this issue Sep 12, 2012
@artemp artemp raster scaling issue
+ fix rasterizer polygon to be equal to target image
+ align raster to pixel bouyndaries (?)
  ( fixes grey border issue - #1471)
8cb2ce4
@artemp
Mapnik member

@springmeyer - see 8cb2ce4 - It should fix 'grey' border issue

@artemp
Mapnik member

@springmeyer - another approach would be to pre-initialise target buffer with 'master' (background) buffer values.

@springmeyer
Mapnik member

8cb2ce4 looks great. Also checked tile alignment (for this test case) is good enough:

The red circle highlights one place where pixels are visibly not perfectly aligned, but only at extremely high zoom levels, so I think this is more than good enough (if this is the poorest visible alignment):

@springmeyer springmeyer referenced this issue in mapbox/tilemill Sep 14, 2012
Closed

mapnik 2.1.1 fixes #1683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment