Message Boards Message Boards

Export of Geographics anti-aliasing problem

I have the following code:

img= [IMAGE];
out=GeoGraphics[{GeoStyling[{"GeoImage",img}],poly},ImageSize->1000,GeoRange->"World",GeoProjection->"Equirectangular"]
Export["out.png",out]

'out' looks good and only has some slight problems with anti-aliasing around the lines in img. See also the notebook. The image in mathematica looks like:

enter image description here

But the exported file looks much worse:

enter image description here

The 'overlay' is created in mathematica, rastering a ContourPlot as "Image" with Background->None. The overlay image (img) does not show this anti-aliasing artifacts. The preview in mathematica shows a bit of anti-aliasing problems, but the export a lot.

How can I remedy the (lack of) anti-aliasing? Any ideas?

Attached is the notebook.

Attachments:
POSTED BY: Sander Huisman
6 Replies

I think the problem comes when the lcp image is resized (because the transparency). Doing the composition in other way lets you have the nice image we all expect:

ImageResize[
 ImageCompose[
  GeoGraphics[{}, ImageSize -> 2000, 
    GeoRange -> {{-89, 89}, {-180, 180}}, GeoZoomLevel -> 2, 
    GeoProjection -> "Equirectangular"] // Image, lcp], 1000]

I tried first doing the resize over the lcp, but got the same bad result, so better do the composition first, then the resizing. I know this looks like a workaround, but the "GeoImage" way does perform something like the resize, so has the same artifacts as ImageResize[lcp, 1000].

This works better! Thanks. I still think, though, this is a bug. The resizing of something anti-aliased/opacity channel should not matter that much and should not introduce these dark grey-ish pixels.

POSTED BY: Sander Huisman

Does this solve the problem

Export["output.png", out, ImageSize -> 3000]

if you resample image back to 1000 px ? You could adjust thickness of lines accordingly.

POSTED BY: Vitaliy Kaurov

Vitaliy, I think it more something fundamental. Probably you can make it less by resampling very high resolution. But I keep seeing it, not really sure if it gets less. I think the transparancy channel for the rasterize does something wrong...

POSTED BY: Sander Huisman

Sander, can you define poly ?

POSTED BY: Vitaliy Kaurov

O sorry, poly is just a rectangle. I updated my code here.

Attachments:
POSTED BY: Sander Huisman
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract