/home/ooechs/ECJ_Tutorial/src/ac/essex/ecj/util/TrainingData.java
|
package ac.essex.ecj.util;
import ac.essex.ecj.imaging.PixelLoader;
/**
* <p/>
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version,
* provided that any use properly credits the author.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details at http://www.gnu.org
* </p>
*
* @author Olly Oechsle, University of Essex, Date: 18-Aug-2006
* @version 1.0
*/
public class TrainingData {
public PixelLoader image;
public PixelLoader truth;
/**
* Initialises the Training Data with two images, one the actual training image itself
* and the second a truth "map" of 'correct' and 'incorrect' pixels. For the sake of
* simplicity, the map represents incorrect pixels as black (RGB: 0,0,0), and correct
* pixels as non-black pixels (although preferably white!)
*
* Both the images should be of the same dimensions, otherwise an exception is thrown,
*/
public TrainingData(PixelLoader image, PixelLoader truth) {
this.image = image;
this.truth = truth;
if ((image.getWidth() != truth.getWidth()) || (image.getHeight() != truth.getHeight())) {
throw new RuntimeException("Truth image and test image are not the same size.");
}
}
/**
* Returns whether a given pixel is correct or not.
*/
public boolean isExpected(int x, int y) {
return truth.getPixel(x, y) > 0;
}
}