图像加载函数
int base::loadImg( Mat &mat, QLabel* labelImage )
{
cvtColor(mat, mat, CV_BGR2RGB);
QImage::Format imgFormat = (mat.channels() == 3) ? QImage::Format_RGB888:QImage::Format_Indexed8;
QImage image((const uchar*)(mat.data), mat.cols, mat.rows, mat.cols*mat.channels(), imgFormat);
labelImage->setPixmap(QPixmap::fromImage(image));
labelImage->resize(labelImage->pixmap()->size());
return 0;
}
图像的线性融合
int base::mixImg( string strFilePath, string strTempFilePath, QLabel* labelImage)
{
Mat matSource = imread(strFilePath);
if (!matSource.data)
{
return(-1);
}
Mat matTemp = imread(strTempFilePath);
if (!matTemp.data)
{
return(-1);
}
Mat roi = matSource(Rect(0, 0, matTemp.cols, matTemp.rows));
//g(x) = af(x) + (1-a)f(y) + m
addWeighted(roi, 0.9, matTemp, 0.1, 0.0, roi);
loadImg(matSource, labelImage);
}