opencv使用pdst[data]的方式方位像素

template <class T>
class RestoreC1h0//构造一个供parallel_for使用的循环结构体  
{
public:
	T* pdst ;
	T* psrc ;
	T* proi;
	int dwidth ;
	int swidth ;
	int rwidth ;
	int dheight;
	int h0 ;
	int hs ;
	vector<SciRun> *Run;

	void operator()(const blocked_range<int>& range) const
	{
		for (int i = range.begin(); i < range.end(); i++)
		{
			int data_o = i*dwidth;
			int data_p = i*swidth;
			for (int j = 0; j < dwidth; j++)
			{
				pdst[data_o + j] = psrc[data_p + j];
			}
		}
	}
};

/*************************************************************************************/
void RunRestoreImageC1(vector<SciRun> &Run, cv::Mat &src, cv::Mat &roi, cv::Mat *dst, int ROITopLeftX, int ROITopLeftY)
{
	T* pdst = (T*)(dst->data);
	T* psrc = (T*)(src.data);
	T* proi = (T*)(roi.data);
	int dwidth = dst->cols;
	int swidth = src.cols;
	int rwidth = roi.cols;
	int dheight = dst->rows;
	int h0 = Run[0][0];
	int hs = Run[Run.size() - 1][0];
	omp_set_num_threads(m_Device.TBBNum);

#pragma omp parallel for
//	for (int i = 0; i < h0; i++)
//	{
//		int data_o = i*dwidth;
//		int data_p = i*swidth;
//		for (int j = 0; j < dwidth; j++)
//		{
//			pdst[data_o + j] = psrc[data_p + j];
//		}
//	}
#pragma omp parallel for
//	for (int i = 0; i < Run.size(); i++)
//	{
//		int data_o = Run[i][0] * dwidth;
//		int data_p = (Run[i][0] - ROITopLeftY) * rwidth - ROITopLeftX;
//		for (int j = 0; j < Run[i][1]; j++)
//		{
//			pdst[data_o + j] = psrc[data_o + j];
//		}
//		for (int j = Run[i][1]; j <= Run[i][2]; j++)
//		{
//			pdst[data_o + j] = proi[data_p + j];
//		}
//		for (int j = Run[i][2] + 1; j < dwidth; j++)
//		{
//			pdst[data_o + j] = psrc[data_o + j];
//		}
//	}
#pragma omp parallel for
//	for (int i = hs + 1; i < dheight; i++)
//	{
//		int data_o = i*dwidth;
//		int data_p = i*swidth;
//		for (int j = 0; j < dwidth; j++)
//		{
//			pdst[data_o + j] = psrc[data_p + j];
//		}
//	}
	//m_Device.TBBNum = 1;
	RestoreC1h0<T> restorec1h0;
	restorec1h0.pdst = pdst;
	restorec1h0.psrc = psrc;
	restorec1h0.proi = proi;
	restorec1h0.dwidth = dwidth;
	restorec1h0.swidth = swidth;
	restorec1h0.dheight = dheight;
	restorec1h0.h0 = h0;
	restorec1h0.hs = hs;
	restorec1h0.Run = &Run;
	if (m_Device.TBBNum > 0)
		parallel_for(blocked_range<int>(0, h0, (h0) / m_Device.TBBNum), restorec1h0);
	else
		parallel_for(blocked_range<int>(0, h0), restorec1h0, auto_partitioner());

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值