• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ SDoublePlane类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中SDoublePlane的典型用法代码示例。如果您正苦于以下问题:C++ SDoublePlane类的具体用法?C++ SDoublePlane怎么用?C++ SDoublePlane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SDoublePlane类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_notes_possitions

int get_notes_possitions(const SDoublePlane &input, const SDoublePlane &tmpl,
		double threshold, SDoublePlane &output, Type t,
		vector<DetectedSymbol> &symbols)
{
	// non-maximum suppress size
	int sup_w,  sup_h;
	
	//shawn calc hamming distance
	
	// get template image
	//SDoublePlane template_note = SImageIO::read_png_file("template1.png");
	// get distance
	SDoublePlane hammdis_note = get_Hamming_distance(input, tmpl);
	if (t == NOTEHEAD)
	{
		write_image("scores4.png", hammdis_note);
	}
	//write_image("hamming_dist_note.png", hammdis_note);
	// print_image_value(hammdis_note);
	// cout << plane_max(hammdis_note) / 255 << endl;
	// non-maximum suppress
	SDoublePlane sup_note = non_maximum_suppress(hammdis_note, threshold*255, tmpl.cols()*0.5, tmpl.rows()-(int)(tmpl.rows()*0.4));
	//write_image("sup_hamming_dist_note.png", sup_note);
	get_symbols(sup_note, symbols, t, tmpl.cols(), tmpl.rows());

	
	return 0;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:28,代码来源:a1.cpp


示例2: set_disparity

void set_disparity(int start, int end, vector<SDoublePlane> &D, SDoublePlane &V, vector<vector<SDoublePlane> > &m)
{
	//disp_arg *A = (disp_arg*)obj;

	double disp_score;
    double min_score = INT_MAX;
	int label, t=1;
	double neighbors_sum;
	start = (start < 1)? 1:start;
	end = (end < (V.rows()-1))?end:(V.rows()-1);
	for (int i = start; i < end-1; i++) {
		for (int j = 1; j < D[0].cols() - 1; j++) {
			min_score = INT_MAX;
			label = DLIMIT;
			for (int d = 0; d < DLIMIT; d++) {
				//cout << i<<","<<j<<endl;
				neighbors_sum = get_messages_from_neighbors(m[d][t], i, j, ALL);
				disp_score = D[d][i][j] + neighbors_sum;

				if (disp_score < min_score) {
					min_score = disp_score;
					label = d;
				}
			}

			V[i][j] = label;
		}
	}
}
开发者ID:shreyarattan,项目名称:MRF,代码行数:29,代码来源:stereo.cpp


示例3: find_line_location

// Finding Line Location for Q4. As this was a open ended question, we found the number of lines using this approach.
vector<LineLocation> find_line_location(SDoublePlane &input){
	
	int rows = input.rows();
	int cols = input.cols();
	vector<LineLocation> allLinesLocVector;
	double sum;
	int lineCounter = 1;
	int j;
	
	for(int i=0;i<rows;i++)
	{	sum =0;
		for(j=cols - 45;j<cols -40;j++){
			sum += input[i][j]; 
		}
		if(sum/5 < 130){
			LineLocation lineLoc;
			lineLoc.row = i;
			lineLoc.col = j;
			set_line_tags(lineLoc, lineCounter);
			lineCounter++;
			allLinesLocVector.push_back(lineLoc);
		}
	
	}
	return allLinesLocVector;
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:27,代码来源:a1.cpp


示例4: convolve_separable

// Convolve an image with a separable convolution kernel
//
SDoublePlane convolve_separable(const SDoublePlane &input, const SDoublePlane &row_filter, const SDoublePlane &col_filter)
{
	SDoublePlane output(input.rows(), input.cols());

	output = convolve_general(input, row_filter);
	return convolve_general(output, col_filter);
}
开发者ID:supersaiyanmode,项目名称:Optical-MusicalCharacter-Recognition,代码行数:9,代码来源:utils.cpp


示例5: write_staves_image

void write_staves_image(const string &filename, const SDoublePlane &img, vector<Line> linesVector){
	
	SDoublePlane output_planes[3];
	
	for (int i = 0; i < 3; i++)
		output_planes[i] = img;
					
	int r = img.rows();
	int c = img.cols();
	
	int x1, y1, x2, y2;
	for (int i = 0; i < linesVector.size(); i++) {
		x1 = linesVector[i].x1;
		y1 = linesVector[i].y1;
		x2 = linesVector[i].x2;
		y2 = linesVector[i].y2;
		//cout<<"(x1,y1): ("<<x1<<","<<y1<<"), (x2,y2):("<<x2<<","<<y2<<")\n"; 
		
		overlay_rectangle(output_planes[2], y1, x1, y2, x2, 255, 2);
		overlay_rectangle(output_planes[0], y1, x1, y2, x2, 0, 2);
		overlay_rectangle(output_planes[1], y1, x1, y2, x2, 0, 2);

	}
	
	SImageIO::write_png_file(filename.c_str(), output_planes[0],
			output_planes[1], output_planes[2]);
		
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:28,代码来源:a1.cpp


示例6: sobel_gradient_filter

// Apply a sobel operator to an image, returns the result
// _gx=true for horizontal gradient, false for vertical gradient
SDoublePlane sobel_gradient_filter(const SDoublePlane &input, bool _gx)
{
	SDoublePlane output(input.rows(), input.cols());
	SDoublePlane row_filter(1, 3), col_filter(3, 1);
	if (_gx)
	{
		row_filter[0][0] = -1.0;
		row_filter[0][1] = 0.0;	
		row_filter[0][2] = 1.0;
			
		col_filter[0][0] = 1.0/8.0;
		col_filter[1][0] = 2.0/8.0;	
		col_filter[2][0] = 1.0/8.0;
	}
	else
	{
		row_filter[0][0] = 1.0/8.0;
		row_filter[0][1] = 2.0/8.0;
		row_filter[0][2] = 1.0/8.0;
			
		col_filter[0][0] = 1.0;
		col_filter[1][0] = 0.0;	
		col_filter[2][0] = -1.0;	
	}	

	SDoublePlane sobel = convolve_separable(input, row_filter, col_filter);	
	return sobel;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:30,代码来源:a1.cpp


示例7: non_maximum_suppress

SDoublePlane non_maximum_suppress(const SDoublePlane &input, double threshold, int w, int h)
{
	//double threshold = 0.84 * 255;
	SDoublePlane output(input.rows(), input.cols());
	
	for (int i = 0; i < input.rows(); i++)
	{
		for (int j = 0; j < input.cols(); j++)
		{
			if (input[i][j] > threshold &&
					is_max_in_neighbour(input, i, j, w, h))
			{
				if (input[i][j] > 0.85 * 255)
				{
					output[i][j] = 255;
				}
				else
				{
					output[i][j] = (input[i][j] - threshold)/(0.85 - threshold/255);
				}
			}
			else
			{
				output[i][j] = 0;
			}
		}
	}
	return output;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:29,代码来源:a1.cpp


示例8: calculate_F

SDoublePlane calculate_F(SDoublePlane D, SDoublePlane &binary_template, double threshold) {	
	double sum = 0.0;
	int m = binary_template.rows(), n = binary_template.cols();
	int i, j, k, l, input_rows = D.rows(), input_cols = D.cols();
	
	SDoublePlane output(input_rows, input_cols);
	for(i=0; i<input_rows - m; i++){
		for(j=0; j<input_cols - n; j++){
			sum=0.0;
			for(k =0; k<m; k++){
				for(l=0; l<n; l++){
					sum += binary_template[k][l] * D[i+k][j+l];
				}
			}
			output[i][j] = sum;
		}
	}
	//converting low scores to white n others black
	for(i=0; i<input_rows - m; i++)
		for(j=0; j<input_cols - n; j++)
			if(output[i][j] < threshold){
				output[i][j] = 255;
			}
			else
				output[i][j] = 0;
			
	return output;
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:28,代码来源:a1.cpp


示例9: compute_pairwise_cost

SDoublePlane compute_pairwise_cost(SDoublePlane disp, SDoublePlane &labels, int i, int j) {
	int sum = 0;
	int min_diff = INT_MAX;
	int min_label = DLIMIT;

	SDoublePlane result(disp.rows(), disp.cols());

//	for (int i = 1; i < disp.rows() - 1; i++) {
//		for (int j = 1; j < disp.cols() - 1; j++) {
			min_diff = INT_MAX;
			for (int d = 0; d < DLIMIT; d++) {
				sum = 0;
				sum += pow(d - disp[i][j - 1], 2);
				sum += pow(d - disp[i][j + 1], 2);
				sum += pow(d - disp[i + 1][j], 2);
				sum += pow(d - disp[i - 1][j], 2);
				if (sum < min_diff) {
					min_diff = sum;
					min_label = d;
				}
			}
			result[i][j] = min_diff;
			disp[i][j] = min_label;
			//cout<<min_diff<<endl;
//		}
//	}
	return result;
}
开发者ID:shreyarattan,项目名称:MRF,代码行数:28,代码来源:stereo.cpp


示例10: find_hamming_distance

HammingDistances find_hamming_distance(SDoublePlane &img_input, SDoublePlane &img_template){
	
	int input_rows = img_input.rows();
	int input_cols = img_input.cols();
	int template_rows = img_template.rows();
	int template_cols = img_template.cols();
	HammingDistances hm;
		
	double sum = 0.0;
	double max_hamming = 0.0;
	SDoublePlane output(input_rows, input_cols);
	for(int i =0;i<input_rows - template_rows ; ++i){
		for(int j =0;j<input_cols - template_cols; ++j){
			sum=0.0;
			for(int k =0;k<template_rows;++k){
				for(int l=0;l<template_cols;++l){
					sum = sum + (img_input[i+k][j+l] * img_template[k][l] + (1 - img_input[i+k][j+l])*(1 - img_template[k][l]));	
				}
			}
			output[i][j] = sum;
			if(sum>max_hamming)
				max_hamming = sum;
		}
	}
	//printImg2File("input_img_file_Output.txt", img_input);
	//printImg2File("img2fileOutput.txt", output);
	hm.hamming_matrix = output;
	hm.max_hamming_distance= max_hamming;
	return hm;	
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:30,代码来源:a1.cpp


示例11: calculate_D

SDoublePlane calculate_D(SDoublePlane &binary_image_blur_sobel) {
	int i, j, input_rows = binary_image_blur_sobel.rows(), input_cols = binary_image_blur_sobel.cols();
	SDoublePlane D(input_rows, input_cols);

	//initialize edges as 0 and others as infinity(10000) in binary_image_blur_sobel
	for(i=0;i<input_rows;i++)
		for(j=0;j<input_cols;j++)
			if(binary_image_blur_sobel[i][j] == 1)
				D[i][j] = 0;
			else
				D[i][j] = 10000;
	
	//distance below and to the right of edges
	for(i=1;i<input_rows;i++)
		for(j=1;j<input_cols;j++)
			D[i][j] = dmin(D[i][j], D[i][j-1]+1, D[i-1][j]+1);
	
	//distance above and to the left of edges
	for(i=input_rows-2; i>=0; i--)
		for(j=input_cols-2; j>=0 ;j--)
			D[i][j] = dmin(D[i][j], D[i+1][j]+1, D[i][j+1]+1);
	
	//bottom row
	i = input_rows-1;	
	for(j=input_cols-2; j>=0 ;j--)
		D[i][j] = dmin(D[i][j], D[i-1][j]+1, D[i][j+1]+1);
	
	//rightmost column
	j = input_cols-1;
	for(i=input_rows-2; i>=0; i--)
		D[i][j] = dmin(D[i][j], D[i+1][j]+1, D[i][j-1]+1);
	
	return D;
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:34,代码来源:a1.cpp


示例12: find_best_line_intercepts

//using the normalized votes find the best row co-ordinates for staff lines
SDoublePlane find_best_line_intercepts(const SDoublePlane &row_votes,const SDoublePlane &normed_votes,int best_space,double norm_threshold=0.55,int neighbour_threshold=4,int start=0)
{	
	SDoublePlane row_spacing=row_votes;
	if(start < row_votes.rows()){
        SDoublePlane staff_lines(row_votes.rows(),1);
	int i=0;	
	double best_value=0;
        int intercept_value=0;
        while(i<row_votes.rows()){
                if(normed_votes[i][0] > norm_threshold){
                        best_value=normed_votes[i][0];
                        intercept_value=i;
			for(int j=1;j<neighbour_threshold;j++){
                                if(normed_votes[i+j][0] > best_value ){
                                        best_value=normed_votes[i+j][0];
                                        intercept_value=i+j;
                                }
                        }
		row_spacing=set_staff(row_spacing,best_space,intercept_value,start);
                i=intercept_value+(4*(best_space))+neighbour_threshold;
		start=intercept_value+(4*best_space)+neighbour_threshold;

                }
		
     		i++;
        }
	
        }
	return row_spacing;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:31,代码来源:a1.cpp


示例13: find_edges

// Apply an edge detector to an image, returns the binary edge map
SDoublePlane find_edges(const SDoublePlane &input, double thresh = 0) {
	SDoublePlane output(input.rows(), input.cols());

	// Implement an edge detector of your choice, e.g.
	// use your sobel gradient operator to compute the gradient magnitude and threshold

	return output;
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:9,代码来源:a1.cpp


示例14: scale_image

SDoublePlane scale_image(const SDoublePlane &input, double ratio)
{
	int m = input.rows();
	int n = input.cols();
	int m2 = input.rows()*ratio;
	int n2 = input.cols()*ratio;
	
	SDoublePlane output(m2, n2);
	
	if (ratio > 0.5)
	{
		for (int i = 0; i < m2; i++)
		{
			int sk = i/ratio;
			int ek = (i + 1)/ratio - 0.00001;
			for (int j = 0; j < n2; j++)
			{
				int sl = j/ratio;
				int el = (j + 1)/ratio - 0.00001;
				
				output[i][j] = input[sk][sl];
				output[i][j] += input[sk][el];
				output[i][j] += input[ek][sl];
				output[i][j] += input[ek][el];
				output[i][j] /= 4.0;
			}
		}
	}
	else
	{
		int span = 1.0/ratio + 0.5;
		for (int i = 0; i < m2; i++)
		{
			int sk = i/ratio;
			int ek = (i - 1)/ratio - 0.00001;
			for (int j = 0; j < n2; j++)
			{
				int sl = j/ratio;
				int el = (j - 1)/ratio - 0.00001;
				
				output[i][j] = 0;
				for (int u = sk; u <= ek; u++)
				{
					for (int v = sl; v <= el; v++)
					{
						output[i][j] += input[u][v];
					}
				}
				output[i][j] /= (ek - sk + 1)*(el - sl + 1);
			}
		}
	}
	
	
	return output;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:56,代码来源:a1.cpp


示例15: normalize_votes

SDoublePlane normalize_votes(const SDoublePlane &acc)
{
	SDoublePlane normalized(acc.rows(),acc.cols());
	double min = find_min_vote(acc);
	double max = find_max_vote(acc);
	for(int i=0;i<acc.rows();i++){
		normalized[i][0] = (acc[i][0] - min)/(max-min);
	}
	return normalized;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:10,代码来源:a1.cpp


示例16: print_image_value

void print_image_value(const SDoublePlane &input)
{
	for (int i = 0; i < input.rows(); ++i)
	{
		for (int j = 0; j < input.cols(); ++j)
		{
			cout << input[i][j] << " ";			
		}
		cout << endl;
	}

}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:12,代码来源:a1.cpp


示例17: complement_image

SDoublePlane complement_image(const SDoublePlane &input)
{
	SDoublePlane output(input);
	for (int i = 0; i < input.rows(); ++i)
	{
		for (int j = 0; j < input.cols(); ++j)
		{
			output[i][j] = 255 - output[i][j];
		}
	}
	return output;
}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:12,代码来源:a1.cpp


示例18: printImg2File

// Print an image to a file
void printImg2File(string filename, SDoublePlane img) {
	ofstream outFile;
	outFile.open(filename.c_str());

	for (int i = 0; i < img.rows(); i++) {
		for (int j = 0; j < img.cols(); j++) {
			outFile << img[i][j] << ",";
		}
		outFile << "\n";
	}
	outFile.close();
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:13,代码来源:a1.cpp


示例19: print_image_value1

// The rest of these functions are incomplete. These are just suggestions to 
// get you started -- feel free to add extra functions, change function
// parameters, etc.
//
//
// Print the value of the image
//
void print_image_value1(const SDoublePlane &input)
{	int sum=0;
	for (int i = 0; i < input.cols(); ++i)
	{	sum=0;
		for (int j = 0; j < input.rows(); ++j)
		{	sum=sum+input[j][i];
			//cout << input[i][j] << " ";			
		}
		//cout << endl;
		cout<<sum<<"|||"<<i<<endl;
	}

}
开发者ID:ishtiakzaman,项目名称:OpticalMusicRecognition,代码行数:20,代码来源:a1.cpp


示例20: find_symbols

// Find symbols in the given image for the given template
void find_symbols(HammingDistances hm, SDoublePlane input, SDoublePlane img_template, vector <DetectedSymbol> &symbols, Type symbol_type){
	
	int template_rows = img_template.rows();
	int template_cols = img_template.cols();
	
	double max_hamming_distance = hm.max_hamming_distance;
	SDoublePlane matrix = hm.hamming_matrix;
	
	vector<LineLocation> allLinesLocVector;
	double confidence_threshold;
	if (symbol_type == NOTEHEAD){
		confidence_threshold = 0.9;
		allLinesLocVector = find_line_location(input);
	}
	else
		confidence_threshold = 0.95;
		
	// Finding symbols
	for(int i =0;i<matrix.rows();i++){
		for(int j=0;j<matrix.cols();j++){
			double value = matrix [i][j];
			if( value >= confidence_threshold * max_hamming_distance) {
				DetectedSymbol s;
				s.row = i;
				s.col = j;
				s.width = template_cols;
				s.height = template_rows;
				s.type = symbol_type;
				s.confidence = value;
				
				s.pitch = ' ';
				
				if(symbol_type == NOTEHEAD)
					set_symbol_marker(s, allLinesLocVector);
				else
					s.pitch = ' ';
				
				symbols.push_back(s);
				// Marking the pixels of the template so that they are not detected again
				for (int x=i; x < i+s.height; x++){
					for (int y=j; y < j+s.width; y++){
						matrix[x][y] = -100;
					}	
				}
				
			}

		}
	}
}
开发者ID:rohitnair987,项目名称:Optical-Music-Recognition,代码行数:51,代码来源:a1.cpp



注:本文中的SDoublePlane类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ SE3类代码示例发布时间:2022-05-31
下一篇:
C++ SDep类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap