[MapProxy] Image quality problem for 8 bit paletted png,
ragged lines
Anne Blankert
anne.blankert at geodan.nl
Thu Apr 5 11:51:20 EDT 2012
Hello List,
I am having a (minor) problem with image quality. Cached lines are much
more ragged than the original lines. Resolution and projection of source
and cache are identical. I found a work-around (meta_buffer:0,
meta_size[1,1]), but I think it would be better if the work- around
would not be necessary?
Visual
1. cached 256x256 png image:
http://research.geodan.nl/edugis/images/raggedlines.png
2. wms original 1184x1184 png image:
http://research.geodan.nl/edugis/images/wmsoriginal.png
Explanation:
I am using mapproxy version 1.3.0, tried both Windows (64 bit) and
Ubuntu (64 bit) versions, same result. See mapproxy.yaml below.
Reproducing the problem:
My mapping client sends the following request to mapproxy for a single
tile of 256 x 256 pixels:
http://mymapproxy.example.com/mapproxy/service?LAYERS=agn&TRANSPARENT=true&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&Styles=&SRS=EPSG%3A900913&BBOX=543008.64525162,6863280.7649075,543161.51930816,6863433.638964&WIDTH=256&HEIGHT=256
The resulting 256x256 png image is at:
http://research.geodan.nl/edugis/images/raggedlines.png
The mapproxy cache on disk contains the same image, also displaying
ragged lines.
In order to fill the cache, Mapproxy request a 1184 x 1184 png image
from the orginal WMS server (mapserv version 6.0.1):
http://mywms.example.com/cgi-bin/mapserv?map=maps/geodan/agn.map&styles=&format=image%2Fpng&height=1184&bbox=542960.875795,6862774.37441,543667.918307,6863481.41693&transparent=True&layers=agn&service=WMS&width=1184&request=GetMap&srs=EPSG%3A900913&version=1.1.1
The resulting wms image is at:
http://research.geodan.nl/edugis/images/wmsoriginal.png
As you see, the original image does not show ragged lines (cached tile
area is at top left of this wms image) . If you zoom in and compare
these images, you will notice that the original image has more gray
levels than the cached image. Therefore the problem seems not to be in
the lines, but in the paletted color-table of the 8 bit png image.
The workaround is to configure the cache as follows:
meta_buffer: 0
meta_size: [1,1]
With these settings, the cached image and the wms image are identical,
so there is no need for Mapproxy to process the image and the ragged
line problem disappears.
Is there a configuration option to solve this problem? Maybe force
MapProxy to use the same paletted color table for cache and original? I
tried several image encoding options.
Thanks,
Anne Blankert
==
My mapproxy.yaml
services:
demo:
kml:
tms:
# needs no arguments
wms:
srs: ['EPSG:4326', 'EPSG:900913', 'EPSG:28992']
# image_formats: ['image/jpeg', 'image/png']
md:
# metadata used in capabilities documents
title: MapProxy WMS Proxy
abstract: MapProxy service
online_resource: http://mapproxy.example.com/
contact:
person: OSGIS beheerder
position: Beheerders
organization: Geodan.nl
address: Geodan, President Kennedylaan 1
city: Amsterdam
postcode: 1079 MB
country: the Netherlands
phone: ...
fax: ..
email: ...
access_constraints: none
fees: 'None'
layers:
- name: agn
title: Adressen en Gebouwen Nederland (agn)
sources: [agn_cache]
caches:
agn_cache:
grids: [GLOBAL_MERCATOR]
sources: [agn_wms]
disable_storage: false
# meta_buffer: 0
# meta_size: [1,1]
sources:
agn_wms:
type: wms
wms_opts:
featureinfo: true
supported_srs: ['EPSG:900913']
req:
url: http://mywms.example.com/cgi-bin/mapserv?map=maps/geodan/agn.map
layers: agn
transparent: true
grids:
global_geodetic_sqrt2:
base: GLOBAL_GEODETIC
res_factor: 'sqrt2'
globals:
# # coordinate transformation options
# srs:
# # WMS 1.3.0 requires all coordiates in the correct axis order,
# # i.e. lon/lat or lat/lon. Use the following settings to
# # explicitly set a CRS to either North/East or East/North
# # ordering.
# axis_order_ne: ['EPSG:9999', 'EPSG:9998']
# axis_order_en: ['EPSG:0000', 'EPSG:0001']
# # you can set the proj4 data dir here, if you need custom
# # epsg definitions. the path must contain a file named 'epsg'
# # the format of the file is:
# # <4326> +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs <>
# proj_data_dir: '/path to dir that contains epsg file'
# # cache options
cache:
# where to store the cached images
base_dir: 'c:/temp/mapproxy/mp'
# where to store lockfiles
lock_dir: 'c:/temp/mapproxy/mplocks'
# image/transformation options
image:
#resampling_method: nearest
# resampling_method: bilinear
resampling_method: bicubic
# formats:
# image/png:
# encoding_options:
# quantizer: fastoctree
# jpeg_quality: 90
# # stretch cached images by this factor before
# # using the next level
# # stretch_factor: 1.15
# stretch_factor: 1.2
# # shrink cached images up to this factor before
# # returning an empty image (for the first level)
# max_shrink_factor: 4.0
More information about the MapProxy
mailing list