当前位置: 首页>>代码示例>>C++>>正文


C++ vnl_matrix::columns方法代码示例

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


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

示例1:

vnl_matrix <double> Normalize_Feature_Matrix(vnl_matrix<double> feats)
{
	mbl_stats_nd stats;

	for(int i = 0; i<feats.rows() ; ++i)
	{
		vnl_vector<double> temp_row = feats.get_row(i);
		stats.obs(temp_row);	
	}

	vnl_vector<double> std_vec = stats.sd();
	vnl_vector<double> mean_vec = stats.mean();
	
	for(int i = 0; i<feats.columns()-3 ; ++i)
	{
		vnl_vector<double> temp_col = feats.get_column(i);
		if(std_vec(i) > 0)
		{	
			for(int j =0; j<temp_col.size() ; ++j)
				temp_col[j] = (temp_col[j] - mean_vec(i))/std_vec(i) ;
		}
	
		feats.set_column(i,temp_col);
	}

	return feats;
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:27,代码来源:mclr_main.cpp

示例2:

vnl_matrix <double> MCLR_SM::Normalize_Feature_Matrix(vnl_matrix<double> feats)
{
	mbl_stats_nd stats;

	for(int i = 0; i<feats.rows() ; ++i)
	{
		vnl_vector<double> temp_row = feats.get_row(i);
		stats.obs(temp_row);	
	}

	std_vec = stats.sd();
	mean_vec = stats.mean();
	

//The last column is the training column 
	for(int i = 0; i<feats.columns() ; ++i)
	{
		vnl_vector<double> temp_col = feats.get_column(i);
		if(std_vec(i) > 0)
		{	
			for(int j =0; j<temp_col.size() ; ++j)
				temp_col[j] = (temp_col[j] - mean_vec(i))/std_vec(i) ;
		}
	
		feats.set_column(i,temp_col);
	}

	return feats;
}
开发者ID:JumperWang,项目名称:farsight-clone,代码行数:29,代码来源:mclr_SM.cpp

示例3: Vectorize

	//std::vector<double> Vectorize(const vnl_matrix<double> &M)
	vnl_vector<double> Vectorize(const vnl_matrix<double> &M)
	{
		
		//std::vector<double> V;
		vnl_vector<double> V(M.rows() * M.columns());
		
		for (unsigned j = 0; j < M.rows(); j++)
		{
			for (unsigned i = 0; i < M.columns(); i++)
			{
				//V.push_back(M(i,j));
				V[M.columns() * j + i] = M(i,j);
			}
		}
		
		return V;
	}
开发者ID:daviddoria,项目名称:VXLHelpers,代码行数:18,代码来源:VXLHelpers.cpp

示例4: EigenVectors

	std::vector<vnl_vector<double> > EigenVectors(const vnl_matrix<double> &M)
	{
		vnl_symmetric_eigensystem<double> Eigs(M);
		
		std::vector<vnl_vector<double> > EVecs;
		for(unsigned int i = 0; i < M.columns(); i++)
			EVecs.push_back(Eigs.get_eigenvector(i));
		
			return EVecs;
		
	}
开发者ID:daviddoria,项目名称:VXLHelpers,代码行数:11,代码来源:VXLHelpers.cpp

示例5: Initialize

void LocalGeometryRef::Initialize(vnl_matrix<double> data)
{
	this->num_row = data.rows();
	this->num_col = data.columns();
	this->data_matrix.set_size(this->num_row, this->num_col);
	for(int row = 0; row < this->num_row; row++)
	{
		for(int col = 0; col < this->num_col; col++)
		{
			this->data_matrix(row, col) = data(row, col);
		}
	}
}
开发者ID:Pandolph,项目名称:farsight,代码行数:13,代码来源:LocalGeometryRef.cpp

示例6: CloseEnough

	bool CloseEnough(const vnl_matrix<double> &M1, const vnl_matrix<double> &M2, const double eps)
	{
		unsigned int NumRows = M1.rows();
		unsigned int NumCols = M1.columns();
		if((M2.rows() != NumRows) || (M2.columns() != NumCols))
		{
			std::cout << "Dimensions do not match!" << std::endl;
			return false;	
		}
		
		for(unsigned int r = 0; r < NumRows; r++)
		{
			for(unsigned int c = 0; c < NumCols; c++)
			{
				if(fabs(M1(r,c) - M2(r,c)) > eps)
				{
					std::cout << "Failed comparison: " << "M1: " << M1(r,c) << " M2: " << M2(r,c) << " diff: " << fabs(M1(r,c) - M2(r,c)) << std::endl;
					return false;
				}
			}
		}
		return true;	
	}
开发者ID:daviddoria,项目名称:VXLHelpers,代码行数:23,代码来源:VXLHelpers.cpp

示例7: WriteMatrixImage

	void WriteMatrixImage(const vnl_matrix<double> &M, const std::string &Filename)
	{
		vil_image_view<vxl_byte> Image(M.rows(), M.columns(), 1, 1); //(ni, nj, n_planes, n_interleaved_planes)
	
		for (unsigned j = 0; j < Image.nj(); j++)
		{
			for (unsigned i = 0; i < Image.ni(); i++)
			{
				Image(i,j) = static_cast<vxl_byte>(255 * M(i,j));
			}
		}
		
		vil_save(Image, Filename.c_str());
	}
开发者ID:daviddoria,项目名称:VXLHelpers,代码行数:14,代码来源:VXLHelpers.cpp

示例8: WriteMatrixImageScaled

	void WriteMatrixImageScaled(const vnl_matrix<double> &M, const std::string &Filename)
	{
		vil_image_view<vxl_byte> Image(M.rows(), M.columns(), 1, 1); //(ni, nj, n_planes, n_interleaved_planes)
		
		//double Max = Tools::VectorMax(Vectorize(M));
		double Max = M.max_value();
		
		for (unsigned j = 0; j < Image.nj(); j++)
		{
			for (unsigned i = 0; i < Image.ni(); i++)
			{
				Image(i,j) = static_cast<vxl_byte>(255 * M(i,j)/Max);
				//cout << "M: " << M(i,j) << endl;
				//cout << "Image: " << Image(i,j) << endl;
			}
		}
		
		vil_save(Image, Filename.c_str());
	}
开发者ID:daviddoria,项目名称:VXLHelpers,代码行数:19,代码来源:VXLHelpers.cpp


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