[mapserver-users] jagged edges on images

Ed McNierney ed at topozone.com
Fri Jun 14 05:58:11 PDT 2002


Chris -

In the example you sent, it's not downsampling, it's upsampling - the
output image is at a higher resolution than the input image.  While
there are alternatives, and it would be nice for MapServer to support
more resampling options, doing that well really needs to wait for the
24-bit output support to be available.

Why do you not want to store multiple copies of the data?  With multiple
copies you greatly reduce the amount of resampling that needs to be
done, and I'm a big fan of precomputing everything you possibly can.

	- Ed


-----Original Message-----
From: chris_faulkner at anytimenow.com
[mailto:chris_faulkner at anytimenow.com] 
Sent: Friday, June 14, 2002 3:41 AM
To: Ed McNierney
Cc: chris_faulkner at anytimenow.com; mapserver-users at lists.gis.umn.edu
Subject: RE: [mapserver-users] jagged edges on images


Hi

Yes - when I make sure that the input image resolution is the same as
output,  the image looks OK. 

However, as my last email says, I do want to be able to  change scale
without storing multiple copies of the data so it would be nice if the
down-sampling operation could support an option of a higher quality
alogorithm. IN this case, the output image might need to increase in
depth, though - maybe MapServer wouldn't support that.

Chris


> Chris -
> 
> This looks like an artifact of image scaling in the output image.
> MapServer prudently uses a fast algorithm for scaling source input
> images to produce the output result.  If you ask for an output image
> whose pixel resolution (that is, meters per pixel, for example) is
> different than the source image resolution, the source image has to be
> scaled.  Your sample image looks like an output image with a pixel
> resolution slightly smaller than the input image.  For example, let's
> assume your source image is at a resolution of 2 meters per pixel.
Then
> let's assume you asked for a 400 x 400 pixel output image from
MapServer
> with a spatial extent of 600 meters by 600 meters.  That means you
want
> the output pixels to be 1.5 meters per pixel.
> 
> Since the output is "zoomed in" a bit, MapServer is being asked to 
> generate 400 output pixels (in each dimension) out of 300 input pixels

> (600 meters at 2 meters per pixel).  It will do that by duplicating 
> every third input pixel in the output, so if you had a row of pixels 
> with these values:
> 
> 0 1 2 3 4 5
> 
> you would get an output image with these values:
> 
> 0 1 2 2 3 4 5 5
> 
> Image then, that you had two single-pixel vertical lines in the source

> image.  In the output, the one at pixel position 2 would end up being 
> two pixels wide, while the identical input line at pixel position 4 
> would still be only one pixel wide in the output.  This will look 
> strange.
> 
> In your specific example, you appear to have antialiased text in the 
> input image.  The intermediate-shaded pixels along the edge of the 
> text are sometimes replicated, giving the odd effect you see in the 
> words "Briar Patch".
> 
> For optimum image quality without artifacts, keep the output image 
> resolution the same as the source resolution, or a multiple of 2x the 
> source resolution.  If you're going to be doing that often, consider 
> using GDAL and create overview images (preprocessed subsamples of the 
> source image) to avoid having to resample the source image over and 
> over again to serve map requests.
> 
>  - Ed
> 
> Ed McNierney
> President and Chief Mapmaker
> TopoZone.com / Maps a la carte, Inc.
> 73 Princeton Street, Suite 305
> North Chelmsford, MA  01863
> ed at topozone.com
> (978) 251-4242
> 
> -----Original Message-----
> From: chris_faulkner at anytimenow.com 
> [mailto:chris_faulkner at anytimenow.com]
> Sent: Wednesday, June 12, 2002 6:14 PM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [mapserver-users] jagged edges on images
> 
> 
> Hello again
> 
> I've been looking at some imagery being generated via PHP Mapscript. 
> On my imagery , jagged effects appear along some of the edges. The 
> jagged version from MapServer is attached. Look along the road 
> boundaries and the word "Briar Patch". Anyone know why this happens ? 
> These effects don't appear when I view and zoom in and out of the 
> source with ImageMagick. Here is the tiffinfo output. Note that I 
> started with tiled Tifs and converted to stripped - I have played with

> different sized strips.
> 
> TIFF Directory at offset 0x1255d6
>   Image Width: 3500 Image Length: 3500
>   Bits/Sample: 8
>   Compression Scheme: PackBits
>   Photometric Interpretation: palette color (RGB from colormap)
>   FillOrder: msb-to-lsb
>   Document Name: "Standard Input"
>   Image Description: "converted PNM file"
>   Orientation: row 0 top, col 0 lhs
>   Samples/Pixel: 1
>   Rows/Strip: 2
>   Planar Configuration: single image plane
>   Color Map: (present)
> 
> If anyone needs it, I can send the original one but I didn't want to 
> waste too much bandwidth !
> 
> Thanks
> 
> 
> Chris
> 
> 



More information about the MapServer-users mailing list