我需要比较两个彩色RGB图像,并获得逐像素差异的结果图像。有什么想法我可以在qt中做到吗?
如有任何帮助或建议,我将不胜感激。
最佳答案
这是基于这个QtForum问题的替代方法:
void substract(const QImage &left, const QImage &rigth, QImage &result)
{
int w=min(left.width(), rigth.width());
int h=min(left.height(),rigth.height();
w=min(w, result.width());
h=min(h, result.height();
//<-This ensures that you work only at the intersection of images areas
for(int i=0;i<h;i++){
QRgb *rgbLeft=(QRgb*)left.constScanLine(i);
QRgb *rgbRigth=(QRgb*)rigth.constScanLine(i);
QRgb *rgbResult=(QRgb*)result.constScanLine(i);
for(int j=0;j<w;j++){
rgbResult[j] = rgbLeft[j]-rgbRigth[j];
}
}
}
关于c++ - 如何在Qt中比较两个RGB图像?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43760920/