当前位置:网站首页>opencv的四个函数
opencv的四个函数
2022-07-07 10:33:00 【什么时候上岸?】
正式开始opencv的学习了!
1.imshow
2.imread
3.cvtcolor
4.imwrite
imshow("显示窗口的名字",图像名字);//显示图片
img=imread("图片路径");//读入图片
cvtcolor(待转换的图片名字,转换后储存的图片名字,转换效果);//变换图片,如变灰度图
imwrite("路径",图片名字);//储存图片示例代码:
源文件1
#include<tupian.h>
void demo::color_demo(Mat &image)
{
Mat hsv, gray;
cvtColor(image, hsv, COLOR_BGR2HSV);
cvtColor(image, gray, COLOR_BGR2GRAY);
imshow("灰度", gray);
imshow("HSV", hsv);
imwrite("D:/hsv.png", hsv);
imwrite("D:/gray.png", gray);
}源文件2
#include <iostream>
#include<tupian.h>
#include<opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc,char** argv)
{
Mat img;
img = imread("C:/Users/guoyongbin123/Desktop/C++/opencv4/opencv4/Lena.png");//图片路径
if (img.empty())
{
cout << "请确认图像文件名称是否正确" << endl;
return -1;
}
//Mat img1;
namedWindow("test", WINDOW_FREERATIO);
imshow("test", img);
demo me;
me.color_demo(img);
waitKey(0);
return 0;
}
头文件
#pragma once
#include<opencv2/opencv.hpp>using namespace cv;
class demo
{
public:
void color_demo(Mat &image);
};
注意:

1.把要导入的图片放在C文件同一目录。
2.把文件路径加入到包含目录,即在解决方案资源管理器找到本次的文件,右击,找到属性,VC++目录,找到包含目录,把上图的文件路径添加进去。
结果如下:

over!!!
边栏推荐
- 金融数据获取(三)当爬虫遇上要鼠标滚轮滚动才会刷新数据的网页(保姆级教程)
- NGUI-UILabel
- SQL Lab (41~45) (continuous update later)
- (待会删)yyds,付费搞来的学术资源,请低调使用!
- 【玩转 RT-Thread】 RT-Thread Studio —— 按键控制电机正反转、蜂鸣器
- [statistical learning method] learning notes - logistic regression and maximum entropy model
- 牛客网刷题网址
- 【统计学习方法】学习笔记——支持向量机(上)
- Object. Simple implementation of assign()
- SQL Lab (46~53) (continuous update later) order by injection
猜你喜欢

解决 Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually

Epp+dis learning path (1) -- Hello world!

leetcode刷题:二叉树27(删除二叉搜索树中的节点)

【玩转 RT-Thread】 RT-Thread Studio —— 按键控制电机正反转、蜂鸣器

EPP+DIS学习之路(2)——Blink!闪烁!

《看完就懂系列》天哪!搞懂节流与防抖竟简单如斯~

跨域问题解决方案

ps链接图层的使用方法和快捷键,ps图层链接怎么做的

OSPF exercise Report

Customize the web service configuration file
随机推荐
Processing strategy of message queue message loss and repeated message sending
(to be deleted later) yyds, paid academic resources, please keep a low profile!
平安证券手机行开户安全吗?
利用棧來實現二進制轉化為十進制
[statistical learning methods] learning notes - Chapter 5: Decision Tree
[pytorch practice] use pytorch to realize image style migration based on neural network
Simple network configuration for equipment management
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
数据库安全的重要性
Attack and defense world - PWN learning notes
File upload vulnerability - upload labs (1~2)
Solutions to cross domain problems
Upgrade from a tool to a solution, and the new site with praise points to new value
关于 Web Content-Security-Policy Directive 通过 meta 元素指定的一些测试用例
Sign up now | oar hacker marathon phase III midsummer debut, waiting for you to challenge
NGUI-UILabel
Airserver automatically receives multi screen projection or cross device projection
ENSP MPLS layer 3 dedicated line
免备案服务器会影响网站排名和权重吗?
Zhimei creative website exercise