域名备案个人网站名称,建设网站坪山,网上商城开发网站建设,邓州市网站建设1.介绍 反色的实际含义是将R、G、B值反转。如果颜色的范围为0-255之间#xff0c;则新图的R、G、B值为255减去原图的R、G、B值。其公式为#xff1a; R_new 255 - R_old G_new 255 - G_old B_new 255 - B_old 2.代码实现#xff08;代码是我以前自学图像处理时写的则新图的R、G、B值为255减去原图的R、G、B值。其公式为 R_new 255 - R_old G_new 255 - G_old B_new 255 - B_old 2.代码实现代码是我以前自学图像处理时写的代码很粗糙没做任何优化但很好理解
/*反色操作*/
QImage* MainWindow::inverseColor(QImage* origiin)
{QImage* newImage new QImage(origiin-width(), origiin-height(), QImage::Format_ARGB32);QColor oldColor;int r 0;int g 0;int b 0;for(int y 0; y newImage-height(); y){for(int x 0; x newImage-width(); x){oldColor QColor(origiin-pixel(x,y));r 255 - oldColor.red();g 255 - oldColor.green();b 255 - oldColor.blue();newImage-setPixel(x, y, qRgb(r, g, b));}}return newImage;
} opencv对二值图片进行反色操作输入和输出都是二值化图片代码如下
bitwise_not(singleROI,singleROI);//颜色反转
3.参考资料 数字图像处理——技术详解与Visual C实践左飞等著写代码与写博客的时间相差两年至于还参考其他的资料不我已经忘记了如若需要我可以补上去