Ошибка при вызове CLAHE Opencv
подскажите, как заставить работать CLAHE apply
#include <opencv2/core/core.hpp>
#include "opencv2/imgcodecs.hpp"
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv\cv.h>
#include <opencv2\opencv.hpp>
#include <math.h>
#include <time.h>
#include <chrono>
#include <iostream>
#include <iostream>
using namespace std;
using namespace cv;
cv::Mat mkKernel(int ks, double sig, double th, double lm, double ps)
{
int hks = (ks - 1) / 2;
double theta = th * CV_PI / 180;
double psi = ps * CV_PI / 180;
double del = 2.0 / (ks - 1);
double lmbd = lm;
double sigma = sig / ks;
double x_theta;
double y_theta;
cv::Mat kernel(ks, ks, CV_32F);
// задали область определения
for (int y = -hks; y <= hks; y++)
{
for (int x = -hks; x <= hks; x++)
{
// поворот
x_theta = x * del * cos(theta) + y * del * sin(theta);
y_theta = -x * del * sin(theta) + y * del * cos(theta);
// ядро
kernel.at<float>(hks + y, hks + x) = (float)exp(-0.5 * (pow(x_theta, 2) + pow(y_theta, 2)) / pow(sigma, 2)) * cos(2 * CV_PI * x_theta / lmbd + psi);
}
}
return kernel;
}
int kernel_size = 21;
int pos_sigma = 3;
int pos_lm = 50;
int pos_th = 0;
int pos_psi = 90;
Mat src_f;
Mat dest;
Mat dst;
class Timer
{
private:
// Псевдонимы типов используются для удобного доступа к вложенным типам
using clock_t = std::chrono::high_resolution_clock;
using second_t = std::chrono::duration<double, std::ratio<1> >;
std::chrono::time_point<clock_t> m_beg;
public:
Timer() : m_beg(clock_t::now())
{
}
void reset()
{
m_beg = clock_t::now();
}
double elapsed() const
{
return std::chrono::duration_cast<second_t>(clock_t::now() - m_beg).count();
}
};
void Process(int, void*)
{
double sig = pos_sigma;
double lm = 0.5 + pos_lm / 100.0;
double th = pos_th;
double ps = pos_psi;
Mat kernel = mkKernel(kernel_size, sig, th, lm, ps);
filter2D(src_f, dest, CV_32F, kernel);
imshow("Process window", dest);
Mat Lkernel(kernel_size * 30, kernel_size * 30, CV_32F);
resize(kernel, Lkernel, Lkernel.size());
Lkernel /= 2.;
Lkernel += 0.5;
imshow("Kernel", Lkernel);
normalize(dest, dest, 0, 255, NORM_MINMAX);
dest.convertTo(dst, CV_8U);
imshow("dst", dst);
/* Mat mag;
pow(dest, 2.0, mag);
imshow("Mag", mag);*/
}
int main(int argc, char** argv[])
{
Timer t;
Mat image =imread("unnamed.jpg", CV_8UC1);
Mat dst = Mat(image.size(), image.type());
CLAHE::apply(image, dst);
imshow("Src", image);
imshow("dst", dst);
Mat src;
if (!kernel_size % 2)
{
kernel_size += 1;
}
//cvtColor(image, src, CV_BGR2GRAY);
dst.convertTo(src_f, CV_32F, 1.0 / 255, 0);
namedWindow("Process window", 1);
createTrackbar("Sigma", "Process window", &pos_sigma, kernel_size, Process);
createTrackbar("Lambda", "Process window", &pos_lm, 100, Process);
createTrackbar("Theta", "Process window", &pos_th, 180, Process);
createTrackbar("Psi", "Process window", &pos_psi, 360, Process);
Process(0, 0);
std::cout << t.elapsed() << '\n';
waitKey(0);
return 0;
}

