Apply Convolution Filter to Layer
The Apply Convolution Filter to Layer tool takes any single raster layer (image or terrain) and applies a filter that can be used to sharpen, blur, enhance, or help detect edges. This will create a new layer with the selected filter applied to some or all of the selected layer. Filters are similar to changing the Resampling options in the Raster Layer Display Options, with the difference being that Filters create a new layer, while the resampling options edit the existing layer and provide guidance on how to handle data interpolation for that layer. In addition to the built in filter options listed below, you can also create a Custom Convolution Filter.
Apply Convolution Filter to Layer is found in the Analysis Menu, and also under the Analysis menu when right-clicking on a layer in the Control Center.
This tool requires Global Mapper Pro.
Convolution filters work by using a weighted kernel (3x3, 5x5, etc), and will not work with streamed online data or raster layers contained in a Map Catalog. To apply a convolution filter to data from an online source, you must export the data to a local file and then load and operate on the local file.
When the tool has been selected, and layers specified, the dialog pictured below will appear. This dialog allows you to specify the name of the new layer, the filter method to apply, and the bounds. You can also create new custom filters (Global Mapper Pro required) that use a weight matrix to multiply the values by.
The new Layer Description can be customized. The default description will be based on the input layer name, the convolution filter selected, and the kernel size (<input layer name> - [<convolution filter> <kernel size>] ).
Filters /Resampling methods
When the pixels change size due to changes in resolution or reprojection, the filtering method determines how new pixel values are calculated. Some of these filters are good for highlighting edges, where "edges" are sudden changes in the intensity of pixels in an area of the image.
The following filtering methods are supported:
Nearest Neighbor - simply uses the value of the sample/pixel that a sample location is in. When resampling an image this can result in a stair-step effect, but will maintain exactly the original color values of the source image.
Box Average - the box average method simply find the average values of the nearest 4 (for 2x2), 9 (for 3x3), 16 (for 4x4), 25 (for 5x5), 49 (for 7x7), 64 (for 8x8), or 81 (for 9x9) ) pixels and use that as the value of the sample location. These methods are very good for resampling data at lower resolutions. The lower the resolution of your export is as compared to the original, the larger "box" size you should use.
Box Maximum - the box maximum methods simply find the maximum value of the nearest 4 (for 2x2), 9 (for 3x3), 16 (for 4x4), 25 (for 5x5), 49 (for 7x7), 64 (for 8x8), or 81 (for 9x9) pixels and use that as the value of the sample location. These methods are very good for resampling elevation data at lower resolutions so that the new terrain surface has the maximum elevation value rather than the average (good for terrain avoidance). The lower the resolution of the export file is as compared to the original, the larger "box" size that should be used.
Box Minimum - the box minimum methods simply find the minimum value of the nearest 4 (for 2x2), 9 (for 3x3), 16 (for 4x4), 25 (for 5x5), 49 (for 7x7), 64 (for 8x8), or 81 (for 9x9) pixels and use that as the value of the sample location. These methods are very good for resampling elevation data at lower resolutions so that the new terrain surface has the minimum elevation value rather than the average. The lower the resolution of the export file is as compared to the original, the larger "box" size that should be used.
Filter/Noise/Median - the Filter/Noise/Median methods simply find the median values of the nearest 4 (for 2x2), 9 (for 3x3), 16 (for 4x4), 25 (for 5x5), 49 (for 7x7), 64 (for 8x8), or 81 (for 9x9) pixels and use that as the value of the sample location. This resampling function is useful for noisy rasters, so outlier pixels do not contribute to the kernel value. Some common sources of raster noise are previous compression artifacts or irregularities of a scanned map/image.
Gaussian Blur - the Gaussian blur methods calculate the value to be displayed for each pixel based on the nearest 9 (for 3x3), 25 (for 5x5), or 49 (for 7x7) pixels. The calculated value uses the Gaussian formula that weights the values based on the distance to the reference pixel.
Box Mode (Most Common) - the Box Mode method sets the sample value to the most common value within the box , like the mode of the list of values. If there are multiple values with the same count, then if one matches the center value, that is kept. Otherwise just the first of the most common is used.
Smooth - the smoothing filter is used to smooth an image by reducing the contrast between neighboring pixels. It produces smooth images and the edges and corners are less accentuated. It is a weighted average where values closer to the center of the box are more heavily weighted. (Contrast this to Box Average where all values in the Kernel are weighted equally)
Sharpen - Sharpen filters (3x3 only) accentuate differences in a value with its neighbors, sharpening edges between objects. Examples and details on the sharpen filter variations are shown below.
-
Sharpen II (3x3) is similar to Sharpen (3x3), but the filter is more aggressive than Sharpen (3x3).
-
Sharpen High Pass (3x3, 5x5) - often used for edge enhancement. It accentuates the differences in pixel values compared to their neighboring pixels by calculating a weighted sum for each pixel in the image using a kernel neighborhood. It brings out the edges and boundaries between different features, making the image appear sharper. The kernel used in the filter (3x3, 5x5) determines size of the neighboring pixels (9, 25) that are included in the neighborhood and how much weight is given to each of them.
Sharpen Filter Examples
Sharpen Kernel Example Original Sharpen
0 -0.25 0 -0.25 2 -0.25 0 -0.25 0 Sharpen II
-0.25 -0.25 -0.25 -0.25 3 -0.25 -0.25 -0.25 -0.25 Sharpen (High Pass)
-1 -1 -1 -1 9 -1 -1 -1 -1
Gradient - the Gradient Filters (3x3 only) is used to detect edges in an image by calculating the gradient in a specified cardinal direction. Options include North, East, South, Northeast, and Northwest. When used on elevation data the generated layer will display with the gradient shader applied.
Gradient Filter Examples
Gradient Kernel Example Terrain Example Image Original North
-1 -2 -1 0 0 0 1 2 1 South
1 2 1 0 0 0 -1 -2 -1 East
1
0 -1 2 0 -2 1 0 -1 West
-1 0 1 -2 0 2 -1 0 1 Northeast
0 -1 -2 1 0 -1 2 1 0 Northwest
-2 -1 0 -1 0 1 0 1 2
Laplacian (Edge Detection) - the Laplacian filter (3x3 or 5x5 only) is a second-order derivative operator, used to calculate the rate of change in the intensity of an image, and emphasizes areas of rapid intensity change, such as edges. It is a more sensitive edge detection method, often best applied to an image that has first been smoothed. When used on elevation data the generated layer will display with the gradient shader applied.
Laplacian Filter Examples
Laplacian Kernel Example Terrain Example Image Original 3x3
0 -1 0 -1 4 -1 0 -1 0 5x5
0 0 -1 0 0 0 -1 -2 -1 0 -1 -2 17 -2 -1 0 -1 -2 -1 0 0 0 -1 0 0
Line Detection- the Line Detection filters (3x3 only) can be used for edge detection similar to the Gradient Filters. These filters accentuate lines oriented in the specified direction ( either horizontal, vertical, or diagonal) while suppressing the others. When used on elevation data the generated layer will display with the gradient shader applied.
Line Detection Examples
Line Detection Kernel Example Terrain Example Image Original Horizontal
-1 -1 -1 2 2 2 -1 -1 -1 Vertical
-1 0 -1 -1 2 -1 -1 2 -1 Left Diagonal
2 -1 -1 -1 2 -1 -1 -1 2 Right Diagonal
-1 -1 2 -1 2 -1 2 -1 -1
Sobel - Sobel filters are used for edge detection that involves a convolution of 3x3 kernel, for detecting either horizontal or vertical edges by multiplying the corresponding pixel values of the image with the kernel and summing them up. It results in an image where the intensity values of pixels are proportional to the strength of the directional edges in the original image. Edges are visible as extreme high/low values in the generated layer. When used on elevation data the generated layer will display with the gradient shader applied.
Sobel Filter Examples
Sobel Kernel Example Terrain Example Image Original Horizontal
-1 -2 -1 0 0 0 1 2 1 Vertical
-1 0 1 -2 0 2 -1 0 1
Bounds
The Bounds button allows the user to set up the portion of the loaded elevation grid data they wish to consider when generating the contours.
Custom Convolution Filter
If you choose to create a new custom filter, or edit an existing custom filter, you will see the dialog below. In this dialog, specify the square kernel size. The kernel values are weights in row-major order, with the center value being the actual pixel at the center.
A value of 0 can be used to ignore a neighbor pixel. If the sum of the weights is 0, then the resulting values will be scaled to the range of the type of the input. Otherwise, the weights are normalized to a sum of 1 so that the output values will be around the same range as the original values.
For grid layers, the computed value will be clipped to the original min/max elevation range.
The new output layer will be snapped to the nearest pixel bounds from the original and created in the same projection as the original layer, creating a 1-to-1 pixel mapping in the specified bounds.