code: public double computeConfidence( int x0 , int y0 , int x1 , int y1 ) {
  
  		computeNccDescriptor(observed,x0,y0,x1,y1);
  
  		// distance from each set of templates
  		if( templateNegative.size() > 0 && templatePositive.size() > 0 ) {
  			double distancePositive = distance(observed,templatePositive);
  			double distanceNegative = distance(observed,templateNegative);
  
  			return distanceNegative/(distanceNegative + distancePositive);
  		} else if( templatePositive.size() > 0 ) {
  			return 1.0-distance(observed,templatePositive);
  		} else {
  			return distance(observed,templateNegative);
  		}
  	}
docs: Compute a value which indicates how confident the specified region is to be a member of the positive set.
  The confidence value is from 0 to 1.  1 indicates 100% confidence.
  
  Positive and negative templates are used to compute the confidence value.  Only the point in each set
  which is closest to the specified region are used in the calculation.
  
  @return value from 0 to 1, where higher values are more confident