[mapserver-users] jagged edges on images

chris_faulkner@anytimenow.com chris_faulkner@anytimenow.com
Fri, 14 Jun 2002 08:41:20 +0100 (GMT Daylight Time)


--------------Boundary-00=_XOQO8N5BHMZOOQCFXFP0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hi

Yes - when I make sure that the input image resolution is the same as out=
put,  the image looks OK.=20

However, as my last email says, I do want to be able to  change scale wit=
hout 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=
=2E IN this case, the output image might need to increase in depth, thoug=
h - maybe MapServer wouldn't support that.

Chris


> Chris -
>=20
> This looks like an artifact of image scaling in the output image.=20
> 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.  The=
n
> let's assume you asked for a 400 x 400 pixel output image from MapServe=
r
> with a spatial extent of 600 meters by 600 meters.  That means you want
> the output pixels to be 1.5 meters per pixel.
>=20
> 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:
>=20
> 0 1 2 3 4 5
>=20
> you would get an output image with these values:
>=20
> 0 1 2 2 3 4 5 5
>=20
> 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.
>=20
> 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".
>=20
> 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 ove=
r
> again to serve map requests.
>=20
>  - Ed
>=20
> Ed McNierney
> President and Chief Mapmaker
> TopoZone.com / Maps a la carte, Inc.
> 73 Princeton Street, Suite 305
> North Chelmsford, MA  01863
> ed@topozone.com
> (978) 251-4242=20
>=20
> -----Original Message-----
> From: chris_faulkner@anytimenow.com
> [mailto:chris_faulkner@anytimenow.com]
> Sent: Wednesday, June 12, 2002 6:14 PM
> To: mapserver-users@lists.gis.umn.edu
> Subject: [mapserver-users] jagged edges on images
>=20
>=20
> Hello again
>=20
> 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 tile=
d
> Tifs and converted to stripped - I have played with different sized
> strips.
>=20
> 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)
>=20
> If anyone needs it, I can send the original one but I didn't want to
> waste too much bandwidth !
>=20
> Thanks
>=20
>=20
> Chris
>=20
>=20

--------------Boundary-00=_XOQO8N5BHMZOOQCFXFP0--