public static TrainingDataSet build(ImageTrainingBound trainBound, ImageFeatures extractor)
      throws IOException {

    double[] output, input;

    if (trainBound == null) return null;

    int totalOutput = trainBound.lastCategority + 1;

    TrainingDataSet dataSet = new TrainingDataSet(extractor.getTotalFeatures(), totalOutput);

    for (int i = 0; i < trainBound.list.size(); i++) {

      input = extractor.extract(trainBound.list.get(i).getImg());

      output = new double[totalOutput];

      for (int j = 0; j < totalOutput; j++) output[j] = (trainBound.outputBind[i] == j) ? 1.0 : 0.0;

      dataSet.registerTest(input, output);
    }

    return dataSet;
  }