コード例 #1
0
void Completer::complete(Token *root)
{
	completeTerm(root);
	// ->
	completePointerExpr(root);
	// ++, --, *
	completeIncDecGlobExpr(root);
	// **
	completePowerExpr(root);
	// !, ~, \, +, -, &, ~~
	completeSingleTermOperatorExpr(root);
	// =~, !~
	completeRegexpMatchExpr(root);
	// *, /, %, x
	completeHighPriorityDoubleOperatorExpr(root);
	// +, -, .
	completeLowPriorityDoubleOperatorExpr(root);
	// <<, >>
	completeShiftOperatorExpr(root);
	//handler, builtin functions
	completeNamedUnaryOperators(root);
	// <, >, <=, >=, lt, gt, le, ge
	completeHighPriorityCompareOperatorExpr(root);
	// ==, !=, <=>, eq, ne, cmp, ~~
	completeLowPriorityCompareOperatorExpr(root);
	// &, |, ^
	completeBitOperatorExpr(root);
	// &&, ||
	completeAndOrOperatorExpr(root);
	//?:
	completeThreeTermOperatorExpr(root);
	// =, +=, -=, *=, ...
	completeAssignExpr(root);
	// ,, =>
	completeCommaArrowExpr(root);
	// function args ....
	completeFunctionListExpr(root);
	completeBlockArgsFunctionExpr(root);
	completeReturn(root);
	// not, and, or, xor
	completeAlphabetBitOperatorExpr(root);
}
コード例 #2
0
double BidirectSimilarity::gradualResize(const cv::Mat &src, cv::Mat &dst, RosMat<Point> &reconst_src, RosMat<Point> &reconst_dst, bool randomInit) {
    
    
    double NumPatch_src = src.rows*src.cols, NumPatch_dst = dst.rows*dst.cols;
    
    #pragma omp parallel sections
    {
        #pragma omp section
        {
            PatchMatch patch_match = PatchMatch(PATCHWIDTH, PATCHWIDTH);
            patch_match.matchImageWithPrior(src, dst, reconst_dst, randomInit);
            patch_match.~PatchMatch();
        }
        
        #pragma omp section
        {
            PatchMatch patch_match = PatchMatch(PATCHWIDTH, PATCHWIDTH);
            patch_match.matchImageWithPrior(dst, src, reconst_src, randomInit);
            patch_match.~PatchMatch();
        }
    }
    
        
    Mat cohere_mat = Mat::zeros(dst.size(), dst.type());
    Mat cohere_count = Mat(dst.size(), CV_64FC1).setTo(0.000001);
    
    Mat complete_mat = Mat::zeros(dst.size(), dst.type());
    Mat complete_count = Mat(dst.size(), CV_64FC1).setTo(0.000001);
    
    double total_error = 0.0, cohere_error = 0.0, complete_error = 0.0;
    
    
    
    #pragma omp parallel sections
    {
        #pragma omp section
        {
            cohere_error = cohereTerm(src, dst, reconst_dst, cohere_mat, cohere_count)/NumPatch_dst;
        }
        
        #pragma omp section
        {
            complete_error = completeTerm(src, dst, reconst_src, complete_mat, complete_count)/NumPatch_src;
        }
    }
    
    total_error = cohere_error + complete_error;
//    cout<<total_error<<", ";
    
    
    for (int i = 0; i < cohere_mat.rows; i ++) {
        for (int j = 0; j < cohere_mat.cols; j ++) {
            
//            dst.at<Vec3d>(i, j) = ( cohere_mat.at<Vec3d>(i, j)/NumPatch_dst + complete_mat.at<Vec3d>(i, j)/NumPatch_src )/( cohere_count.at<double>(i, j)/NumPatch_dst + complete_count.at<double>(i, j)/NumPatch_src);
            
            dst.at<double>(i, j) = cohere_mat.at<double>(i, j)/cohere_count.at<double>(i, j);
            
        }
    }
    
    
    cohere_mat.release();
    cohere_count.release();
    complete_mat.release();
    complete_count.release();
    
    return total_error;
    
}
コード例 #3
0
double BidirectSimilarity::gradualResize (const cv::Mat &src, cv::Mat &dst, const Mat &mask, RosMat<Point> &reconst_src, RosMat<Point> &reconst_dst, bool randomInit) {

    
    double NumPatch_src = src.rows*src.cols, NumPatch_dst = dst.rows*dst.cols;
    
    #pragma omp parallel sections
    {
        #pragma omp section
        {
            PatchMatch patch_match = PatchMatch(PATCHWIDTH, PATCHWIDTH);
//            patch_match.matchImageWithPrior(src, dst, reconst_dst, randomInit);
            patch_match.matchPriorWithMask(src, dst, mask, reconst_dst, randomInit);
            patch_match.~PatchMatch();
        }
        
        #pragma omp section
        {
            PatchMatch patch_match = PatchMatch(PATCHWIDTH, PATCHWIDTH);
            patch_match.matchImageWithPrior(dst, src, reconst_src, randomInit);
//            patch_match.matchPriorWithMask(src, dst, mask, reconst_src, randomInit);
            patch_match.~PatchMatch();
        }
    }
    
        
    for (int i = 0; i < mask.rows; i ++) {
        for (int j = 0; j < mask.cols; j ++) {
            
            if ( mask.at<double>(i, j) != 1 ) {
                
                reconst_dst.at(i, j) = Point(-j, -i);
            }
            
        }
    }
    
    Mat cohere_mat = Mat::zeros(dst.size(), dst.type());
    Mat cohere_count = Mat(dst.size(), CV_64FC1).setTo(0.000001);
    
    Mat complete_mat = Mat::zeros(dst.size(), dst.type());
    Mat complete_count = Mat(dst.size(), CV_64FC1).setTo(0.000001);
    
    double total_error = 0.0, cohere_error = 0.0, complete_error = 0.0;
    
    
    
//    #pragma omp parallel sections
//    {
//        #pragma omp section
//        {
            cohere_error = cohereTerm(src, dst, reconst_dst, cohere_mat, cohere_count)/NumPatch_dst;
//        }
//            
//        #pragma omp section
//        {
            complete_error = completeTerm(src, dst, reconst_src, complete_mat, complete_count)/NumPatch_src;
//        }
//    }
    
    total_error = cohere_error + complete_error;

    
    for (int i = 0; i < cohere_mat.rows; i ++) {
        for (int j = 0; j < cohere_mat.cols; j ++) {
        
            dst.at<double>(i, j) = ( cohere_mat.at<double>(i, j)/NumPatch_dst + complete_mat.at<double>(i, j)/NumPatch_src )/( cohere_count.at<double>(i, j)/NumPatch_dst + complete_count.at<double>(i, j)/NumPatch_src) * mask.at<double>(i, j);
            
        }
    }
    
    
    cohere_mat.release();
    cohere_count.release();
    complete_mat.release();
    complete_count.release();
    
    return total_error;
    
}