about summary refs log tree commit diff
path: root/converter/other/pamtosvg/image-proc.h
blob: 0607d3dd9ff76fbf8fa8e4fcb4db1cb7da0fde6f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* image-proc.h: image processing routines */

#ifndef IMAGE_PROC_H
#define IMAGE_PROC_H

#include "bitmap.h"
#include "exception.h"


/* Threshold for binarizing a monochrome image */
#define GRAY_THRESHOLD 225

/* RGB to grayscale */
#define LUMINANCE(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11 + 0.5)


typedef struct
{
  unsigned height, width;
  float **weight;
  float **d;
} distance_map_type;


/* Allocate and compute a new distance map. */
extern distance_map_type new_distance_map(bitmap_type,
    unsigned char target_value, bool padded,
                                          at_exception_type * exp);

/* Free the dynamically-allocated storage associated with a distance map. */
extern void free_distance_map(distance_map_type*);


/* Binarize a grayscale or color image. */
extern void binarize(bitmap_type*);


/* Thin a binary image, replacing the original image with the thinned one. */
extern bitmap_type ip_thin(bitmap_type);

#endif /* not IMAGE_PROC_H */