我正在尝试拍摄图像的dct。起初我得到了错误
未在dct中实现功能/功能(未实施奇数DCT)
所以我用零填充图像使其大小均匀
但现在我收到了错误:
dct中的断言失败(类型== CV_32FC1 || type == CV_64FC1)
我该如何解决这个问题?以下是我在python中所做的事情
foo
答案 0 :(得分:1)
import cv2
import numpy as np
img = cv2.imread('imgColor.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret,thresholded = cv2.threshold(gray,200,255,cv2.THRESH_BINARY)
img = cv2.cvtColor(thresholded, cv2.COLOR_GRAY2BGR)
gray = thresholded
gray = np.float32(gray)/255.0
dct=cv2.dct(gray)
#padding
# BLUE = [255,0,0]
# rows,cols = gray.shape
# nrows = cv2.getOptimalDFTSize(rows)
# ncols = cv2.getOptimalDFTSize(cols)
# right = ncols - cols
# bottom = nrows - rows
# bordertype = cv2.BORDER_CONSTANT
# gray = cv2.copyMakeBorder(img,0,bottom,0,right,bordertype, value = 0)
# gray = np.float32(gray)/255.0
# dct=cv2.dct(gray)
这对我有用!找到了这个here