void normalize( uint8_t array[],
unsigned int cols,
unsigned int rows )
{
uint8_t darkest = min(array, cols, rows);
uint8_t lightest = max(array, cols, rows);
uint8_t arr[lightest-darkest+1];
double scale_factor = (255/(lightest-darkest));
int k =0;
for(int i=darkest; i<lightest-darkest+1; i++){
arr[k] = i;
k++;
}
for(int i=0; i<cols*rows; i++){
for(int k=0; k<lightest-darkest+1; k++){
if(array[i] == arr[k]){
double new = round(k*scale_factor);
array[i] = (uint8_t) new;
break;
}
}
}
}
No comments:
Post a Comment