智能剪刀算法+详细注释

//#include<opencv2/core/core.hpp>
//#include<iostream>
//#include<opencv2/highgui/highgui.hpp>
//#include<opencv2/imgproc.hpp>        
//#include<vector>
//#include<math.h>
//#include<queue>
//#include<climits>
//#define _math_defines_defined
//#define _use_math_defines
//#define pi 3.1415926
//#define sqrt2  1.4142135623731 
//using namespace std;
//using namespace cv;
//std::vector<point> v;
//vector<vector<vector<float> > > cost_vector;
//mat source;
//mat src;
//void initial_eight_point() {
//	v.push_back(point(1, 0));
//	v.push_back(point(1, 1));
//	v.push_back(point(0, 1));
//	v.push_back(point(-1, 1));
//	v.push_back(point(-1, 0));
//	v.push_back(point(-1, -1));
//	v.push_back(point(0, -1));
//	v.push_back(point(1, -1));
//}
//void initial_cost_vector(int row, int col) {
//	vector<vector<vector<float> > > temp(row, vector<vector<float> >(col, vector<float>(8)));
//	swap(temp, cost_vector);
//}
//void initial_cost() {
//	initial_eight_point();
//	initial_cost_vector(src.rows, src.cols);
//	float w1 = 0.4f, w2 = 0.4f, w3 = 0.14f;
//	/
//	mat detected_edges;
//	mat gray_image;//上下两个函数公用一个灰度图
//	vector<vector<float> > first(src.rows, vector<float>(src.cols));
//	cvtcolor(src, gray_image, color_bgr2gray);
//	blur(gray_image, detected_edges, size(3, 3));
//	canny(detected_edges, detected_edges, 3, 9, 3);
//	for (int i = 0; i < src.rows; i++) {
//		for (int j = 0; j < src.cols; j++) {
//			if (detected_edges.at<uchar>(i, j) > 0) {
//				first[i][j] = 1;
//			}
//			else {
//				first[i][j] = 0;
//			}
//		}
//	}
//	//经过测试,这一部分没有问题
//	vector<vector<float> >  vectori(src.rows, vector<float>(src.cols, 0.0f));
//	mat dest_x, dest_y;
//	scharr(gray_image, dest_x, src.depth(), 1, 0);
//	scharr(gray_image, dest_y, src.depth(), 0, 1);//这里x,y方向的梯度应该没有问题
//
  • 5
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 23
    评论
评论 23
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值