From 05e9507e1468ba0dce3efd448f7227aef8b49eff Mon Sep 17 00:00:00 2001 From: Thierry Leconte Date: Wed, 24 Aug 2005 20:30:36 +0000 Subject: [PATCH] add gvi colormap --- Makefile | 2 +- fcolor.c | 20 +++++++++++--------- main.c | 16 ++++++++++------ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 7ca4165..93d2631 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ OBJS= main.o image.o dsp.o filter.o reg.o fcolor.o atpdec: $(OBJS) $(CC) -o $@ $(OBJS) -lm -lsndfile -lpng -main.o: main.c version.h temppalette.h offsets.h +main.o: main.c version.h temppalette.h gvipalette.h offsets.h dsp.o: dsp.c filtercoeff.h filter.h filter.o: filter.c filter.h image.o: image.c satcal.h offsets.h diff --git a/fcolor.c b/fcolor.c index f36bb22..a225017 100644 --- a/fcolor.c +++ b/fcolor.c @@ -70,7 +70,7 @@ static struct { hsvpix_t GroundTop; hsvpix_t GroundBot; } fcinfo = { - 30.0, 90.0, 100.0, { + 30.0, 90.0, 155.0, { 230, 0.2, 0.3}, { 230, 0.0, 1.0}, { 200.0, 0.7, 0.6}, { @@ -112,25 +112,25 @@ void falsecolor(double v, double t, float *r, float *g, float *b) hsvpix_t top, bot, c; double scv, sct; - if (t < fcinfo.Tthresold) { + if (t > fcinfo.Tthresold) { if (v < fcinfo.Seathresold) { /* sea */ top = fcinfo.SeaTop, bot = fcinfo.SeaBot; scv = v / fcinfo.Seathresold; - sct = t / fcinfo.Tthresold; + sct = (256.0-t) / (256.0-fcinfo.Tthresold); } else { /* ground */ top = fcinfo.GroundTop, bot = fcinfo.GroundBot; scv = (v - fcinfo.Seathresold) / (fcinfo.Landthresold - fcinfo.Seathresold); - sct = t / fcinfo.Tthresold; + sct = (256.0-t) / (256.0-fcinfo.Tthresold); } } else { /* clouds */ top = fcinfo.CloudTop, bot = fcinfo.CloudBot; - scv = v / 255.0; - sct = t / 255.0; + scv = v / 256.0; + sct = (256.0-t) / 256.0; } c.s = top.s + sct * (bot.s - top.s); @@ -140,11 +140,11 @@ void falsecolor(double v, double t, float *r, float *g, float *b) HSVtoRGB(r, g, b, c); }; -void Ngiv(float **prow, int nrow) +void Ngvi(float **prow, int nrow) { int n; - printf("Vegetation ... "); + printf("GVI ... "); fflush(stdout); for (n = 0; n < nrow; n++) { @@ -154,9 +154,11 @@ void Ngiv(float **prow, int nrow) pixelv = prow[n]; for (i = 0; i < CH_WIDTH; i++) { float pv; + double gvi; - pv = (pixelv[i + CHA_OFFSET]-pixelv[i + CHB_OFFSET])/(pixelv[i + CHA_OFFSET]+pixelv[i + CHB_OFFSET])*128.0+128.0; + gvi = (pixelv[i + CHA_OFFSET]-pixelv[i + CHB_OFFSET])/(pixelv[i + CHA_OFFSET]+pixelv[i + CHB_OFFSET]); + pv = (gvi+0.1)*340.0; if (pv > 255.0) pv = 255.0; if (pv < 0.0) diff --git a/main.c b/main.c index 53532df..98434fa 100644 --- a/main.c +++ b/main.c @@ -22,19 +22,23 @@ #include #include +#include + #ifdef WIN32 #include "w32util.h" #else #include #endif -#include + #include #include #include "version.h" -#include "temppalette.h" #include "offsets.h" +#include "temppalette.h" +#include "gvipalette.h" + extern int getpixelrow(float *pixelv); extern int init_dsp(double F);; @@ -271,7 +275,7 @@ fclose(df); extern int Calibrate(float **prow, int nrow, int offset); extern void Temperature(float **prow, int nrow, int ch, int offset); -extern int Ngiv(float **prow, int nrow); +extern int Ngvi(float **prow, int nrow); extern void readfconf(char *file); extern int optind, opterr; extern char *optarg; @@ -408,11 +412,11 @@ int main(int argc, char **argv) ImageRGBOut(pngfilename, prow, nrow); } -/* vegetation image */ +/* GVI image */ if (chA==1 && chB==2 && strchr(imgopt, (int) 'c') != NULL) { - Ngiv(prow, nrow); + Ngvi(prow, nrow); sprintf(pngfilename, "%s/%s-c.png", pngdirname, name); - ImageOut(pngfilename, "Vegetation", prow, nrow, CH_WIDTH, CHB_OFFSET, (png_color*)TempPalette); + ImageOut(pngfilename, "GVI", prow, nrow, CH_WIDTH, CHB_OFFSET, (png_color*)GviPalette); } } exit(0);