error: type == CV_32FC1 || type == CV_64FC1 in function 'cv::dct'
时间: 2023-11-01 21:01:31 浏览: 162
This error occurs when using the OpenCV function cv::dct and the input matrix type is not CV_32FC1 or CV_64FC1. The cv::dct function performs a Discrete Cosine Transform on a single-channel floating-point matrix.
To resolve this error, make sure that the input matrix type is either CV_32FC1 or CV_64FC1. You can use the cv::Mat::type() function to check the type of the input matrix. If the input matrix is of a different type, you can convert it to the required type using the cv::Mat::convertTo() function.
Here is an example code snippet that demonstrates how to use cv::dct:
```
cv::Mat input_image = cv::imread("input.jpg", cv::IMREAD_GRAYSCALE);
cv::Mat float_image;
input_image.convertTo(float_image, CV_32FC1);
cv::Mat dct_image;
cv::dct(float_image, dct_image);
```
In this example code, the input image is read in grayscale mode and then converted to a floating-point matrix of type CV_32FC1. The cv::dct function is then called on the float_image to compute the DCT. The resulting DCT coefficients are stored in the dct_image matrix.
阅读全文