Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

AnImage.hpp

00001 #ifndef _AnImage_H
00002 #define _AnImage_H
00003 
00004 #include <stdio.h>
00005 
00006 
00007 
00026 class RImage;                           
00027 class Real3CImage;                      
00028 
00029 class FImage;                           
00030 class Float3CImage;                     
00031 
00032 class CImage;                           
00033 class C3CImage;                         
00034 
00035 enum  AnImageType { 
00036                 ByteIm=0, 
00037                 ShortIm=1,                      // used for byte <0
00038                 UShortIm=2, 
00039                 IntIm=3 , 
00040                 RGBIm=10,
00041                 ARGBIm=11,
00042                 RGBs16Im=12,            // used for rgb <0
00043                 RGB16Im=20, 
00044                 RGBs32Im=22,            // used for rgb16 <0
00045                 UnknownIm=255
00046                 };
00047 
00048 class AnImage
00049 {
00050 protected:
00051 
00052 AnImageType                     type;
00053 
00054 int                                     x0, y0;                 
00055 
00056 
00057 int                                     width;  
00058 int                                     height;         
00059 
00060 int                                     nchannels;              
00061 int                                     pixelSize;              
00062 int                                     channelSize;    
00063 
00064 int                                     padding;
00065 
00066 int                                     lineSizeInBytes;   
00067 
00068         
00069 double                          PI;             
00070 
00072 int                                     maskValue;                      
00073 
00074 public:
00075 
00076 AnImage(int w, int h);
00077 AnImage(int w, int h, int channels);
00078 AnImage(int w, int h, int channels, int apixelSize, int achannelSize=1);
00079 virtual ~AnImage(){}
00080 
00081 virtual AnImageType getType(){ return type; }
00082 
00083 virtual AnImage* copy()=0;
00084 virtual AnImage* scaleDown(int multiplier=2)=0;
00085 virtual AnImage* scaleUp(int multiplier=2)=0;
00086 virtual AnImage* scaleUp(int multiplier, int r, int g, int b){return 0;}
00087 
00088 virtual AnImage* zeroInterleaving()=0;
00089 
00090 virtual AnImage* flipHorizontal();
00091 virtual AnImage* flipVertical();
00092 
00093 virtual AnImage* rotate90Left()=0;
00094 virtual AnImage* rotate90Right()=0;
00095 virtual AnImage* rotate180();
00096 
00097 virtual int available8BitsColors(){ return -1; }
00098 
00099 
00100 virtual void set(CImage& data, int ctype=0, int ch=0)=0;
00101 virtual void set(C3CImage& data, int ctype=0);
00102 
00103 virtual void set(RImage& data, int ch=0)=0;
00104 virtual void set(Real3CImage& data);
00105 
00106 virtual void set(FImage& data, int ch=0)=0;
00107 virtual void set(Float3CImage& data);
00108 
00109 virtual void setChannel(AnImage* channel, int ch=0){}
00110 
00111 virtual void setData(AnImage* src, AnImage* mask=0);
00112 virtual void setValues(unsigned char value){}
00113 virtual void setValues(int r, int g, int b);
00114 
00115 virtual int  getMaskValue(){return maskValue;}
00116 virtual void setMaskValue(int value){maskValue= value;}
00117 
00118 virtual AnImage* partImage(int x0=0, int y0=0, int w=256, int h=256)=0;
00119 virtual AnImage* subImage(int x0, int y0, int x1, int y1)=0;
00120 virtual AnImage* smallImage(double xscale, double yscale)=0;
00121 virtual AnImage* smallImage(int newWidth){return 0; }
00122 
00123 virtual void setOrigin(int xorig, int yorig){ x0= xorig; y0= yorig; }
00124 virtual int getX0(){ return x0; }
00125 virtual int getY0(){ return y0; }
00126 
00127 virtual void set(AnImage* image);
00128 
00129 virtual unsigned char* getData()=0;
00130 
00131 // data limits of each image type
00132 virtual int getMinBoundaryValue(){ return 0; }
00133 virtual int getMaxBoundaryValue(){ return 255; }
00134 virtual int getPower2MaxRangeBoundary(){ return 8; }
00135 
00136 int getWidth() const { return width; }  
00137 int getHeight() const { return height; }
00138 int getChannels(){ return nchannels; }
00139 int getPixelSize(){ return pixelSize; }
00140 int getChannelSize(){ return channelSize; }
00141 int getPadding(){ return padding; }
00142 
00143 int getByteSize(){ return size()*channelSize; }         
00144 
00145 int size(){ return width*height*nchannels; }
00146 
00147 virtual void setRed(int x, int y, int value)=0;
00148 virtual void setGreen(int x, int y, int value)=0;
00149 virtual void setBlue(int x, int y, int value)=0;
00150 virtual void setGrey(int x, int y, int value)=0;
00151 
00152 virtual void setRGB(int x, int y, int r, int g, int b)=0;
00153 virtual void set(int x, int y, int value)=0;
00154 
00155 virtual void setColor(int c, int x, int y, int val)
00156         {
00157         switch( c )
00158                 {
00159                 case 0:
00160                         setRed(x, y, val);
00161                         break;
00162                 case 1:
00163                         setGreen(x, y, val);
00164                         break; 
00165                 case 2:
00166                         setBlue(x, y, val);
00167                         break; 
00168                 default:
00169                         setRed(x, y, val);
00170                         break;
00171                 }
00172         }
00173 
00174 virtual int getRed(int x, int y)=0;
00175 virtual int getGreen(int x, int y)=0;
00176 virtual int getBlue(int x, int y)=0;
00177 virtual int getGrey(int x, int y)=0;
00178 
00179 virtual int get(int x, int y){ return getGrey(x,y); }
00180 virtual int get(int c, int x, int y)
00181         {
00182         int val=0;
00183         switch( c )
00184                 {
00185                 case 0:
00186                         val= getRed(x, y);
00187                         break;
00188                 case 1:
00189                         val= getGreen(x, y);
00190                         break; 
00191                 case 2:
00192                         val= getBlue(x, y);
00193                         break;
00194                 default:
00195                         val= getRed(x, y);
00196                         break; 
00197                 }
00198         return val;
00199         }
00200 
00201 // stepped value
00202 virtual int getGrey(int x, int y, int dx, int dy){ return getGrey(x*dx,y*dy); }
00203 virtual int getRed(int x, int y, int dx, int dy){ return getGrey(x*dx,y*dy); }
00204 virtual int getGreen(int x, int y, int dx, int dy){ return getGrey(x*dx,y*dy); }
00205 virtual int getBlue(int x, int y, int dx, int dy){ return getGrey(x*dx,y*dy); }
00206 
00207 virtual void setGrey(int x, int y, int dx, int dy, int value)
00208                 { setGrey(x*dx,y*dy, value); }
00209 virtual void setRed(int x, int y, int dx, int dy, int value)
00210                 { setRed(x*dx,y*dy, value); }
00211 virtual void setGreen(int x, int y, int dx, int dy, int value)
00212                 { setGreen(x*dx,y*dy, value); }
00213 virtual void setBlue(int x, int y, int dx, int dy, int value)
00214                 { setBlue(x*dx,y*dy, value); }
00215 
00216 virtual void replace(int pixel, int newPixel=0);
00217 virtual void replace(int red, int green, int blue, int newPixel=0);
00218 virtual void replace(int red, int green, int blue, int newR, int newG, int newB);
00219 
00220 virtual void setRgbFromLhs(int x,int y, double luminance, double hue, double saturation );
00221 virtual void setRgbFromYiq(int x,int y, double Y, double I, double Q );
00222 
00223 
00224 int getLineLength(){ return width; }
00225 int getLineByteSize(){ return lineSizeInBytes; }
00226 
00227 virtual void report(FILE* file);
00228 
00229 virtual void output();
00230 
00231 
00232 virtual void restaure(int model, int type, int iterations, double coeff)
00233                         { restaure(model, 1, type, iterations, coeff); }  // separate channels
00234 virtual void restaure(int model, int chMode,int type, 
00235                                           int iterations, double coeff, double rsat=0.5)
00236                         { restaure(type, iterations, coeff); } // default is RGB
00237 
00238 virtual void restaure(int type, int iterations, double coeff){}
00239 virtual void restaureLHS(int type, int iterations, double coeff, double rsat)
00240                                 { restaure(type, iterations, coeff); } // default is RGB
00241 virtual void restaureYIQ(int type, int iterations, double coeff)
00242                                 { restaure(type, iterations, coeff); } // default is RGB
00243 
00244 };
00245 
00246 #endif
SourceForge.net Logo
Restoreinpaint sourceforge project `C++/Java Image Processing, Restoration, Inpainting Project'.

Bernard De Cuyper: Open Project Leader: Concept, design and development.
Bernard De Cuyper & Eddy Fraiha 2002, 2003. Bernard De Cuyper 2004. Open and free, for friendly usage only.
Modifications on Belgium ground of this piece of artistic work, by governement institutions or companies, must be notified to Bernard De Cuyper.
bern_bdc@hotmail.com