/* jsppmcmap.h - colormap routines */ /* Last edited on 2006-11-20 20:34:10 by stolfi */ #ifndef jsppmcmap_H #define jsppmcmap_H #include /* RGB COLOR HISTOGRAMS */ typedef struct rgb_pixel_t { pnm_sample_t c[3]; } rgb_pixel_t; typedef struct ppm_cmapx_hist_item* ppm_cmapx_hist_vector; struct ppm_cmapx_hist_item { rgb_pixel_t color; int value; }; typedef struct ppm_cmapx_list_item* ppm_cmapx_list; struct ppm_cmapx_list_item { struct ppm_cmapx_hist_item ch; ppm_cmapx_list next; }; ppm_cmapx_hist_vector ppm_cmapx_hist_build (rgb_pixel_t** pixels, int cols, int rows, int maxcolors, int* colorsP); /* Returns a {ppm_cmapx_hist_vector} {*colorsP} long (with space allocated for {maxcolors}. */ void ppm_cmapx_hist_add (ppm_cmapx_hist_vector chv, int* colorsP, int maxcolors, rgb_pixel_t* colorP, int value, int position); void ppm_cmapx_hist_free (ppm_cmapx_hist_vector chv); /* HASH TABLE FOR RGB COLORS */ typedef ppm_cmapx_list* ppm_cmapx_table; ppm_cmapx_table ppm_cmapx_table_build (rgb_pixel_t** pixels, int cols, int rows, int maxcolors, int* colorsP); int ppm_cmapx_table_lookup (ppm_cmapx_table cht, rgb_pixel_t* colorP); ppm_cmapx_hist_vector ppm_cmapx_table_to_hist (ppm_cmapx_table cht, int maxcolors); ppm_cmapx_table ppm_cmapx_hist_to_table (ppm_cmapx_hist_vector chv, int colors); int ppm_cmapx_table_add (ppm_cmapx_table cht, rgb_pixel_t* colorP, int value); /* Returns -1 on failure. */ ppm_cmapx_table ppm_cmapx_table_alloc (void); void ppm_cmapx_table_free (ppm_cmapx_table cht); #endif