/** * Course material for the "Konenako 2010" course. */ /** * Abstract base class for a dumb grayscale image feature * extractor. Why is it dumb? Because it only deals with grayscale * images which must be encoded as row-major vectors of double * numbers. This was the fastest route for me to prepare exercises for * the hands-on lecture on 2010-11-18. In reality, you would use some * image processing library such as ImageJ. * * How to use: You derive a concrete SomeExtractor and implement the * method extractFromGrayscale() which gets a height-by-width double * array as argument and is expected to return a double vector * containing the nice features extracted by your code. * * @author nieminen * */ public abstract class AbstractDumbGrayscaleFeatureExtractor implements FeatureExtractor{ protected int height; protected int width; public AbstractDumbGrayscaleFeatureExtractor(){ throw new RuntimeException("Must not instantiate without height and width."); } public AbstractDumbGrayscaleFeatureExtractor(int height,int width) { this.height=height; this.width=width; } /** * Extracts a feature from a raw vector. In this case we assume that it is * a grayscale image encoded as a row-major 1d array (concatenated rows). * * @param input * @return */ public double[] extractFromRawVector(double[] input){ double[][] image = new double[height][width]; for(int row=0;row