计算机视觉_OpenCV开源库讲解(第二节:图像的算术操作)

图像的算术操作:
1、加:add(src1, src2, dst);

2、减:subtract(src1, src2, dst);

3、乘:multiply(src1, src2, dst);

4、除:divide(src1, src2, dst);

#include “opencv2\opencv.hpp”
#include

using namespace std;
using namespace cv;

int main(int argv, char** argc)
{
Mat src1 = imread(“xxx”);
Mat src2 = imread(“xxxx”);

if (src1.empty()||src2.empty())
{
    printf("Could not load image src1 or src2...\n");
    return -1;
}
Mat addResult = Mat::zeros(src1.size(), src1.type());
add(src1, src2, addResult);
imshow("addResult", addResult);

Mat subResult = Mat::zeros(src1.size(), src1.type());
subtract(src1, src2, subResult);
imshow("subResult", subResult);

Mat mulResult = Mat::zeros(src1.size(), src1.type());
multiply(src1, src2, mulResult);
imshow("mulResult", mulResult);

Mat divResult = Mat::zeros(src1.size(), src1.type());
divide(src1, src2, divResult);
imshow("divResult", divResult);

int b1 = 0, g1 = 0, r1 = 0;
int b2 = 0, g2 = 0, r2 = 0;
int b = 0, g = 0, r = 0;
int height = src1.rows;
int width = src1.cols;

Mat result = Mat::zeros(src1.size(), src1.type());
for (int row = 0; row < height; row++){
    for (int col = 0; col < width; col++) {
        b1 = src1.at<Vec3b>(row, col)[0];
        g1 = src1.at<Vec3b>(row, col)[1];
        r1 = src1.at<Vec3b>(row, col)[2];

        b2 = src2.at<Vec3b>(row, col)[0];
        g2 = src2.at<Vec3b>(row, col)[1];
        r2 = src2.at<Vec3b>(row, col)[2];
        result .at<Vec3b>(row, col)[0] = saturate_cast<uchar>(b1 * b2);
        result .at<Vec3b>(row, col)[1] = saturate_cast<uchar>(g1 * g2);
        result .at<Vec3b>(row, col)[2] = saturate_cast<uchar>(r1 * r2);
    }
}
imshow("saturateResult", saturateResult);

waitKey(0);
return 0;

}

相关推荐
<p> <strong><span style="font-size:20px;color:#FF0000;">本课程主要针对计算机相关专业正在做毕设学生与需要项目实战练习Java学习者</span></strong> </p> <p> <span style="color:#FF0000;"><strong><span style="font-size:18px;">1. 包含<span style="color:#FFFF00;background-color:#FF0000;">项目源码、</span><span style="color:#FFFF00;background-color:#FF0000;">项目文档、数据脚本、软件工具</span>等所有资料</span></strong></span> </p> <p> <span style="color:#FF0000;"><strong><span style="font-size:18px;">2. 手把手带你从零开始部署运行本套系统</span></strong></span> </p> <p> <span style="color:#FF0000;"><strong><span style="font-size:18px;">3. 该项目附带源码资料可作为毕设使用</span></strong></span> </p> <p> <span style="color:#FF0000;"><strong><span style="font-size:18px;">4. 提供技术答疑和远程协助指导</span></strong></span><strong><span style="font-size:18px;"></span></strong> </p> <p> <br /> </p> <p> <span style="font-size:18px;"><strong>项目运行截图</strong></span> </p> <p> <strong><span style="font-size:18px;">1系统登陆界面</span></strong> </p> <p> <strong><span style="font-size:18px;"><img src="https://img-bss.csdn.net/202002241015433522.png" alt="" /><br /> </span></strong> </p> <p> <strong><span style="font-size:18px;"><strong><span style="font-size:18px;">2学生模块</span></strong></span></strong> </p> <p> <strong><span style="font-size:18px;"><img src="https://img-bss.csdn.net/202002241015575966.png" alt="" /></span></strong> </p> <p> <strong><span style="font-size:18px;"><strong><span style="font-size:18px;">3教师模块</span></strong></span></strong> </p> <p> <strong><span style="font-size:18px;"><img src="https://img-bss.csdn.net/202002241016127898.png" alt="" /></span></strong> </p> <p> <strong><span style="font-size:18px;"><strong><span style="font-size:18px;">4系统管理员</span></strong></span></strong> </p> <p> <strong><span style="font-size:18px;"><img src="https://img-bss.csdn.net/202002241016281177.png" alt="" /></span></strong> </p> <p> <strong><span style="font-size:18px;"><img src="https://img-bss.csdn.net/202002241016369884.png" alt="" /></span></strong> </p> <p> <strong><span style="font-size:18px;"><br /> </span></strong> </p> <p> <strong><span style="font-size:18px;"><strong><span style="font-size:18px;">更多Java毕设项目请关注我毕设系列课程 <a href="https://edu.csdn.net/lecturer/2104">https://edu.csdn.net/lecturer/2104</a></span></strong></span></strong> </p> <p> <strong><span style="font-size:18px;"><br /> </span></strong> </p>
<p> 课程演示环境Windows10  </p> <p> 需要学习<span>Ubuntus</span>系统<span>YOLOv4-tiny</span>同学请前往《<span>YOLOv4-tiny</span>目标检测实战训练自己数据集》 <span></span> </p> <p> <span> </span> </p> <p> <span style="color:#E53333;">YOLOv4-tiny</span><span style="color:#E53333;">来了!速度大幅提升!</span><span></span> </p> <p> <span> </span> </p> <p> <span>YOLOv4-tiny</span>在<span>COCO</span>上性能可达到<span>40.2% AP50, 371 FPS (GTX 1080 Ti)</span>。相较于<span>YOLOv3-tiny</span>,<span>AP</span>和<span>FPS</span>性能有巨大提升。并且,<span>YOLOv4-tiny</span>权重文件只有<span>23MB</span>,适合在移动端、嵌入式设备、边缘计算设备上部署。<span></span> </p> <p> <span> </span> </p> <p> 本课程将手把手地教大家使用<span>labelImg</span>标注和使用<span>YOLOv4-tiny</span>训练自己数据集。课程实战分为两个项目单目标检测足球目标检测和多目标检测足球和梅西同时检测。<span></span> </p> <p> <span> </span> </p> <p> 本课程<span>YOLOv4-tiny</span>使用<span>AlexAB/darknet</span>,在<span>Windows10</span>系统上做项目演示。包括<span>YOLOv4-tiny</span>网络结构、安装<span>YOLOv4-tiny</span>、标注自己数据集、整理自己数据集、修改配置文件、训练自己数据集、测试训练出网络模型、性能统计<span>(mAP</span>计算<span>)</span>和先验框聚类分析。 <span> </span> </p> <p> <span> </span> </p> <p> 除本课程《<span>Windows</span>版<span>YOLOv4-tiny</span>目标检测实战训练自己数据集》外,本人推出了有关<span>YOLOv4</span>目标检测系列课程。请持续关注该系列其它视频课程,包括<span></span> </p> <p> 《<span>Windows</span>版<span>YOLOv4</span>目标检测实战训练自己数据集》<span></span> </p> <p> 《<span>Windows</span>版<span>YOLOv4</span>目标检测实战人脸口罩佩戴识别》<span></span> </p> <p> 《<span>Windows</span>版<span>YOLOv4</span>目标检测实战中国交通标志识别》<span></span> </p> <p> 《<span>Windows</span>版<span>YOLOv4</span>目标检测原理与源码解析》<span></span> </p> <p> <span> <img alt="" src="https://img-bss.csdnimg.cn/202007061503586145.jpg" /></span> </p> <p> <span><img alt="" src="https://img-bss.csdnimg.cn/202007061504169339.jpg" /><br /> </span> </p>
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页