From 46aa64da0124a712e10b07ae71e8fe6d436a28e2 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Thu, 25 May 2023 10:37:33 +0200 Subject: [PATCH] cnn/export:write_image:Increase brightness --- src/cnn/export.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/cnn/export.c b/src/cnn/export.c index f75549f..4bfa151 100644 --- a/src/cnn/export.c +++ b/src/cnn/export.c @@ -94,9 +94,16 @@ void write_image(float** data, int width, int height, char* base_filename, int l image->height = height; image->lpData = (unsigned char*)malloc(sizeof(unsigned char)*width*height*3); + float maxi = 1e-7; for (int i=0; i < height; i++) { for (int j=0; j < width; j++) { - float color = fmax(fmin(data[i][j], 1.), 0.)*255; + maxi = fmax(maxi ,data[i][j]); + } + } + + for (int i=0; i < height; i++) { + for (int j=0; j < width; j++) { + float color = fmax(data[i][j]/maxi, 0.)*255; image->lpData[(i*width+j)*3] = color; image->lpData[(i*width+j)*3 + 1] = color;