当前位置:网站首页>OpenCV中的saturate操作(饱和操作)究竟是怎么回事
OpenCV中的saturate操作(饱和操作)究竟是怎么回事
2022-06-13 04:54:00 【昊虹图像算法】
OpenCV中的saturate操作(饱和操作)究竟是怎么回事?
用两个实际例子试一下就知道了。
我们用CV_8U类型来试下,CV_8U的范围为0~255
第一个例子:
//OpenCV版本:3.0.0
//VS版本:2013
//博主微信/QQ 2487872782
//有问题可以联系博主交流
//有图像处理开发需求也请联系博主
//图像处理技术交流QQ群 271891601
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
int main()
{
cv::Mat A1(2, 3, CV_8UC1, cv::Scalar(254));
cout << "A1中的数据为:\n" << A1 << endl << endl;
cv::Mat B1(2, 3, CV_8UC1, cv::Scalar(2));
cout << "B1中的数据为:\n" << B1 << endl << endl;
cv::Mat C1;
cv::add(A1, B1, C1);
cout << "C1中的数据为:\n" << C1 << endl << endl;
return(0);
}
运行结果如下:
按道理,结果应该是256,但因为输出矩阵的类型也为CV_8U,而CV_8U的范围为0~255,所以值被置为了255。
第二个例子:
//OpenCV版本:3.0.0
//VS版本:2013
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace std;
int main()
{
cv::Mat A1(2, 3, CV_8UC1, cv::Scalar(254));
cout << "A1中的数据为:\n" << A1 << endl << endl;
cv::Mat B1(2, 3, CV_8UC1, cv::Scalar(2));
cout << "B1中的数据为:\n" << B1 << endl << endl;
cv::Mat C1;
cv::subtract(B1, A1, C1);
cout << "C1中的数据为:\n" << C1 << endl << endl;
return(0);
}
运行结果如下:
按道理,结果应该是-252,但因为输出矩阵的类型也为CV_8U,而CV_8U的范围为0~255,所以值被置为了0。
通过这两个例子,大家就应该理解知道了OpenCV中的saturate操作(饱和操作)究竟是怎么回事了吧。
边栏推荐
- Internet people a few years ago vs Internet people today
- Explain the role of key attribute in V-for
- Kaggle time series tutorial
- Win8.1和Win10各自的优势
- Your one-on-one meetings are inefficient. You can do this!
- rust编程-链表:使用struct实现链表,使用堆合并k个升序链表,自定义Display
- On switch() case statement in C language
- Infinite cycle scrolling code Alibaba international station store decoration code base map scrolling black translucent display effect custom content decoration code full screen display
- Brick story
- 推荐的图片临时在线压缩工具
猜你喜欢

无限循环滚动代码阿里巴巴国际站店铺装修代码底图滚动黑色半透明显示效果自定义内容装修代码全屏显示

Powershell 加域 Add-Computer模块

About mission planning and improving execution

Bomb disposal cat

CMB written test graphical reasoning

Section 2 - branch and loop statements

2021tami/ image processing: exploiting deep generative priority for versatile image restoration and manipulation

利用Javeswingjdbc基于mvc设计系统

正态分布(高斯分布)

Embedded hardware - read schematic
随机推荐
使用Service Worker优选请求资源 - 持续更新
rainbow
Advanced C - Section 2 - pointers
Crawler scrapy framework learning 1
The differences between the four startup modes of activity and the applicable scenarios and the setting methods of the two startup modes
Go scheduled task cron package usage
Conception d'un système basé sur MVC avec javaswing JDBC
LeetCode第297场周赛(20220612)
[JS solution] leedcode 200 Number of islands
Test question bank and online simulation test for special operation certificate of construction scaffolder (special type of construction work) in 2022
Vercel 使用 HTTP 缓存
Kaggle 时间序列教程
Construction problem of D Xiaohong
Chinese trumpet creeper
NodeJS 解析 GET 请求 url 字符串
How to use redis
C language exercise 1
Develop go using vscode
Promise processing JS multithreads get the same processing result after all the results are obtained
Red Treasure Book Reading Notes (continuously updated)