Sobel derivatives
Measure image change along x or y while smoothing in the perpendicular direction.
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.
Keep the signed response or combine x and y magnitudes.
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
Signed grayscale derivative. The preview displays absolute magnitude; native samples preserve the sign.
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
Estimate edge strength and orientation, normals, or inputs to gradient-based feature methods.
How it works
- 01Smooth across the direction perpendicular to the derivative.
- 02Subtract weighted samples on opposite sides.
- 03Keep the signed response or combine x and y magnitudes.
|∇I| = √(Ix² + Iy²)
What to tune
dx and dy choose derivative orders; ksize changes support; scale keeps magnitudes comparable across kernels.
Where it breaks down
An unsigned output clips negative derivatives. Convert to a signed or floating matrix before interpreting direction.
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.