Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 对图像应用离散余弦变换_Python_Image Processing_Signal Processing_Dft_Dct - Fatal编程技术网

Python 对图像应用离散余弦变换

Python 对图像应用离散余弦变换,python,image-processing,signal-processing,dft,dct,Python,Image Processing,Signal Processing,Dft,Dct,我想对我的图像应用离散余弦变换 import os.path from PIL import Image if __name__ == '__main__': image_counter = 1 while True: if not os.path.isfile('noise_images/' + str (image_counter) + '.png'): break print(image_counter) noise_ima

我想对我的图像应用离散余弦变换

import os.path
from PIL import Image

if __name__ == '__main__':
    image_counter = 1  
while True:      
    if not os.path.isfile('noise_images/' + str (image_counter) + '.png'):
        break
    print(image_counter)
    noise_image_path = 'noise_images/' + str(image_counter) + '.png'
    noise_image = Image.open(noise_image_path)  
    # Apply DCT to an image.

    image_counter = image_counter + 1
看看这个

以下是使用此功能的示例代码:

import cv2
from scipy.fftpack import dct

def dct2(block):
    return dct(dct(block.T, norm='ortho').T, norm='ortho')

img = cv2.imread(filename)
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
dctImage = dct2(img.astype(float))

您可以使用
scipy.fftpack.dct
。更多细节