Пример #1
0
void dispRefinement::operator()(Mat& src, Mat& guid, Mat& dest)
{
	Mat s;src.copyTo(s);
	Mat imgG;cv::cvtColor(guid,imgG,CV_BGR2GRAY);
	Mat ref;cv::cvtColor(guid,ref,CV_BGR2GRAY);

	for(int j=0;j<iter;j++)
	{
		Mat bmap = Mat::zeros(src.size(),CV_8U);
		Mat bmask = Mat::zeros(src.size(),CV_8U);

		boundaryDetect(s, guid, bmap,bmask);

		Mat alpha;bmap.copyTo(alpha);bmap.setTo(128,bmask);

		Mat temp;
		for(int i=0;i<iter_g;i++)
		{
			guidedFilter(alpha,ref,temp,r_g,eps_g/100.0f);
			temp.copyTo(alpha);
			alpha.setTo(128,bmask);
		}
		Mat maskf,maskb;
		compare(alpha,255.0*((double)th_FB/100.0),maskf,CMP_GT);
		alpha.setTo(255,maskf);
		compare(alpha,255.0*(1.0-th_FB/100.0),maskb,CMP_LT);
		alpha.setTo(0,maskb);
		dispRefine(s,bmap,bmask,alpha);
	}
	s.copyTo(dest);
}
Пример #2
0
void mattingMethod::getAmap(Mat& img)
{
	Mat mask;
	Mat trimax;
	Mat trimin;
	for(int i=0;i<iter;i++)
	{
		maxFilter(trimap,trimax,Size(3,3));
		compare(trimap,0,mask,CMP_NE);
		trimax.copyTo(trimap,mask);

		minFilter(trimap,trimin,Size(3,3));
		compare(trimap,255,mask,CMP_NE);
		trimin.copyTo(trimap,mask);
	}
	
	Mat tmp;
	Mat imgG;cvtColor(img,imgG,CV_BGR2GRAY);
	for(int i=0;i<iter_g;i++)
	{
		guidedFilter(trimap,imgG,tmp,r_g,eps_g/100.0f);
		tmp.copyTo(trimap);
	}

}
Пример #3
0
	void HazeRemove::operator() (Mat& src, Mat& dest, int r_dark, double toprate, int r_joint, double e_joint)
	{
		size = src.size();

		darkChannel(src, r_dark);
		getAtmosphericLight(src, toprate);
		getTransmissionMap();
		Mat srcg;
		cvtColor(src, srcg, CV_BGR2GRAY);
		guidedFilter(tmap, srcg, tmap, r_joint, (float)e_joint);
		removeHaze(src, tmap, A, dest);
	}