00001 #ifndef _RGBImage_H 00002 #define _RGBImage_H 00003 00004 00005 00025 #include <stdio.h> 00026 00027 #include "AnImage.hpp" 00028 #include "RImage.hpp" 00029 #include "FImage.hpp" 00030 #include "CImage.hpp" 00031 00032 00033 class RGBImage : public AnImage 00034 { 00035 private: 00036 00037 unsigned char* palign; 00038 unsigned char* p1; 00039 unsigned char** image; 00040 00041 protected: 00042 00043 void meanCurvature3Restoration(int iterations, double coeff, 00044 RImage* channel1, RImage* channel2, RImage* channel3); 00045 void geodesicMeanCurvature3Restoration(int iterations, double coeff, 00046 RImage* channel1, RImage* channel2, RImage* channel3); 00047 00048 void peronaMalik3Restoration(int iterations, double coeff, 00049 RImage* channel1, RImage* channel2, RImage* channel3); 00050 void geodesicPeronaMalik3Restoration(int iterations, double coeff, 00051 RImage* channel1, RImage* channel2, RImage* channel3); 00052 00053 void beltrami3Restoration(int iterations, double coeff, 00054 RImage* channel1, RImage* channel2, RImage* channel3); 00055 void geodesicBeltrami3Restoration(int iterations, double coeff, 00056 RImage* channel1, RImage* channel2, RImage* channel3); 00057 00058 public: 00059 00060 RGBImage(int w, int h); 00061 RGBImage(int w, int h, unsigned char data); 00062 RGBImage(int w, int h, unsigned char* data); 00063 RGBImage(int w, int h, unsigned char red, unsigned char green, unsigned char blue); 00064 RGBImage(int w, int h, unsigned char* red, unsigned char* green, unsigned char* blue); 00065 RGBImage(RImage& red, RImage& green, RImage& blue); 00066 virtual ~RGBImage(){ delete[] image; p1=0; delete[] palign; } 00067 00068 00069 virtual unsigned char* getData(){ return p1; } 00070 00071 virtual void set(AnImage* src){ setData(src,0); } 00072 00073 virtual void set(FImage& data, int ch=0); 00074 virtual void set(RImage& data, int ch=0); 00075 virtual void set(CImage& data, int ctype=0, int ch=0); 00076 virtual void setChannel(AnImage* channel, int ch=0); 00077 virtual void setValues(unsigned char value); 00078 00079 virtual AnImage* copy(); 00080 00081 virtual AnImage* flipHorizontal(); 00082 virtual AnImage* flipVertical(); 00083 00084 virtual AnImage* rotate90Left(); 00085 virtual AnImage* rotate90Right(); 00086 virtual AnImage* rotate180(); 00087 00088 virtual AnImage* scaleDown(int multiplier=2); 00089 virtual AnImage* scaleUp(int multiplier=2); 00090 virtual AnImage* scaleUp(int multiplier, int r, int g, int b); 00091 virtual AnImage* zeroInterleaving(); 00092 00093 virtual AnImage* partImage(int x0=0, int y0=0, int w=256, int h=256); 00094 virtual AnImage* subImage(int x0, int y0, int x1, int y1); 00095 virtual AnImage* smallImage(double xscale, double yscale); 00096 virtual AnImage* smallImage(int width); 00097 00098 virtual int available8BitsColors(); 00099 00100 virtual void setData(AnImage* src, AnImage* mask=0); 00101 00102 virtual int getRed(int x, int y){ return image[y][x*3]; } 00103 virtual int getGreen(int x, int y){ return image[y][x*3+1]; } 00104 virtual int getBlue(int x, int y){ return image[y][x*3+2]; } 00105 virtual int getGrey(int x, int y) // luminance 00106 { return (299*getRed(x,y)+587*getGreen(x,y)+114*getBlue(x,y))/1000; } 00107 00108 virtual void setRed(int x, int y, int value){ image[y][x*3]=value; } 00109 virtual void setGreen(int x, int y, int value){ image[y][x*3+1]=value; } 00110 virtual void setBlue(int x, int y, int value){ image[y][x*3+2]=value; } 00111 virtual void setGrey(int x, int y, int value) 00112 { 00113 image[y][x*3]=value; 00114 image[y][x*3+1]=value; 00115 image[y][x*3+2]=value; 00116 } 00117 00118 virtual void set(int x, int y, int rgb) 00119 { 00120 setRed(x, y, (0x00ff0000 & rgb) >> 16 ); 00121 setGreen(x, y, (0x0000ff00 & rgb) >> 8 ); 00122 setBlue(x, y, (0x000000ff & rgb) ); 00123 } 00124 00125 virtual int get(int x, int y) 00126 { return (299*getRed(x,y)+587*getGreen(x,y)+114*getBlue(x,y))/1000; } 00127 00128 // RGB simulation 00129 virtual void setRGB(int x, int y, int r, int g, int b) 00130 { 00131 image[y][x*3]=r; 00132 image[y][x*3+1]=g; 00133 image[y][x*3+2]=b; 00134 } 00135 00136 00137 virtual void restaure(int model, int chMode,int type, 00138 int iterations, double coeff,double rsat=0.5); 00139 00140 virtual void restaure(int type, int iterations, double coeff); 00141 00142 virtual void report(FILE* file); 00143 virtual void output(); 00144 }; 00145 00146 #endif