O'Reilly logo

Mastering OpenLayers 3 by Gábor Farkas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a convolution matrix

In the next example, called ch07_convolution, we will implement a control, which can apply a filter on a single image. We will hardcode a Sobel filter for this example; however, based on the implementation, you will be able to use any kind of filter, even dynamically. Our implementation will have three stages:

  • Converting the image to grayscale
  • Applying the Sobel filter
  • Normalizing the image

How convolution works

Before creating the control, let's discuss how convolution works in a nutshell. When we convolve an image, we calculate some sort of statistics from the image matrix that is based on every pixel's (or raster's) neighborhood. This is why this method is also referred to as focal statistics or a moving window in geoinformatics. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required