-
Notifications
You must be signed in to change notification settings - Fork 3
/
mycv.h
40 lines (35 loc) · 797 Bytes
/
mycv.h
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
#ifndef MYCV_H
#define MYCV_H
typedef unsigned char uchar;
template<class T> class Image
{
private:
IplImage* imgp;
public:
Image(IplImage* img=0) {imgp=img;}
~Image(){imgp=0;}
void operator=(IplImage* img) {imgp=img;}
inline T* operator[](const int rowIndx) {
return ((T *)(imgp->imageData + rowIndx*imgp->widthStep));}
};
typedef struct{
unsigned char b,g,r;
} RgbPixel;
typedef struct{
float b,g,r;
} RgbPixelFloat;
typedef Image<RgbPixel> RgbImage;
typedef Image<RgbPixelFloat> RgbImageFloat;
typedef Image<unsigned char> BwImage;
typedef Image<float> BwImageFloat;
uchar trimax(uchar x,uchar y,uchar z)
{
uchar t=(x>y)?x:y;
return ((t>z)?t:z);
}
uchar trimin(uchar x,uchar y,uchar z)
{
uchar t=(x<y)?x:y;
return ((t<z)?t:z);
}
#endif