@Override
  public IplImage process(IplImage img) {

    /*
    		if(convertFromColor) {
    			imageConversion.convertFromRGB(img, grayImage);
    		} else {
    			imageConversion.convertFromGray(img, grayImage);
    		}
    */

    blur.apply(grayImage, blurImage);
    IplImage bkImage = background.update(blurImage);
    if (bkImage == null) return null;

    ImageDifference.apply(bkImage, blurImage, diffImage);

    thresh.apply(diffImage, threshImage);

    synchronized (blobs) {
      Vector<Blob> allBlobs = new Vector<Blob>(newFrameBlobs.size());
      // probably should come up with some kind of double (or triple buffer) for this rather than
      // re-allocating vectors every frame
      blobs.detectBlobs(threshImage2.getData());
      for (int i = 0; i < regionMap.size(); i++) {
        Vector<Blob> detected = blobs.getDetectedBlobs(i);
        Vector<Blob> newBlobs = new Vector<Blob>(detected.size());
        newBlobs.addAll(detected);
        allBlobs.addAll(detected);
        tracker[i].queueBlobs(newBlobs);
      }
      newFrameBlobs = allBlobs;
    }

    switch (mode) {
      case raw:
        return img;
      case background:
        return bkImage;
      case diff:
        return diffImage;
      case thresh:
      case running:
        return threshImage2;
      default:
        return img;
    }
  }
 public double getThresh() {
   return thresh.getThreshold();
 }
 public void setThresh(double d) {
   thresh.setThreshold(d);
 }