segmentation
All Data Structures Namespaces Files Functions Variables Modules Pages
BgImage.h
1 // Name: BgImage.h
3 // Purpose: BgImage class
4 // Author: Bogdan Georgescu
5 // Modified by:
6 // Created: 06/22/2000
7 // Copyright: (c) Bogdan Georgescu
8 // Version: v0.1
10 
11 #ifndef _BG_IMAGE_H
12 #define _BG_IMAGE_H
13 
14 #include <assert.h>
15 
16 #define RED_WEIGHT 0.299
17 #define GREEN_WEIGHT 0.587
18 #define BLUE_WEIGHT 0.114
19 
20 class BgImage
21 {
22 public:
23  int x_;
24  int y_;
25  unsigned char* im_;
26  bool hasIm_;
27  bool colorIm_; // false - bw image
28  // true - color RGB image
29 
30  BgImage();
31  BgImage(int, int, bool colorIm = false);
32  ~BgImage();
33 
34  void SetImage(unsigned char*, int, int, bool colorIm = false);
35  void SetImageFromRGB(unsigned char*, int, int, bool colorIm = false);
36  void SetSameImageFromRGB(unsigned char*);
37  void SetImage(short*, int, int, bool colorIm = false);
38  void GetImage(unsigned char*);
39  void GetImageBW(unsigned char*);
40  void GetImageColor(unsigned char*);
41  void GetImageR(unsigned char*);
42  void GetImageG(unsigned char*);
43  void GetImageB(unsigned char*);
44  bool ValidCoord(int, int);
45  int ValidReturnBW(int in_x, int in_y, int& cval);
46  int ValidReturnCol(int in_x, int in_y, int& rval, int& gval, int& bval);
47  int ReturnCol(int in_x, int in_y, int& rval, int& gval, int& bval);
48 
49  inline int GetWidth() {return x_;};
50  inline int GetHeight() {return y_;};
51 
52 
53  const BgImage& operator=(const BgImage& im);
54  bool IsAllocated(void) const;
55 
56  void CleanData();
57  inline unsigned char operator()(int, int) const;
58  inline unsigned char& operator()(int, int);
59  unsigned char PixelValue(int, int);
60 
61  void Resize(int width, int height, bool color);
62 
63 private:
64  void PrivateCopyToThis(const BgImage& im);
65  void PrivateResize(int width, int height, bool color);
66 
67 
68 };
69 extern inline unsigned char gBgImPt(BgImage*, int, int);
70 
71 #endif