我正在使用图像比率和Otsu阈值法在两个图像之间执行变化检测。
代码的最后一行给出了错误。在import cv2
import numpy as np
image1 = cv2.imread( 'E:\\alada.jpg', 0 )
image2 = cv2.imread( 'E:\\alada2.jpg', 0 )
dest = 'E:\\Ratio\\'
print image1.shape
image1 = cv2.resize( image1, ( 300, 200 ) )
image2 = cv2.resize( image2, ( 300, 200 ) )
img1 = image1.ravel()
img2 = image2.ravel()
sd1 = np.std( img1 )
sd2 = np.std( img2 )
img2 = ( ( img2 - np.mean( img2 ) ) * sd1 / sd2 ) + np.mean( img1 )
ratio = img1 / img2
ratio = np.arctan( ratio ) - np.pi / 4
ratio = np.reshape( ratio, ( image1.shape[0], image1.shape[1] ) )
print ratio.shape
thresh, th2 = cv2.threshold( ratio, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU )
error: ..\..\..\..\opencv\modules\imgproc\src\thresh.cpp:718: error: (-215)
src.type() == CV_8UC1 in function cv::threshold
有什么帮助吗?在