OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
color_quant.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
#include <stdint.h>
#include <math.h>
#include <imageutils.h>
Include dependency graph for color_quant.c:

Go to the source code of this file.

Classes

struct  oct_node
 
struct  node_heap
 

Macros

#define ON_INHEAP   1
 

Functions

img_rgb_timg_new (int w, int h)
 
void img_free (img_rgb_t *img)
 
int img_write_ppm (img_rgb_t *img, char *filename)
 
int read_num (FILE *f)
 
img_rgb_timg_read_ppm (char *filename)
 
int cmp_node (oct_node a, oct_node b)
 
void down_heap (node_heap *h, oct_node p)
 
void up_heap (node_heap *h, oct_node p)
 
void heap_add (node_heap *h, oct_node p)
 
oct_node pop_heap (node_heap *h)
 
oct_node node_new (uint8_t idx, uint8_t depth, oct_node p)
 
void node_free ()
 
oct_node node_insert (oct_node root, uint8_t *pix)
 
oct_node node_fold (oct_node p)
 
void color_replace (oct_node root, uint8_t *pix)
 
uint8_t find_color_index (oct_node root, uint8_t *pix)
 
void img_color_quant (img_rgb_t *im, int n_colors, int dither)
 
void img_color_palette_quantization (img_rgb_t *in_image, int num_colors, uint8_t *palette, uint8_t *out_image)
 

Macro Definition Documentation

◆ ON_INHEAP

#define ON_INHEAP   1

Definition at line 19 of file color_quant.c.

Function Documentation

◆ cmp_node()

int cmp_node ( oct_node  a,
oct_node  b 
)

Definition at line 98 of file color_quant.c.

◆ color_replace()

void color_replace ( oct_node  root,
uint8_t *  pix 
)

Definition at line 234 of file color_quant.c.

◆ down_heap()

void down_heap ( node_heap h,
oct_node  p 
)

Definition at line 107 of file color_quant.c.

◆ find_color_index()

uint8_t find_color_index ( oct_node  root,
uint8_t *  pix 
)

Definition at line 248 of file color_quant.c.

◆ heap_add()

void heap_add ( node_heap h,
oct_node  p 
)

Definition at line 140 of file color_quant.c.

◆ img_color_palette_quantization()

void img_color_palette_quantization ( img_rgb_t in_image,
int  num_colors,
uint8_t *  palette,
uint8_t *  out_image 
)

Take the input 24 bit full color RGB image and convert it into a color mapped image and color palette which have already been allocated by the caller.

Parameters
in_image24 bit RGB input image
num_colorsnumber of colors in the color palette
palettecolor palette (allocated by caller) 3 bytes (r,g,b) for each entry
out_imageoutput image data (allocated by caller)

Definition at line 300 of file color_quant.c.

◆ img_color_quant()

void img_color_quant ( img_rgb_t im,
int  n_colors,
int  dither 
)

Definition at line 263 of file color_quant.c.

◆ img_free()

void img_free ( img_rgb_t img)

Definition at line 48 of file color_quant.c.

◆ img_new()

img_rgb_t* img_new ( int  w,
int  h 
)

Definition at line 40 of file color_quant.c.

◆ img_read_ppm()

img_rgb_t* img_read_ppm ( char *  filename)

Definition at line 75 of file color_quant.c.

◆ img_write_ppm()

int img_write_ppm ( img_rgb_t img,
char *  filename 
)

Definition at line 54 of file color_quant.c.

◆ node_fold()

oct_node node_fold ( oct_node  p)

Definition at line 219 of file color_quant.c.

◆ node_free()

void node_free ( )

Definition at line 190 of file color_quant.c.

◆ node_insert()

oct_node node_insert ( oct_node  root,
uint8_t *  pix 
)

Definition at line 200 of file color_quant.c.

◆ node_new()

oct_node node_new ( uint8_t  idx,
uint8_t  depth,
oct_node  p 
)

Definition at line 173 of file color_quant.c.

◆ pop_heap()

oct_node pop_heap ( node_heap h)

Definition at line 159 of file color_quant.c.

◆ read_num()

int read_num ( FILE *  f)

Definition at line 63 of file color_quant.c.

◆ up_heap()

void up_heap ( node_heap h,
oct_node  p 
)

Definition at line 124 of file color_quant.c.