Discrete-Cosine-Transform | Calculates the DCT at different frequencies | Data Manipulation library
kandi X-RAY | Discrete-Cosine-Transform Summary
kandi X-RAY | Discrete-Cosine-Transform Summary
Discrete Cosine Transform Author: Andrew Chalmers, 2014. This calculates the DCT at different frequencies in two dimensions. Some packages don't allow you to specify the basis (u,v), but instead sum across the frequencies giving you the final result. Useful applications for specifying a certain basis can be for educational purposes (visualising the basis functions), or if you need to split the bases into a dictionary for learning. I've left this unoptimised for clarity. Resources: Image and video processing: From Mars to Hollywood with a stop at the hospital, lecture 10. By Guillermo Sapiro from Duke University.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Generate a basis set image
- Convenience function for the DCT function
Discrete-Cosine-Transform Key Features
Discrete-Cosine-Transform Examples and Code Snippets
def dct(input, type=2, n=None, axis=-1, norm=None, name=None): # pylint: disable=redefined-builtin
"""Computes the 1D [Discrete Cosine Transform (DCT)][dct] of `input`.
Types I, II, III and IV are supported.
Type I is implemented using a leng
def mdct(signals, frame_length, window_fn=window_ops.vorbis_window,
pad_end=False, norm=None, name=None):
"""Computes the [Modified Discrete Cosine Transform][mdct] of `signals`.
Implemented with TPU/GPU-compatible ops and supports grad
def idct(input, type=2, n=None, axis=-1, norm=None, name=None): # pylint: disable=redefined-builtin
"""Computes the 1D [Inverse Discrete Cosine Transform (DCT)][idct] of `input`.
Currently Types I, II, III, IV are supported. Type III is the inv
Community Discussions
Trending Discussions on Discrete-Cosine-Transform
QUESTION
I'm trying to make application which compress image from camera. I have mat image and 3 separate arrays for channels. I've found something about discrete cosine transform DCT and read that I should do zigzag algorithm (I've found something with zigzag here).
I understand that DCT makes output array but I can't see if zigzag makes one too and where.
Maybe there is some simple example of zigzag algorithm (or dct with zigzag) with input and output arrays?
ANSWER
Answered 2018-Sep-05 at 23:50Images are from this wikipedia article.
TL,DR: see the bold part below.
Start with a 2D array of pixel values. There are 64 bytes of information.
After applying an offset, and computing the DCT, the output is a 2D array of frequency coefficients. So now there are 64 floating point values.
Here's the key behind how JPEG compression works. The frequency coefficients in the upper left of the array (the low frequencies) are much more important to the image quality than the frequency coefficients in the lower right of the array (the high frequencies).
So the next step is to apply quantization to the array. The quantization allocates a variable number of bits to each value in the array. Values in the upper left get more bits, and values in the lower right get fewer bits. After quantization, the array looks like this.
Notice that many of the values in the lower right are now zero. So finally we get to the zigzag, which looks like this:
The purpose of the zigzag is to convert the 2D array of quantized DCT coefficients into a 1D array, where the first elements come from the upper left, and later elements come from the lower right, of the 2D array. After the zigzag, the array looks like this
QUESTION
I'm trying to find a way to perform a fast 16 point dct2 and dct3 transform.
I found some articles like this one talking about how to do this in mathematical theory, but I'm novice when it comes to reading complex math equations, so honestly I can't understand it.
I searched online for an implementation of a fast 16 point dct, and I found this code generator which outputs code based on your desired DCT parameters.
I asked it to generate a 16 point dct2 and dct3 with double precision, however the outputs were not mirror images as the inputs when ran through both equations. This was my input:
...ANSWER
Answered 2018-Aug-04 at 19:24The link you posted to a 2012 paper (https://arxiv.org/pdf/1203.3442.pdf) seems to describe a rather interesting DCT algorithm: It has low computational complexity (32*17 + 255 multiplies for a 16*16 block and 16*5 + 63 for size 8*8) but also a very regular structure, which makes it easy to synthesise a double-sized variant.
When implementing these things, one should mostly just focus on the butterfly graph: Read from left to right to implement forward (Type II) DCT and from right to left to implement inverse (Type III) DCT. Read text and formulas only when needed to interpret any special symbols in the graph.
That being said, I tried to implement the 8-point DCT II sub-module using the graph from the paper. In this case, the 8 outputs, starting from top, should be re-defined as X0, X4, X2, X6, X1, X3, X5, X7. The first five seem to be within a constant factor of reference DCT output, but I don't seem to get the bottom 3 right.
Here's my code that tries to calculate the 8-point transform:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Discrete-Cosine-Transform
You can use Discrete-Cosine-Transform like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page