When I try to use the following function to normalize the dynamic range of an image:
void normalize(uint8_t array[], unsigned int cols, unsigned int rows) {
uint8_t minValue = min(array, cols, rows);
uint8_t maxValue = max(array, cols, rows);
uint8_t MIN_RANGE = 0;
uint8_t MAX_RANGE = 255;
uint8_t new_range = MAX_RANGE - MIN_RANGE;
uint8_t old_range = maxValue - minValue;
int range = 0;
double scale = 0;
for (range = 0; range < rows * cols; range++) {
scale = (array[range] - minValue) / (old_range);
array[range] = scale * new_range + MIN_RANGE;
}
}
All I get is 0, but I can't identify the mistake. min() and max() are functions that work correctly to return the darkest and lightest colors respectively.