/** * Provides a much faster way of serialization. * * @return a byte array that can be read with the corresponding method. * @see CEDD#setByteArrayRepresentation(byte[]) */ @Override public byte[] getByteArrayRepresentation() { return SerializationUtils.toByteArray(feature); }
/** * Trims the white border around an image. * * @param img * @return a new image, hopefully trimmed. */ public static BufferedImage trimWhiteSpace(BufferedImage img, int whiteThreshold, int startTop, int startRight, int startBottom, int startLeft) { return trimWhiteSpace(img, img, whiteThreshold, startTop, startRight, startBottom, startLeft); }
@Override public double[] getFeatureVector() { int[] result = new int[NumberOfCoefficients]; for (int i = 2; i < result.length; i++) { result[i] = haarTransformedHistogram[i]; } return ConversionUtils.toDouble(result); }
/** * by patch contributed by Franz Graf, franz.graf@gmail.com * @return the feature vector as double[] */ @Override public double[] getFeatureVector() { return SerializationUtils.toDoubleArray(descriptorValues); }
/** * Returns the vector representation in string format. * @return the vector representation as string. */ public String toString() { return SerializationUtils.toString(histogram);}
/** * Creates an IndexWriter for given index path, with a SimpleAnalyzer. * * @param indexPath the path to the index directory * @param create set to true if you want to create a new index * @return the IndexWriter * @throws IOException */ public static IndexWriter createIndexWriter(String indexPath, boolean create) throws IOException { return createIndexWriter(indexPath, create, AnalyzerType.SimpleAnalyzer); //TODO: Simple or Standard ?? }
@Override public double getDistance(LireFeature f) { if (!(f instanceof SurfFeature)) return -1; return MetricsUtils.distL2(feature, ((SurfFeature) f).feature); }
@Override public void setByteArrayRepresentation(byte[] in) { int[] result = SerializationUtils.toIntArray(in); NumberOfBitplanesDiscarded = result[0]; NumberOfCoefficients = result[1]; haarTransformedHistogram = new int[result.length - 2]; for (int i = 2; i < result.length; i++) { haarTransformedHistogram[i - 2] = result[i]; } }
/** * Returns the vector representation in byte[] format. * @return the vector representation as a byte array. */ @Override public byte[] getByteVectorRepresentation() { return SerializationUtils.toByteArray(vector); }
/** * Reads descriptor from a byte array. Much faster than the String based method. * * @param in byte array from corresponding method * @see CEDD#getByteArrayRepresentation */ @Override public void setByteArrayRepresentation(byte[] in) { feature = SerializationUtils.toDoubleArray(in); }
/** * Trims the white border around an image. * * @param img * @return a new image, hopefully trimmed. */ public static BufferedImage trimWhiteSpace(BufferedImage img) { return trimWhiteSpace(img, 250, 0, 0, 0, 0); }
@Override public double[] getFeatureVector() { int[] result = new int[NumberOfCoefficients]; for (int i = 2; i < result.length; i++) { result[i] = haarTransformedHistogram[i]; } return ConversionUtils.toDouble(result); }
/** * Returns the vector representation in string format. * @return the vector representation as string. */ @Override public String getStringVectorRepresentation() { return SerializationUtils.toString(vector); }
/** * Creates an IndexWriter for given index path, with a SimpleAnalyzer. * * @param indexPath the path to the index directory * @param create set to true if you want to create a new index * @return the IndexWriter * @throws IOException */ public static IndexWriter createIndexWriter(String indexPath, boolean create) throws IOException { return createIndexWriter(indexPath, create, AnalyzerType.SimpleAnalyzer); //TODO: Simple or Standard ?? }
/** * Returns the vector representation in byte[] format. * @return the vector representation as a byte array. */ @Override public byte[] getByteVectorRepresentation() { return SerializationUtils.toByteArray(histogram); }
public SiftFeature(float s, float o, float[] l, float[] d) { this.scale = s; this.orientation = o; this.location = l; this.descriptor = SerializationUtils.toDoubleArray(d); }
/** * Trims the white border around an image. * * @param img * @return a new image, hopefully trimmed. */ public static BufferedImage trimWhiteSpace(BufferedImage img, int whiteThreshold, int startTop, int startRight, int startBottom, int startLeft) { return trimWhiteSpace(img, img, whiteThreshold, startTop, startRight, startBottom, startLeft); }
/** * Creates a byte array representation from the clusters mean. * * @return the clusters mean as byte array. */ public byte[] getByteRepresentation() { return SerializationUtils.toByteArray(mean); }
/** * Trims the white border around an image. * * @param img * @return a new image, hopefully trimmed. */ public static BufferedImage trimWhiteSpace(BufferedImage img) { return trimWhiteSpace(img, 250, 0, 0, 0, 0); }
/** * Returns the vector representation in byte[] format. * @return the vector representation as a byte array. */ @Override public byte[] getByteVectorRepresentation() { return SerializationUtils.toByteArray(histogram); }