You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.2 KiB
61 lines
1.2 KiB
#include "avgfilter.h" |
|
#include <QDebug> |
|
|
|
avgfilter::avgfilter(QObject *parent) |
|
: QObject{parent} |
|
{ |
|
thread = new QThread(); |
|
this->moveToThread(thread); |
|
thread->start(); |
|
ready = false; |
|
} |
|
|
|
void avgfilter::setpara(int para) |
|
{ |
|
this->para = para; |
|
if(para!=0){ |
|
on(); |
|
} |
|
else if(para==0){ |
|
off(); |
|
} |
|
qDebug()<<"para = "<<para; |
|
} |
|
|
|
void avgfilter::on() |
|
{ |
|
ready = true; |
|
} |
|
|
|
void avgfilter::off() |
|
{ |
|
ready = false; |
|
} |
|
void avgfilter::slotprocimg(cv::Mat img) |
|
{ |
|
if(ready){ |
|
if(lastmat.empty()){ |
|
img.copyTo(lastmat); |
|
emit signalsendimg(img); |
|
} |
|
else{ |
|
|
|
cv::Mat dst = (256-para)*(img/256)+para*(lastmat/256); |
|
|
|
for(int i = 0;i< img.rows;i++){ |
|
for(int j = 0;j<img.cols;j++){ |
|
if(abs(int(img.at<ushort>(i,j))- int(dst.at<ushort>(i,j)))>(320)) |
|
dst.at<ushort>(i,j) = img.at<ushort>(i,j); |
|
} |
|
} |
|
|
|
dst.copyTo(lastmat); |
|
emit signalsendimg(dst); |
|
} |
|
} |
|
else{ |
|
cv::Mat temp; |
|
img.copyTo(temp); |
|
emit signalsendimg(temp); |
|
} |
|
}
|
|
|