#include "clhe.h" #include clhe::clhe(QObject *parent) : QObject{parent} { thread = new QThread(); thread->start(); this->moveToThread(thread); hist = (int*)malloc(sizeof(int)*16384); HIST = (int*)malloc(sizeof(int)*16384); ready = false; } void clhe::setthreshold(int threshold) { this->threshold = threshold; ready = true; } void clhe::off() { ready = false; } void clhe::slotprocimg(cv::Mat img) { if(ready){ cv::Mat dst(img.rows,img.cols,CV_16UC1); memset(hist,0,sizeof(int)*16384); for(int i = 0;i(i,j)/4]+=1; } } HIST[0] = hist[0]>threshold?threshold:hist[0]; for(int i =1;i<16384;i++){ HIST[i] = HIST[i-1]+ (hist[i]>threshold?threshold:hist[i]); } double sub = double(img.rows*img.cols - HIST[16383])/16384; for (int i = 0; i < 16384; ++i) { HIST[i] += sub*(i+1); } for(int i = 0;i(i,j) = HIST[img.at(i,j)/4]/double(HIST[16383])*65535; } } emit(signalsendimg(dst)); } else{ cv::Mat temp; img.copyTo(temp); emit(signalsendimg(temp)); } }