Browse Source

Fix clipping on linear equalise

tags/v1.8.0
Xerbo 4 years ago
parent
commit
d2880a6406
1 changed files with 7 additions and 4 deletions
  1. +7
    -4
      image.c

+ 7
- 4
image.c View File

@@ -90,16 +90,19 @@ void linearEnhance(float **prow, int nrow, int offset, int width){
// Find min/max points
int min = -1, max = -1;
for(int i = 5; i < 250; i++){
if(histogram[i]/width/(nrow/255.0) > 0.25){
if(histogram[i]/width/(nrow/255.0) > 0.1){
if(min == -1) min = i;
max = i;
}
}

// Stretch the brightness into the new range
for(int y = 0; y < nrow; y++)
for(int x = 0; x < width; x++)
for(int y = 0; y < nrow; y++){
for(int x = 0; x < width; x++){
prow[y][x+offset] = (prow[y][x+offset]-min) / (max-min) * 255.0;
prow[y][x+offset] = CLIP(prow[y][x+offset], 0.0, 255.0);
}
}
}

// Brightness calibrate, including telemetry
@@ -397,4 +400,4 @@ void temperature(options_t *opts, image_t *img, int offset, int width){
}
}
printf("Done\n");
}
}

Loading…
Cancel
Save