You are here: Advanced Encoding and Tools > Despeckling an Image

Despeckling an Image

A side effect of lossy encoding schemes is that subtle compression artifacts are introduced which alter the pixel values of the source image. While these changes are usually invisible to the human eye, they can damage the integrity of any collar regions in the image, which makes it difficult to seamlessly mosaic images together.

The best way to avoid this "speckling" in the collar areas is to compress to MrSID Generation 4, or to losslessly encode source images to MrSID Generation 3 or JPEG 2000. If you need to make images with higher compression ratios, GeoExpress offers a despeckling option to minimize the compression effects in the areas that should be transparent.

Despeckling is a computationally expensive operation that increases the time it takes to encode an image. Also, despeckled JPEG 2000 files employ an alpha band to mask the transparent region; most, but not all, applications can view JPEG 2000 files with alpha bands.

Despeckling is only supported for MG3, MG4 and JPEG 2000 output. If you select JPEG 2000 as the format of your despeckled output, that output will be a GMLJP2 file and thus a JPEG 2000 Part II file, even if your input was a JPEG 2000 Part I file. Source images with alpha bands cannot be despeckled when outputting to JPEG 2000. Also, the area of valid image data must be contained within a single polygon (for example, an image of a series of islands cannot be despeckled).

There are two ways to despeckle imagery in GeoExpress: despeckling upon encoding and despeckling existing MrSID and JPEG 2000 images. For information on how to despeckle existing imagery, see Despeckling Existing Imagery.

To despeckle images upon encoding:

To encode a new image that's speckle-free, use the -despeckle/-ds switch with a value of "true". For example:

mrsidgeoencoder -i foo.tif -o foo.sid -of mg4 -despeckle true

By default this value is "false" and images are not despeckled upon encoding. Further, despeckling is not recommended for images without a collar.

Setting Despeckling Options

If you require finer control over how despeckling is performed, you can set despeckling threshold and point spacing values.

To set despeckling threshold and point spacing values:

Specify a threshold value with the -dsthreshold switch. For example:

mrsidgeoencoder -i foo.tif -o foo.sid -of mg3 -ds true -dsthreshold 10

Specify point spacing using the -dsspacing switch, which takes an integer value greater than zero. For example:

mrsidgeoencoder -i foo.tif -o foo.sid -ds true -dsspacing 8

Despeckling Threshold

All pixel values below the despeckling threshold will be used in the despeckling process. For example, with a threshold value of 10, GeoExpress treats any border pixels with a value less than 10 as no-data pixels.

If the -despeckle/-ds switch is set to "true" but no despeckling threshold value is specified, the default value is 8.

Point Spacing

In order to despeckle an image, GeoExpress must determine the mask or "outline" of the valid image data. This outline is created as a polygon of connected points, similar to a "connect the dots" drawing. Image data that fall outside the outline are treated as invalid and subject to despeckling.

Whether image pixels are incorporated into the mask or abandoned as "islands" of data is largely a function of the point spacing value, which determines the distance between the points that make up the outline. The less distance there is between points in the outline, the more points it takes to create the entire outline.

Therefore, decreasing the point spacing value raises the number of points, which is generally desirable and is particularly useful when the outline is complex, such as that of a coastline. However, higher numbers of points may slow performance or cause the job to fail. Conversely, increasing the point spacing value reduces the total number of points, which makes for better performance. When the outline is simple, such as a rectangle, the point spacing value can safely be increased.

For any given dataset, some trial and adjustment may be required to arrive at the best balance between a more accurate mask (lower point spacing value) and better encode performance (higher point spacing value).

Generally, even values between 6 and 12 work best.

If the -despeckle/-ds switch is set to "true" but no point spacing value is specified, the default value is 6.