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


C++ Mat_::step1方法代码示例

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


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

示例1: convolve

	void convolve(cv::Mat_<float> &im, const int axis, const float* kernel)
	{
		if(axis >= im.dims)
			throw std::invalid_argument("Matrix dimension is too small to convolve along this axis");
		assert(im.isContinuous());
		Convolver co(im.size[axis]);
		unsigned long int step = im.step1(axis);
		//whatever the real dimension, we fall back to a 3d situation where the axis of interest is y
		//and either x or z can be of size 1
		int nbplanes = 1;
		for(int d=0; d<axis; ++d)
			nbplanes *= im.size[d];
		int planestep = im.total()/nbplanes;
		//for each plane
		for(int i=0; i<nbplanes; ++i)
			//for each line
			for(size_t j=0; j<step; ++j)
				co(reinterpret_cast<float*>(im.data) + i*planestep + j, step, kernel);
	}
开发者ID:MathieuLeocmach,项目名称:colloids,代码行数:19,代码来源:deconvolution.cpp

示例2: invalid_argument

	std::vector<float> get_spectrum_1d(const cv::Mat_<float> &im, const int axis, const bool windowing)
	{
		if(axis >= im.dims)
			throw std::invalid_argument("Matrix dimension is too small to compute the spectrum along this axis");
		assert(im.isContinuous());
		Convolver co(im.size[axis]);
		if(windowing)
			co.set_hanning();
		std::vector<float> spectrum(co.fourier_size());
		std::vector<double> tot(co.fourier_size(), 0.0);
		std::vector<std::complex<double> > totf(co.fourier_size(), 0.0);
		unsigned long int step = im.step1(axis);
		//whatever the real dimension, we fall back to a 3d situation where the axis of interest is y
		//and either x or z can be of size 1
		int nbplanes = 1;
		for(int d=0; d<axis; ++d)
			nbplanes *= im.size[d];
		int planestep = im.total()/nbplanes;
		//for each plane
		for(int i=0; i<nbplanes; ++i)
		{
			//for each line
			for(size_t j=0; j<step; ++j)
			{
				co.spectrum(reinterpret_cast<float* const>(im.data) + i*planestep + j, step, &spectrum[0]);
				for(size_t u=0; u<spectrum.size(); ++u)
					tot[u] += spectrum[u];
				for(size_t u=0; u<spectrum.size(); ++u)
					totf[u] += co.get_fourier()[u];
			}
		}
		const double icount = 1.0 / (nbplanes * step);
		for(size_t i=0; i<tot.size(); ++i)
			spectrum[i] = tot[i]*icount - std::norm(totf[i]*icount);
		return spectrum;
	}
开发者ID:MathieuLeocmach,项目名称:colloids,代码行数:36,代码来源:deconvolution.cpp


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