source: foam/trunk/vision/src/Image.h @ 90

Revision 90, 2.0 KB checked in by dave, 10 years ago (diff)

PCA updated - projection and resynthesis seem to work

Line 
1// Copyright (C) 2009 foam
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License as published by
5// the Free Software Foundation; either version 2 of the License, or
6// (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17#include "cv.h"
18#include "Vector.h"
19#include <string>
20
21#ifndef IMAGE
22#define IMAGE
23
24class Image
25{
26public:
27        Image(int w, int h, int d, int c);
28        Image(const std::string &filename);
29        Image(const Image &other);
30        Image(const IplImage *other); // copies the given image
31        Image(int w, int h, int c, const Vector<float> &v, float gain=1.0f);
32        ~Image();
33
34        void Clear();
35
36        Image operator-(const Image &other);
37        Image operator+(const Image &other);
38        Image &operator=(const Image &other);
39
40        void PrintInfo();
41       
42        void Crop(int x, int y, int w, int h);
43        Image Scale(int w, int h);
44
45        // Paste an image into this one
46        void Blit(const Image &image, int x, int y);
47       
48        // Return a sum of squared differences, for giving a similarity metric
49        float SSD(Image &other);
50       
51        // Subtract the mean - this is useful for accounting for global lighting changes
52        void SubMean();
53       
54        // Convert the image into a local binary patterns image
55        void LBP();
56       
57        // Convert to different colour spaces
58        Image GRAY2RGB();
59        Image RGB2GRAY();
60        Image BayerGB2RGB();
61       
62        // Calculate a histogram for a given channel
63        unsigned int *Hist(int channel);
64       
65        Vector<float> ToFloatVector();
66        unsigned int NumElements() { return m_Image->width*m_Image->height*m_Image->nChannels; }
67       
68        IplImage *m_Image;
69       
70private:
71        unsigned char SafeGet2D(int y, int x, int c);
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.