private void calculateGreyValues() { int size = image.getPixelCount(); int gray; for (int pos = 0; pos < size; pos++) { gray = image.get(pos); grayValue[pos] = (byte) (gray / GRAY_SCALE); // quantized for texture analysis grayHistogram[gray]++; } Arrays2.div(grayHistogram, size); }
private void process(ColorProcessor ip) { double[] feature = new double[binX * binY * binZ]; int processedPixels = 0; ImageProcessor mask = ip.getMask(); int numpixels = ip.getPixelCount(); float[] hsbvals = new float[3]; // Conversion buffer for (int i = 0; i < numpixels; i++) { if (mask == null || mask.get(i) != 0) { if (type == TYPE.HSB) { feature[getBinForHSB(ip.get(i), hsbvals)]++; } else if (type == TYPE.RGB) { feature[getBinForRGB(ip.get(i))]++; } processedPixels++; } } Arrays2.div(feature, processedPixels); addData(feature); }
/** * Normalizes the array by the given sum. by dividing each 2nd dimension array componentwise by * the sum. * * @param A * @param sum */ private void normalize(double[][] A, double sum) { for (int i = 0; i < A.length; i++) { Arrays2.div(A[i], sum); } }