Custom correlation kernels
Apply your own linear filter to every pixel neighbourhood.
The same scene stays here while the working view changes.
The orange 3 × 3 window surrounds one output location. This example uses a sharpening kernel. Positive and negative weights emphasize local contrast.
This example uses a sharpening kernel. Positive and negative weights emphasize local contrast. One output value is 232.3; the window then moves across the image.
The whole image has now been processed. The highlighted input value 156 becomes 232.3.
Add the products and delta, then convert to the output depth.
Computed teaching example on a 24 × 16 image. Small kernels and simplified settings keep each change visible; use the image laboratory for native OpenCV.
Try it on an image
Experiment at pixel level
Correlate grayscale pixels with a custom square kernel. Display shows absolute response; inspect signed native values below.
The engine loads on your first run. Your images stay in this browser.
Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.
Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Select a pixel
Select a pixel
When to use it
Build sharpening, derivative, embossing, or application-specific linear filters.
How it works
- 01Align the kernel anchor with the output pixel.
- 02Multiply kernel coefficients and matching input samples.
- 03Add the products and delta, then convert to the output depth.
dst(x,y) = Σ kernel(i,j) · src(x+i−ax,y+j−ay) + delta
What to tune
Use float or signed output for negative responses. A separable kernel can run as a horizontal pass followed by a vertical pass.
Where it breaks down
filter2D computes correlation: it does not flip the kernel. Flip the kernel and adjust the anchor when true convolution is required.
TypeScript API
Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.
All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.
Related methods
Gaussian blur
Replace each pixel with a weighted average that gives nearby pixels more influence.
Box filtering
Average a rectangular neighbourhood with equal weight at every position.
Median filtering
Choose the middle value of a pixel neighbourhood instead of averaging its intensities.
Bilateral filtering
Smooth nearby pixels only when their colours are also similar.