예제 #1
0
bool VarianceFilter::filter(Mat& ii, Mat& iiSqr, BoundingBox& bb) {
	if(!enabled) return true;

	bb.var = computeVar(ii,iiSqr, bb);

	
	//printf("BLOCKED BY VARIANCE! Var: %f initVar: %f\n",bb.var,minVar);
	if(bb.var < minVar) {
		return false;
	}
	return true;
}
예제 #2
0
// main process
int process (Mat &cimg, int xstart, int ystart, int xend,
             int yend, int offset, double threshold,
             PicNodeList* picNodeList, RefillList* refillList) {
    
    if (xend - xstart < 4 || yend - ystart < 4 || offset < 4)
        return 0;
    
	int x = xstart;
	int y = ystart;
    
    printf("xend = %d\n", xend);
    printf("yend = %d\n", yend);
    
	while (x < xend) {
        //printf("x = %d\n", x);
		y = ystart;
		while (y < yend) {
			printf("x = %d, y = %d\n", x, y);
            
			int xp;
			int yp;
			if (x + offset >= cimg.rows)
				xp = cimg.rows - 1;
			else
				xp = x + offset;
			if (y + offset >= cimg.cols)
				yp = cimg.cols - 1;
			else
				yp = y + offset;
            
			Color *avgs = (Color*) malloc (sizeof(Color));
			computeAvg (cimg, x, y, xp, yp, avgs);
			Color *vars = (Color*) malloc (sizeof(Color));
			computeVar (cimg, x, y, xp, yp, avgs, vars);
            
			if (checkVar(vars, threshold)) {
				process (cimg, x, y, xp, yp, offset / 2, threshold, picNodeList, refillList);
                y += offset;
                continue;
			}
            
			PicNode *picNode = nullptr;
			if (findProperPic (avgs, vars, &picNode, picNodeList) == -1) {
                return -1;
			}
            
			ReplaceInfo *replaceInfo = (ReplaceInfo*) malloc (sizeof(ReplaceInfo));
			memset(replaceInfo, 0, sizeof(ReplaceInfo));
			replaceInfo->xstart = x;
			replaceInfo->ystart = y;
			replaceInfo->xend = xp;
			replaceInfo->yend = yp;
			replaceInfo->pNext = NULL;
			replaceInfo->picNode = picNode;
			last->pNext = replaceInfo;
            
//            printf("begin cshou debug Last Node##############\n");
//            printNode(last);
//            printf("end cshou debug Last Node##############\n");
//            printNode(replaceInfo);
            
            last = replaceInfo;
            
			y += offset;
		}
		x += offset;
	}
    
	return 0;
}