添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
发财的充值卡  ·  Array.prototype.find() ...·  1 年前    · 
重感情的围巾  ·  excel vba sendkeys ...·  2 年前    · 
大气的作业本  ·  File ...·  2 年前    · 
Mat img = imread ( "C:/Users/12271/Desktop/test/eren.jpg" ) ; if ( img . empty ( ) == 1 ) { cout << "cannot load the image" << endl ; return - 1 ; Mat img_brighness_high100 , img_brighness_low100 ; img . convertTo ( img_brighness_high100 , - 1 , 1 , 100 ) ; img . convertTo ( img_brighness_low100 , - 1 , 1 , - 100 ) ; string high_img = "brighness high 100" , low_img = "brighness low 100" , original = "original" ; namedWindow ( high_img ) ; namedWindow ( low_img ) ; namedWindow ( original ) ; imshow ( high_img , img_brighness_high100 ) ; imshow ( low_img , img_brighness_low100 ) ; imshow ( original , img ) ; waitKey ( 0 ) ; destroyAllWindows ( ) ;

2. 视频

更改视频亮度时要将新建数组放在while循环内,每帧都要创建一个新数组用来存放更改亮度后的图片。

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
	VideoCapture cap(0);
	if (cap.isOpened() == 0) {
		cout << "cannot load the video or webcam" << endl;
		return -1;
	string brighness_high = "+100", brightness_low = "-100", original = "original";
	namedWindow(brighness_high);
	namedWindow(brightness_low);
	namedWindow(original);
	while (1) {
		Mat frame;
		bool is_read = cap.read(frame);
		if (is_read == 0) {
			cout << "this is the end" << endl;
			break;
		Mat brighter, lower;
		frame.convertTo(brighter, -1, 1, 100);
		frame.convertTo(lower, -1, 1, -100);
		imshow(brighness_high, brighter);
		imshow(brightness_low, lower);
		imshow(original, frame);
		if (waitKey(10) == 27) {
			break;
	return 0;

3. 改变对比度

		frame.convertTo(brighter, -1, 2, 0);
 

参数分别为:void Mat::convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const
m 输出图片,发起请求时将原图片数据重新分配到该数组内存中。
rtype 输出图片的格式,值为负数时,输出格式将和输入图片格式保持一致。
alpha 输出前数组中的每个像素都将与该数相乘。
beta 输出前数组中每个像素都与该数相加

改变方法中第三个参数的值即可,alpha>1,对比度增强,0 < alpha < 1, 对比度减弱

二、高斯模糊

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
	VideoCapture cap(0);
	if (cap.isOpened() == 0) {
		cout << "cannot load the video or webcam" << endl;
		return -1;
	string gauss = "gauss", original = "original";
	namedWindow(gauss);
	namedWindow(original);
	while (1) {
		Mat frame;
		bool is_read = cap.read(frame);
		if (is_read == 0) {
			cout << "this is the end" << endl;
			break;
		Mat gaussfiler;
		GaussianBlur(frame, gaussfiler, Size(3, 3), 0);
		imshow(gauss, gaussfiler);
		imshow(original, frame);
		if (waitKey(10) == 27) {
			break;
	return 0;

三、图像腐蚀

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
	VideoCapture cap(0);
	if (cap.isOpened() == 0) {
		cout << "cannot load the video or webcam" << endl;
		return -1;
	string erode_win = "erosion", original = "original";
	namedWindow(erode_win);
	namedWindow(original);
	while (1) {
		Mat frame;
		bool is_read = cap.read(frame);
		if (is_read == 0) {
			cout << "this is the end" << endl;
			break;
		Mat erosion_img;
		erode(frame, erosion_img, getStructuringElement(MORPH_RECT, Size(5,	5)));
		imshow(erode_win, erosion_img);
		imshow(original, frame);
		if (waitKey(10) == 27) {
			break;
	return 0;

卡姿兰大眼睛

四、图像膨胀

太丑了,卧槽
在这里插入图片描述

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main() {
	VideoCapture cap(0);
	if (cap.isOpened() == 0) {
		cout << "cannot load the video or webcam" << endl;
		return -1;
	string dilate_win = "dilate img", original = "original";
	namedWindow(dilate_win);
	namedWindow(original);
	while (1) {
		Mat frame;
		bool is_read = cap.read(frame);
		if (is_read == 0) {
			cout << "this is the end" << endl;
			break;
		Mat dilate_img;
		dilate(frame, dilate_img, getStructuringElement(MORPH_RECT, Size(5,	5)));
		imshow(dilate_win, dilate_img);
		imshow(original, frame);
		if (waitKey(10) == 27) {
			break;
	return 0;

好像没啥总结,溜了。

OpenCV C++ 改变图片亮度、对比度目录OpenCV C++ 改变图片亮度、对比度一、改变图片视频亮度1. 图片2. 视频3. 改变对比度二、高斯模糊三、图像腐蚀四、图像膨胀总结一、改变图片视频亮度1. 图片#include &lt;iostream&gt;#include &lt;opencv2/opencv.hpp&gt;using namespace std;using namespace cv;int main() { Mat img = imread("C:/Use cols = len(imgArray[0]) rowsAvailable = isinstance(imgArray[0], list) width = imgArray[0][0].shape[1] height = imgArray[0][0].shape[0] 本篇是最近碰到的一个关于雾天能见度的问题,然后查阅到很多资料,顺便记录一下思考过程,进行总结归类成笔记。主要参考资料是华为杯2020年E题论文,结合一下自己的实际情况,做出了改进与延伸,文献在最后引出。 相关定义说明 能见度定义: 1. 大气能见度: 能见度是气象、公路行车、飞机飞行中常见指标,单位通常是米。在气象上的能见度定义为:标准视力眼睛观察到水平方向以天空为背景的黑体目标物(0.50)标注为你轮廓的最大水平距离。 2. 雾: 在水汽充足、微风及大气稳定的情况下,相对湿度达到100%时,空气中的
@OpenCv下图片的展示 欢迎使用Markdown编辑器 你好! 这是你第一次使用 Markdown编辑器 所展示的欢迎页。如果你想学习如何使用Markdown编辑器, 可以仔细阅读这篇文章,了解一下Markdown的基本语法知识。 新的改变 我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客: 全新的界面设计 ,将会带来全新的写作体验; 在创作中心设置你喜爱的代码高亮样式,Markdown 将代码片显示选择的高亮样
而当我们只对图片做缩放(为了跑得快),然后用bgr通道出直方图算相似度时: 却发现,只有第一张和第二张图片的相似度是大于0.5的,而第二、三张,以及第三、四张图片之间的相似度几乎都小于等于0.1。 于是,经过思考后我觉得,判断两张图片在颜色上相不相似,其本质在于判断其直方图分布的形状相不相似,而不应该考虑是 def mousePoints(event,x,y,flags,params): if event == cv2.EVENT_LBUTTONDOWN: size = len(pointsList) if size != 0 and size % 3