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


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

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


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

示例1: caltridiagonalMatrices

bool CubicSplineInterpolation::caltridiagonalMatrices( 
    cv::Mat_<double> &input_a, 
    cv::Mat_<double> &input_b, 
    cv::Mat_<double> &input_c,
    cv::Mat_<double> &input_d,
    cv::Mat_<double> &output_x )
{
    int rows = input_a.rows;
    int cols = input_a.cols;

    if ( ( rows == 1 && cols > rows ) || 
        (cols == 1 && rows > cols ) )
    {
        const int count = ( rows > cols ? rows : cols ) - 1;

        output_x = cv::Mat_<double>::zeros(rows, cols);

        cv::Mat_<double> cCopy, dCopy;
        input_c.copyTo(cCopy);
        input_d.copyTo(dCopy);

        if ( input_b(0) != 0 )
        {
            cCopy(0) /= input_b(0);
            dCopy(0) /= input_b(0);
        }
        else
        {
            return false;
        }

        for ( int i=1; i < count; i++ )
        {
            double temp = input_b(i) - input_a(i) * cCopy(i-1);
            if ( temp == 0.0 )
            {
                return false;
            }

            cCopy(i) /= temp;
            dCopy(i) = ( dCopy(i) - dCopy(i-1)*input_a(i) ) / temp;
        }

        output_x(count) = dCopy(count);
        for ( int i=count-2; i > 0; i-- )
        {
            output_x(i) = dCopy(i) - cCopy(i)*output_x(i+1);
        }
        return true;
    }
    else
    {
        return false;
    }
}
开发者ID:brightming,项目名称:ImageTest,代码行数:55,代码来源:CubicSplineInterpolation.cpp

示例2: binImg

cv::Mat_<uchar> ocmu_maxconnecteddomain(cv::Mat_<uchar> binImg)
{	
	cv::Mat_<uchar> maxRegion; // Returned matrix;

	// 查找轮廓,对应连通域 
	cv::Mat_<uchar> contourImg;
	binImg.copyTo(contourImg);
	std::vector<std::vector<cv::Point>> contourVecs;  
	cv::findContours(contourImg, contourVecs,CV_RETR_EXTERNAL, \
		CV_CHAIN_APPROX_NONE);
		 
	if (contourVecs.size() > 0) { // 存在多个连通域,寻找最大连通域 
		double maxArea = 0;  
		std::vector<cv::Point> maxContour;  
		for(size_t i = 0; i < contourVecs.size(); i++) {  
			double area = cv::contourArea(contourVecs[i]);  
			if (area > maxArea) {  
				maxArea = area;  
				maxContour = contourVecs[i];  
			}  
		}  

		// 将轮廓转为矩形框  
		cv::Rect maxRect = cv::boundingRect(maxContour);  
		int xBegPos = maxRect.y;
		int yBegPos = maxRect.x;
		int xEndPos = xBegPos + maxRect.height;
		int yEndPos = yBegPos + maxRect.width;

		maxRegion = binImg(cv::Range(xBegPos, xEndPos), \
			cv::Range(yBegPos, yEndPos));
	}

	return maxRegion;
}
开发者ID:RobertMarton,项目名称:OpenCV-and-CPP-for-MATLAB-Users,代码行数:35,代码来源:ocmu_maxconnecteddomain.cpp

示例3: AddDescriptor

	void AddDescriptor(cv::Mat_<double>& descriptors, cv::Mat_<double> new_descriptor, int curr_frame, int num_frames_to_keep)
	{
		if(descriptors.empty())
		{
			descriptors = Mat_<double>(num_frames_to_keep, new_descriptor.cols, 0.0);
		}

		int row_to_change = curr_frame % num_frames_to_keep;

		new_descriptor.copyTo(descriptors.row(row_to_change));
	}	
开发者ID:AndreySheka,项目名称:CLM-framework,代码行数:11,代码来源:Face_utils.cpp

示例4: estimate

illumestimators::Illum OrthodoxTanAdapter::estimate(cv::Mat_<cv::Vec3b> the_image, cv::Mat_<unsigned char> mask)
{
	// mask out white pixels
	assert((the_image.rows == mask.rows) && (the_image.cols == mask.cols));

	// alter copy, not original image;
	cv::Mat_<cv::Vec3d> use_this;
	the_image.copyTo(use_this);

	for (int y = 0; y < the_image.rows; ++y)
		for (int x = 0; x < the_image.cols; ++x)
			if (mask[y][x] == 255)
				use_this[y][x] = cv::Vec3d(0, 0, 0);

	return estimate(use_this);
}
开发者ID:tiagojc,项目名称:IBTSFIF,代码行数:16,代码来源:orthodox_tan_adapter.cpp

示例5: smoothingKernelSize

WTLF::FilteredImg::FilteredImg(int kernelSize, const cv::Mat_<float> &img)
: smoothingKernelSize(kernelSize), cumsum(img.rows*img.cols + 1, 0)
{
	if (smoothingKernelSize == 0)
		img.copyTo(filtImg);
	else
		cv::boxFilter(img, filtImg, -1 /* same depth as img */,
			Size(smoothingKernelSize, smoothingKernelSize), 
			Point(-1,-1) /* anchor at kernel center */,
			true /* normalize */);

	//calculate CDF
	cumsum[0] = 0.0f;
	Mat_<float>::const_iterator it = filtImg.begin(), 
		itEnd = filtImg.end();
	for (int i = 0; it != itEnd; ++it, ++i)
	{
		cumsum[i+1] = cumsum[i] + (*it)*(*it); /*pow(*it, 2)*/
	}
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:20,代码来源:WalkTheLineFitter.cpp

示例6: FGS

// mex function call:
// x = mexFGS(input_image, guidance_image = NULL, sigma, lambda, fgs_iteration = 3, fgs_attenuation = 4);
void FGS(const cv::Mat_<float> &in, const cv::Mat_<cv::Vec3b> &color_guide, cv::Mat_<float> &out, double sigma, double lambda, int solver_iteration, int solver_attenuation)
{
	
	// image resolution
	W = in.cols;
	H = in.rows;

    nChannels = 1;
    nChannels_guide = 3;
	
	cv::Mat_<cv::Vec3f> image_guidance;
	color_guide.convertTo(image_guidance,CV_32FC3);

	cv::Mat_<float> image_filtered;
	in.copyTo(image_filtered);

	// run FGS
	sigma *= 255.0;
    
	FGS_simple(image_filtered, image_guidance, sigma, lambda, solver_iteration, solver_attenuation);
	image_filtered.copyTo(out);
}
开发者ID:IanDaisy,项目名称:spm-bp,代码行数:24,代码来源:FGS_Function.cpp

示例7: sizeof

cv::Mat_<cv::Vec3b> SuperpixelSegmentation::getSegmentedImage(cv::Mat_<cv::Vec3b> input_host, int options){
	
	if(options == Line){
	//cudaMemcpy(Labels_Host, Labels_Device, sizeof(int)*width*height, cudaMemcpyDeviceToHost);
	input_host.copyTo(SegmentedColor);

	for(int y=0; y<height-1; y++){
		for(int x=0; x<width-1; x++){
			if(Labels_Host[y*width+x] !=  Labels_Host[(y+1)*width+x]){
				//SegmentedColor.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 0, 0);
				SegmentedColor.at<cv::Vec3b>(y, x) = cv::Vec3b(255, 255, 255);
			}
			if(Labels_Host[y*width+x] !=  Labels_Host[y*width+x+1]){
				//SegmentedColor.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 0, 0);
				SegmentedColor.at<cv::Vec3b>(y, x) = cv::Vec3b(255, 255, 255);
			}
		}
	}

	}
	else{
	//int* size = new int[40*80];
	//int3* rgb = new int3[40*80];
	//int3* center = new int3[40*80];
	//int3 init;
	//init.x = 0;
	//init.y = 0;
	//init.z = 0;
	//for(int i=0; i<40*80; i++){
	//	size[i] = 0;
	//	rgb[i] = init;
	//	center[i] = init;
	//}
	//for(int y=0; y<height; y++){
	//	for(int x=0; x<width; x++){
	//		int id = Labels_Host[y*width+x];
	//		if(id != -1){
	//			size[id]++;
	//			rgb[id].x += (int)input_host.at<cv::Vec3b>(y, x).val[0];
	//			rgb[id].y += (int)input_host.at<cv::Vec3b>(y, x).val[1];
	//			rgb[id].z += (int)input_host.at<cv::Vec3b>(y, x).val[2];
	//			center[id].x += x;
	//			center[id].y += y;
	//		}
	//	}
	//}
	//cudaMemcpy(Labels_Host, Labels_Device, sizeof(int)*width*height, cudaMemcpyDeviceToHost);
	cudaMemcpy(meanData_Host, meanData_Device, sizeof(superpixel)*ClusterNum.x*ClusterNum.y, cudaMemcpyDeviceToHost);
	for(int y=0; y<height; y++){
		for(int x=0; x<width; x++){
			int id = Labels_Host[y*width+x];
			if(id != -1){
				//std::cout << id <<std::endl;
				SegmentedColor.at<cv::Vec3b>(y, x).val[0] = meanData_Host[id].r;
				SegmentedColor.at<cv::Vec3b>(y, x).val[1] = meanData_Host[id].g;
				SegmentedColor.at<cv::Vec3b>(y, x).val[2] = meanData_Host[id].b;
				//if(SegmentedColor.at<cv::Vec3b>(y, x) == cv::Vec3b(0, 0, 0))
				//	std::cout << "id: "<< id <<std::endl;
				//SegmentedColor.at<cv::Vec3b>(y, x).val[0] = (unsigned char)(rgb[id].x/size[id]);
				//SegmentedColor.at<cv::Vec3b>(y, x).val[1] = (unsigned char)(rgb[id].y/size[id]);
				//SegmentedColor.at<cv::Vec3b>(y, x).val[2] = (unsigned char)(rgb[id].z/size[id]);
			}												
			else
				SegmentedColor.at<cv::Vec3b>(y, x) = cv::Vec3b(0, 0, 0);
		}
	}
	}
	

	
	//delete [] size;
	//delete [] rgb;
	//delete [] center;
	//
	return SegmentedColor;
}
开发者ID:hvrl,项目名称:DepthMapEnhancement,代码行数:76,代码来源:SuperpixelSegmentation.cpp


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