I want to apply a Discrete Cosine Transform (as well as the inverse) to an image in Python and I'm wondering what is the best way to do it and how. I've looked at PIL and OpenCV but I still don't understand how to use it.
我想对Python中的图像应用离散余弦变换(以及反余弦变换),我想知道最好的方法是什么以及如何去做。我看了PIL和OpenCV,但是我还是不明白怎么用它。
1 个解决方案
#1
8
From OpenCV:
从OpenCV:
DCT(src, dst, flags) → None Performs a forward or inverse Discrete Cosine transform of a 1D or 2D floating-point array. Parameters: src (CvArr) – Source array, real 1D or 2D array dst (CvArr) – Destination array of the same size and same type as the source flags (int) – Transformation flags, a combination of the following values CV_DXT_FORWARD do a forward 1D or 2D transform. CV_DXT_INVERSE do an inverse 1D or 2D transform. CV_DXT_ROWS do a forward or inverse transform of every individual row of the input matrix. This flag allows user to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself), to do 3D and higher-dimensional transforms and so forth.
Here is an example of it being used.
这里有一个使用它的例子。
The DCT is also available in scipy.fftpack.
DCT也可以在scipy.fftpack中使用。
#1
8
From OpenCV:
从OpenCV:
DCT(src, dst, flags) → None Performs a forward or inverse Discrete Cosine transform of a 1D or 2D floating-point array. Parameters: src (CvArr) – Source array, real 1D or 2D array dst (CvArr) – Destination array of the same size and same type as the source flags (int) – Transformation flags, a combination of the following values CV_DXT_FORWARD do a forward 1D or 2D transform. CV_DXT_INVERSE do an inverse 1D or 2D transform. CV_DXT_ROWS do a forward or inverse transform of every individual row of the input matrix. This flag allows user to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself), to do 3D and higher-dimensional transforms and so forth.
Here is an example of it being used.
这里有一个使用它的例子。
The DCT is also available in scipy.fftpack.
DCT也可以在scipy.fftpack中使用。