-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIP.h
More file actions
43 lines (37 loc) · 1.39 KB
/
IP.h
File metadata and controls
43 lines (37 loc) · 1.39 KB
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
43
/* ======================================================================
* IP.h - Image processing header file.
* Copyright (C) 2014 by George Wolberg
*
* Written by: George Wolberg, 2014
* ======================================================================
*/
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#define MaxGray 255
#define MXGRAY 256
#define NEWIMAGE ((imageP) malloc(sizeof(imageS)))
/* useful macros */
#define ABS(A) ((A) >= 0 ? (A) : -(A))
#define SGN(A) ((A) > 0 ? 1 : ((A) < 0 ? -1 : 0 ))
#define ROUND(A) ((A) >= 0 ? (int)((A)+.5) : -(int)(.5-(A)))
#define FLOOR(A) ((A) >= 0 ? (int) (A) : (int) (A)-1)
#define CEILING(A) ((A)==FLOOR(A) ? FLOOR(A) : SGN(A)+FLOOR(A))
#define MAX(A,B) ((A) > (B) ? (A) : (B))
#define MIN(A,B) ((A) < (B) ? (A) : (B))
#define SWAP(A,B) { double temp=(A); (A) = (B); (B) = temp; }
#define SWAP_INT(A,B) { (A) ^= (B); (B) ^= (A); (A) ^= (B); }
#define CLAMP(A,L,H) ((A)<=(L) ? (L) : (A)<=(H) ? (A) : (H))
typedef unsigned char uchar;
typedef struct { /* image data structure */
int width; /* image width (# cols) */
int height; /* image height (# rows) */
uchar *image; /* pointer to image data */
} imageS, *imageP;
extern imageP IP_readImage (char *);
extern void IP_saveImage (imageP, char*);
extern imageP IP_allocImage (int, int, int);
extern void IP_freeImage (imageP);