Scharr derivatives
Use a specialized 3×3 derivative kernel with improved rotational symmetry.
Flat regions and sharp transitions respond very differently.
The highlighted window straddles an intensity boundary. Flat windows have cancelling contributions.
Mint is positive; violet is negative. Dark pixels have almost no response. Keep a signed matrix depth to preserve both signs.
Magnitude makes transitions visible regardless of sign. Display normalization is applied only to this illustration.
Combine horizontal and vertical responses for edge orientation.
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
A 3 × 3 signed grayscale derivative, displayed as absolute magnitude.
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
Get small-kernel image gradients when orientation accuracy matters.
How it works
- 01Weight the centre row or column more strongly.
- 02Subtract the opposite side to estimate a derivative.
- 03Combine horizontal and vertical responses for edge orientation.
x kernel = [−3,0,3; −10,0,10; −3,0,3]
What to tune
Choose dx=1, dy=0 or dx=0, dy=1 and use signed output. Scale differs from a 3×3 Sobel response.
Where it breaks down
It is still a local derivative and responds to noise. Blur first when the image is noisy.
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.