图像处理 【基础】

图像文件读写

读文件
Mat cv::imread(const String &filename, int flags = IMREAD_COLOR)	
写文件
bool cv::imwrite(const String & filename, InputArray img, const std::vector<int> &params = std::vector<int>())	

图像缩放

函数
void cv::resize	(	
	InputArray 		src,	//图像
	OutputArray 	dst,	//输出图像
	Size 	dsize,			//输出图像尺寸
	double 	fx = 0,			//宽度放大倍数
	double 	fy = 0,			//高度放大倍数
	int 	interpolation = INTER_LINEAR 
)	

形状绘制

直线
void cv::line	(
	InputOutputArray 	img,		//图像数据
	Point 	pt1,					//直线起始点
	Point 	pt2,					//直线结束点
	const Scalar & 	color,			//直线颜色
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	
折线
void cv::polylines	(
	InputOutputArray 	img,
	const Point *const * 	pts,
	const int * 	npts,
	int 	ncontours,
	bool 	isClosed,
	const Scalar & 	color,
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	

void cv::polylines	(
	InputOutputArray 	img,
	InputArrayOfArrays 	pts,
	bool 	isClosed,
	const Scalar & 	color,
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	
矩形

void cv::rectangle	(
	InputOutputArray 	img,  	//图像数据
	Point 	pt1,				//矩形左上角
	Point 	pt2,				//矩形右下角
	const Scalar & 	color,	// 矩形颜色
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	

void 	cv::rectangle (
  	InputOutputArray img, 		//图像数据
  	Rect rec, 					//矩形范围
	const Scalar &color, 		//矩形颜色
	int thickness=1, 
	int lineType=LINE_8, 
	int shift=0
)
圆形
void cv::circle	(
	InputOutputArray 	img,	//图像数据
	Point 	center,				//圆心坐标
	int 	radius,				//圆半径
	const Scalar & 	color,		//圆颜色
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	
椭圆
void cv::ellipse	(
	InputOutputArray 	img,	//图像数据
	Point 	center,				//椭圆中心
	Size 	axes,				//椭圆尺寸
	double 	angle,				//角度范围
	double 	startAngle,			//起始角度
	double 	endAngle,			//结束角度
	const Scalar & 	color,		//椭圆颜色
	int 	thickness = 1,
	int 	lineType = LINE_8,
	int 	shift = 0 
)	

void cv::ellipse	(
	InputOutputArray 	img,
	const RotatedRect & 	box,
	const Scalar & 	color,
	int 	thickness = 1,
	int 	lineType = LINE_8 
)	
颜色空间转换
void cv::cvtColor	(
	InputArray 	src,		//输入
	OutputArray 	dst,	//输出
	int 	code,			//颜色空间
	int 	dstCn = 0 		//目标图像通道数
)	
物体检测
void cv::matchTemplate	(
	InputArray 	image,
	InputArray 	templ,
	OutputArray 	result,
	int 	method,
	InputArray 	mask = noArray() 
)	
例子
#include <iostream>

#include "opencv2/core.hpp"
#include "opencv2/core/mat.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"


int main(void)
{
    cv::Mat src, dst;
    src = cv::imread("image/lena.jpg");
    if (!src.empty()) {
        cv::imshow("src", src);
        cv::resize(src, dst, cv::Size(0, 0), 2, 1);
        if (!dst.empty()) {
            cv::imshow("dst", dst);
            cv::waitKey(0);
        }
    }
    return 0;
}

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值