边缘处理

边缘处理
1、边缘处理

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
增加图像边缘api:
在这里插入图片描述

2、代码实现
#include <opencv2/opencv.hpp>
#include <iostream>

using namespace std;
using namespace cv;

int main(int argc, char** argv)
{
	Mat img = imread("G:/testpic/img.png");
	if (img.empty())
	{
		printf("cannot load the image");
		return 0;
	}

	namedWindow("input",  WINDOW_AUTOSIZE);
	imshow("input", img);

	//
	int c = 0;
	int top = (int)(0.1 * img.rows);
	int bottom = (int)(0.1 * img.rows);
	int left = (int)(0.1 * img.cols);
	int right = (int)(0.1 * img.cols);
	Mat dst;
	RNG rng(123545);
	while(true)
	{
		c = waitKey(500);
		if ((char) c == 27)
		{
			break;
		}
		else if((char) c == "w")
		{
			border_type = BORDER_WRAP;
		}
		else if((char) c == "r")
		{
			border_type = BORDER_REPLICATE;
		}
		else if((char)  c == "c")
		{
			border_type = BORDER_CONSTANT;
		}
		else
		{
			border_type = BORDER_DEFAULT;
		}
		Scalar color = Scalar(rng.uniform(0,255), rng.unform(0,255), rng.uniform(0,255));
		copyMakeBorder(img, dst, top, bottom, left, right, border_type, color);
		imshow("output", dst);
	}

	return 0;
}

原图
在这里插入图片描述
border_Constant
在这里插入图片描述
border_Replicate
在这里插入图片描述
border_wrap
在这里插入图片描述

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值