public void extractFeatures(List regions) throws FeatureExtractorException {
    for (int i = 0; i < regions.size() - 1; ++i) {
      Region r = (Region) regions.get(i);
      Region next_r = (Region) regions.get(i + 1);

      for (String feature : features) {
        if (r.hasAttribute(feature) && next_r.hasAttribute(feature)) {

          if (!(r.getAttribute(feature) instanceof Number))
            throw new FeatureExtractorException(
                "Cannot calculate difference. Feature, " + feature + ", is not a Number on region, " + r);
          if (!(next_r.getAttribute(feature) instanceof Number))
            throw new FeatureExtractorException(
                "Cannot calculate difference. Feature, " + feature + ", is not a Number on region, " + next_r);

          Number value =
              ((Number) next_r.getAttribute(feature)).doubleValue() - ((Number) r.getAttribute(feature)).doubleValue();
          r.setAttribute("diff_" + feature, value);
        }
      }
    }
  }