Discrete cosine transform
Express a signal using cosine basis functions with an implicit even boundary extension.
A smooth component and a rapid component are mixed together.
Each coefficient measures agreement with one cosine basis function.
Mint marks the first ten coefficients. Grey coefficients will be discarded in this reconstruction example.
The inverse cosine transform of the retained coefficients preserves broad variation and loses fine oscillation.
Reconstruct with the inverse cosine transform.
Computed 64-sample teaching example, separate from the native OpenCV runtime.
Try it on an image
Experiment at pixel level
Compute the grayscale cosine transform after padding to even dimensions. Preview shows log absolute coefficients, DC at the upper left.
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
Compact smooth image content into a small set of coefficients or study block compression.
How it works
- 01Project samples onto cosine basis functions.
- 02Retain or modify selected frequency coefficients.
- 03Reconstruct with the inverse cosine transform.
samples ↔ weighted cosine basis functions
What to tune
DFT_INVERSE selects reconstruction in dct; check supported dimensions and floating-point depth.
Where it breaks down
Removing high frequencies loses detail; independent block processing can introduce visible block boundaries.
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.