From fb8dfc3de3563a6bd48923d1f76ff37134245856 Mon Sep 17 00:00:00 2001 From: Xerbo Date: Wed, 15 Jan 2020 00:27:56 +0000 Subject: [PATCH] Fix falsecolor --- fcolor.c | 6 +++--- pngio.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/fcolor.c b/fcolor.c index 621b811..d262992 100644 --- a/fcolor.c +++ b/fcolor.c @@ -65,16 +65,16 @@ int readfcconf(char *file) { return 1; }; -rgb_t falsecolor(float vis, float temp, float *r, float *g, float *b){ +rgb_t falsecolor(float vis, float temp){ rgb_t buffer; - float land = 0, sea, cloud; + float land = 0.0, sea, cloud; // Calculate intensity of sea sea = CLIP(vis+fcinfo.Seaoffset, 0, fcinfo.Seaintensity)/fcinfo.Seaintensity; // Land if(vis > fcinfo.Landthreshold) - land = CLIP(vis+fcinfo.Landoffset, 0, fcinfo.Landintensity)/fcinfo.Landintensity; + land = CLIP(vis-fcinfo.Landoffset, 0, fcinfo.Landintensity)/fcinfo.Landintensity; // Composite land on sea buffer = RGBcomposite(fcinfo.Land, land, fcinfo.Sea, sea); diff --git a/pngio.c b/pngio.c index 770839f..4e1b53b 100644 --- a/pngio.c +++ b/pngio.c @@ -288,20 +288,26 @@ int ImageOut(options_t *opts, image_t *img, int offset, int width, char *desc, c return 0; } - //extern void falsecolor(float vis, float temp, float *r, float *g, float *b); - printf("Writing %s", outName); - int fcimage = strcmp(chid, "False Color") == 0; + extern rgb_t falsecolor(float vis, float temp); + int fcimage = strcmp(desc, "False Color") == 0; // Build RGB image for (int y = 0; y < img->nrow; y++) { png_color pix[width]; for (int x = 0; x < width; x++) { - pix[x].red = (int)crow[y][x + offset].r; - pix[x].green = (int)crow[y][x + offset].g; - pix[x].blue = (int)crow[y][x + offset].b; + if(fcimage){ + rgb_t pixel = falsecolor(img->prow[y][x + CHA_OFFSET], img->prow[y][x + CHB_OFFSET]); + pix[x].red = pixel.r; + pix[x].green = pixel.g; + pix[x].blue = pixel.b; + }else{ + pix[x].red = (int)crow[y][x + offset].r; + pix[x].green = (int)crow[y][x + offset].g; + pix[x].blue = (int)crow[y][x + offset].b; + } } png_write_row(png_ptr, (png_bytep) pix);