code: public int checkBackground( float[] pixelValue , float[] dataRow , int modelIndex ) {
  
  		// see which gaussian is the best fit based on Mahalanobis distance
  		int index = modelIndex;
  		float bestDistance = maxDistance*numBands;
  		float bestWeight = 0;
  
  		int ng; // number of gaussians in use
  		for (ng = 0; ng < maxGaussians; ng++, index += gaussianStride) {
  			float variance = dataRow[index + 1];
  			if (variance <= 0) {
  				break;
  			}
  
  			float mahalanobis = 0;
  			for (int i = 0; i < numBands; i++) {
  				float mean = dataRow[index + 2+i];
  				float delta = pixelValue[i] - mean;
  				mahalanobis += delta * delta / variance;
  			}
  
  			if (mahalanobis < bestDistance) {
  				bestDistance = mahalanobis;
  				bestWeight = dataRow[index];
  			}
  		}
  
  		if( ng == 0 ) // There are no models. Return unknown
  			return unknownValue;
  		return bestWeight >= significantWeight ? 0 : 1;
  	}
docs: Checks to see if the the pivel value refers to the background or foreground
  
  @return true for background or false for foreground