8

私はPythonの画像に離散コサイン変換(逆も同様)を適用したいと思います。私はそれを行う最良の方法と方法を知りたいと思います。私はPILとOpenCVを見てきましたが、私はそれを使う方法はまだ分かりません。 OpenCVからPythonでイメージにDCTを適用するにはどうすればよいですか?

+0

PILとOpenCVについて正確にはわかりませんが、DCTと逆DCTの両方を適用すると、基本的にソースブロックに関連する変換行列が乗算されます。 – agibalov

答えて

7

 
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

DCTはscipy.fftpackでも利用できます。

+0

その使い方を表示するための基本的なプログラムを提供できますか? Pythonは私の宛先配列が空であると不平を言うようです。 – jmnwong

+0

正しいサイズになるように出力先配列を変更しましたか? – agf

+0

私がやったことは、PILを使って入力イメージのサイズを変更した後、cv.CreateImageHeaderを使ってソースと空の出力先配列を作成することです。これが正しいかどうかはわかりません。 – jmnwong

関連する問題