void normalize(ImageProcessor ip, double min, double max) { int min2 = 0; int max2 = 255; int range = 256; if (ip instanceof ShortProcessor) {max2 = 65535; range=65536;} else if (ip instanceof FloatProcessor) normalizeFloat(ip, min, max); int[] lut = new int[range]; for (int i=0; i<range; i++) { if (i<=min) lut[i] = 0; else if (i>=max) lut[i] = max2; else lut[i] = (int)(((double)(i-min)/(max-min))*max2); } applyTable(ip, lut); }
void normalize(ImageProcessor ip, double min, double max) { int min2 = 0; int max2 = 255; int range = 256; if (ip instanceof ShortProcessor) {max2 = 65535; range=65536;} else if (ip instanceof FloatProcessor) normalizeFloat(ip, min, max); int[] lut = new int[range]; for (int i=0; i<range; i++) { if (i<=min) lut[i] = 0; else if (i>=max) lut[i] = max2; else lut[i] = (int)(((double)(i-min)/(max-min))*max2); } applyTable(ip, lut); }
private void equalize(ImageProcessor ip, int[] histogram) { ip.resetRoi(); if (ip instanceof ShortProcessor) { // Short max = 65535; range = 65535; } else { //bytes max = 255; range = 255; } double sum; sum = getWeightedValue(histogram, 0); for (int i=1; i<max; i++) sum += 2 * getWeightedValue(histogram, i); sum += getWeightedValue(histogram, max); double scale = range/sum; int[] lut = new int[range+1]; lut[0] = 0; sum = getWeightedValue(histogram, 0); for (int i=1; i<max; i++) { double delta = getWeightedValue(histogram, i); sum += delta; lut[i] = (int)Math.round(sum*scale); sum += delta; } lut[max] = max; applyTable(ip, lut); }
private void equalize(ImageProcessor ip, int[] histogram) { ip.resetRoi(); if (ip instanceof ShortProcessor) { // Short max = 65535; range = 65535; } else { //bytes max = 255; range = 255; } double sum; sum = getWeightedValue(histogram, 0); for (int i=1; i<max; i++) sum += 2 * getWeightedValue(histogram, i); sum += getWeightedValue(histogram, max); double scale = range/sum; int[] lut = new int[range+1]; lut[0] = 0; sum = getWeightedValue(histogram, 0); for (int i=1; i<max; i++) { double delta = getWeightedValue(histogram, i); sum += delta; lut[i] = (int)Math.round(sum*scale); sum += delta; } lut[max] = max; applyTable(ip, lut); }