Convolution Matrix

Blur, sharpen, emboss or detect the edges of an image with a ready-made or a custom kernel.

This free online tool applies a convolution matrix to images. Choose one of the ready-made kernels, such as gaussian blur, sharpen, edge detection, Sobel or emboss, or type your own weights in a 3×3, 5×5 or 7×7 matrix, and download the result as a PNG image.

A convolution matrix, also known as a kernel, mask or convolution filter, is a small grid of numbers that tells how each pixel is mixed with its neighbors. It is the basis of most image filters of photo editors, and of the convolutional neural networks used in computer vision. The tool shows the result as you type, which makes it a good way to learn how kernels work.

Everything runs directly in your browser. No image is uploaded to a server, and nothing needs to be installed.

Drop your image here
You can also paste an image with Ctrl+V.

How to apply a convolution matrix to an image?

  1. Upload your image - Drop a JPG, PNG or WebP image in the box above, or paste an image with Ctrl+V.
  2. Choose a preset - Start from one of the ready-made kernels: blurs, sharpen, edge detection, Sobel or emboss. The result appears immediately.
  3. Edit the matrix - Change any weight to create your own filter, or choose a bigger kernel size for wider effects. Use the divisor, or click "Normalize", to keep the brightness of the image.
  4. Fine-tune the result - Repeat the filter with the iterations, soften it with the strength, convert the image to grayscale or invert the colors.
  5. Download the image - Click "Download image" to save the result as a PNG.

Options

FieldDescription
PresetA ready-made kernel, with its size, weights, divisor, offset and absolute value. It becomes "Custom" as soon as you change any of them.
Kernel sizeThe size of the matrix: 3×3, 5×5 or 7×7. Bigger kernels reach pixels further away, for stronger blurs and thicker edges. When the size changes, the current weights stay in the center.
MatrixThe weights of the kernel. The center weight is applied to the pixel itself, and the others to the neighbors in the same position around it. Weights can be negative and decimal.
DivisorThe weighted sum is divided by this number. It lets you type whole numbers in the matrix: a box blur is nine 1s with a divisor of 9, instead of nine 0.111s. A divisor of 0 is treated as 1.
NormalizeSets the divisor to the sum of the weights, so the brightness of the image is kept. When the weights add up to zero, as in edge detection and emboss kernels, it sets the divisor to 1 and the offset to 128 instead.
OffsetA value added to every color, from -255 to 255, after the division. An offset of 128 turns the flat areas gray and shows negative results as dark tones, which is how the gray relief emboss works.
Absolute valueTurns negative results into positive ones before the offset is added. Edge detection kernels such as Sobel give positive values on one side of an edge and negative values on the other; with the absolute value both sides are visible.
Edges What the kernel reads when it goes past the borders of the image.
EdgesDescription
ExtendRepeats the pixels of the border. The default, and the best choice for photos.
MirrorReflects the image at its borders.
Wrap aroundReads the opposite side of the image, as if it was repeated like a tile. Keeps seamless textures seamless.
TransparentTreats everything outside the image as transparent. With "Filter transparency" turned on, blurs fade the borders of the image out.
IterationsHow many times the filter is applied, from 1 to 20, each time on the result of the previous one. Repeating a 3×3 blur a few times gives a smooth, strong blur.
StrengthMixes the result with the original image, from 0% (the original image) to 100% (the full effect). Useful to apply a subtle sharpen or emboss.
GrayscaleConverts the image to shades of gray before filtering. Edge detection then gives white edges instead of colored ones.
Invert colorsInverts the colors of the result. Combined with edge detection, it turns the image into dark lines on a white background, like a pencil drawing.
Filter transparencyWhen it is off, the transparency of every pixel is kept, and only the colors are filtered. When it is on, the kernel is also applied to the transparency, so a blur softens the outline of a logo on a transparent background. Leave it off for edge detection, which would make the flat areas transparent.

Presets

PresetKernelDescription
Identity (no change)
000010000
Keeps the image as it is. A good starting point for your own kernel.
Box blur 3×3
111111111
÷ 9
Every pixel becomes the average of itself and its 8 neighbors.
Box blur 5×55×5
÷ 25
The average of a 5×5 square, for a stronger blur.
Gaussian blur 3×3
121242121
÷ 16
A weighted average where the closest pixels count more, which gives a smoother blur than the box blur.
Gaussian blur 5×55×5
÷ 256
A stronger gaussian blur.
Gaussian blur 7×77×7
÷ 4096
The strongest gaussian blur of the list. Apply it several times for even more blur.
Motion blur (horizontal)7×7
÷ 7
The average of 7 pixels on the same row, as if the camera moved sideways.
Sharpen
0-10-15-10-10
Increases the difference between every pixel and its 4 direct neighbors, which makes the details crisper.
Sharpen (strong)
-1-1-1-19-1-1-1-1
Like sharpen, but with the 8 neighbors, for a stronger effect.
Unsharp masking 5×55×5
÷ -256
Sharpens by subtracting a gaussian blur from the image. Softer and with less noise than the 3×3 sharpen.
Edge detection (4 neighbors)
0-10-14-10-10
A Laplacian filter: flat areas become black, and the edges become bright.
Edge detection (8 neighbors)
-1-1-1-18-1-1-1-1
A Laplacian filter that also compares the diagonal neighbors, so it finds more edges. Also known as "outline".
Sobel (horizontal edges)
-1-2-1000121
Finds the horizontal edges, where the image changes from top to bottom.
Sobel (vertical edges)
-101-202-101
Finds the vertical edges, where the image changes from left to right.
Emboss
-2-10-111012
Makes the image look raised, as if it was lit from the bottom right, keeping its colors.
Emboss (gray relief)
-1-10-101011
+ 128
Turns the flat areas gray and keeps only the relief of the edges, like a metal plate. Looks best with "Grayscale" turned on.

How does a convolution matrix work?

The kernel is placed over every pixel of the image, with its center on the pixel. Each weight is multiplied by the pixel below it, and the products are added up. The sum, divided by the divisor and added to the offset, becomes the new value of the pixel. This is done separately for the red, green and blue channels, and always on the original pixels, so the result of one pixel does not affect its neighbors.

For example, the sharpen kernel has a 5 in the center and -1 above, below, to the left and to the right of it. A pixel with a value of 100, surrounded by darker neighbors of 70, 80, 90 and 80, becomes 5 × 100 − 70 − 80 − 90 − 80 = 180: it gets brighter, because it is brighter than its surroundings. In a flat area, where all the pixels are 100, the result is 5 × 100 − 4 × 100 = 100, so nothing changes. That is why sharpening only affects the details and edges.

The sum of the weights tells how the brightness changes. When it is 1 (after the division), flat areas keep their color, as in blurs and sharpening. When it is 0, flat areas become black and only the changes remain, as in edge detection. Results below 0 or above 255 are clipped.

Blurs have only positive weights and average the neighbors. Sharpening and edge detection subtract the neighbors from the pixel. Directional kernels, such as Sobel and emboss, subtract the pixels on one side from the pixels on the other side, so they react to edges in one direction only.

Frequently Asked Questions (FAQ)

Is this convolution matrix tool free to use?

Yes, this tool is 100% free and works directly in your browser, with no installation and no sign-up required.

Are my images uploaded to a server?

No. The filter is calculated by your own browser and the image never leaves your computer.

Why did my image become too bright or too dark?

Because the weights of the kernel do not add up to the divisor. If the sum is 9 and the divisor is 1, every flat area becomes 9 times brighter. Click "Normalize" to set the divisor to the sum of the weights.

Why is the edge detection result almost black?

Edge detection kernels add up to zero, so flat areas become black, and only the edges are bright. Turn on "Invert colors" to get dark lines on white, "Grayscale" to remove the colors of the edges, or use an offset of 128 to see them over gray. For Sobel kernels, "Absolute value" shows the edges on both sides.

How do I get the outline of a logo with a transparent background?

Choose "Edge detection (8 neighbors)" and turn on "Filter transparency". The kernel is then applied to the transparency too, so only a thin outline around the shape stays visible. With "Filter transparency" turned off, the transparent areas have no color, so their border is not treated as an edge.

How do I make a stronger blur?

Choose the gaussian blur 7×7, and increase the iterations. Each iteration blurs the result of the previous one. For blurs with a radius in pixels, see also the Blur Image tool.

Why are there dark or wrong colors along the borders of the image?

The kernel needs pixels beyond the borders of the image. With the default "Extend" edges, the border pixels are repeated and the borders look natural. Choose "Wrap around" only for seamless textures.

Can I use decimal weights, such as 1/9?

Yes, the weights accept decimal and negative numbers. But it is easier and more precise to type whole numbers and use the divisor: nine 1s with a divisor of 9 give the same result as nine weights of 0.111.

Is the transparency of my image preserved?

Yes. The result is a PNG image, and the transparent areas stay transparent. Transparent pixels do not darken the edges of the visible parts. Turn on "Filter transparency" if you want blurs to also soften the outline.

Related tools

Edge Detection

Detect the edges of an image with Canny, Sobel, Laplacian of Gaussian or XDoG, and turn photos into line art.

Blur image online

Apply Gaussian blur filter to images.

Bevel and Emboss

Add 3D depth, raised edges and carved or stamped looks to text, logos and shapes.

Bloom Effect

Apply bloom effect to images to create dreamlike glow or halo of light that bleeds from bright areas into darker regions of the image.

RGB Formula Editor

Edit images using math equations. Transform images by applying custom RGB formulas to each pixel.