From f758127362e3c1e4e926204a83ce3104af1278bb Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 11 Jul 2013 13:21:36 +0100 Subject: cvimage fully incorporated --- rotord/cvimage.h | 121 +++++++------------------------------------------------ 1 file changed, 14 insertions(+), 107 deletions(-) (limited to 'rotord/cvimage.h') diff --git a/rotord/cvimage.h b/rotord/cvimage.h index 7588673..a538d4e 100644 --- a/rotord/cvimage.h +++ b/rotord/cvimage.h @@ -1,11 +1,9 @@ #include #include -using namespace std; - //converting to use a cv image... //cv::Mat supports most of what we want here -//need to think +//need to think //http://answers.opencv.org/question/8202/using-external-image-data-in-a-cvmat/ //all access to the image is presently through a pointer to the data @@ -15,7 +13,7 @@ using namespace std; //Rotor::Image will contain a cv::Mat object which may own its data or inherit it //cv::Mat should take care of reference counting -//can cv::Mat +//can cv::Mat namespace Rotor { class pixeltables{ @@ -30,7 +28,7 @@ namespace Rotor { add[i]=new uint8_t[256]; multiply[i]=new uint8_t[256]; for (int j=0;j<256;j++){ - add[i][j]=(uint8_t)min(i+j,0xFF); + add[i][j]=(uint8_t)std::min(i+j,0xFF); multiply[i][j]=(uint8_t)((((float)i)/255.0f)*(((float)j)/255.0f)*255.0f); } } @@ -107,7 +105,7 @@ namespace Rotor { else return false; */ } - bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){ + bool setup_fromRGB(int _w,int _h,uint8_t *pRGBdata){ //here the data belongs to libavcodec or other //could move to using cv::Mat there also and just passing cv:Mat over rgb=cv::Mat(_w,_h,CV_8UC3,pRGBdata); @@ -131,7 +129,7 @@ namespace Rotor { return false; */ } - bool setup_fromMat(cv::Mat& othermat){ + bool setup_fromMat(cv::Mat& othermat){ //here the mat belongs to another Image object rgb=cv::Mat(othermat); RGBdata=rgb.data; //can move to use the bare pointer eventually @@ -155,105 +153,14 @@ namespace Rotor { return t; } //believe these still work, don't know if these optimisations are better than opencvs.. - Image & operator+=(const Image &other) { - if (other.w!=w||other.h!=h) { - cerr<<"Rotor: cannot add images with different sizes! (wanted "<RGBdata[i]=LUT[RGBdata[i]]; - } - delete[] LUT; - return other; - } - Image * operator+(const float &amount) { - Image *other=new Image(w,h); - uint8_t *LUT=new uint8_t[256]; - for (int i=0;i<256;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i+(amount*255.0f)))); - } - for (int i=0;iRGBdata[i]=LUT[RGBdata[i]]; - } - delete[] LUT; - return other; - } - Image * operator-(const float &amount) { - Image *other=new Image(w,h); - uint8_t *LUT=new uint8_t[256]; - for (int i=0;i<256;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i-(amount*255.0f)))); - } - for (int i=0;iRGBdata[i]=LUT[RGBdata[i]]; - } - delete[] LUT; - return other; - } - Image * operator/(const float &amount) { - Image *other=new Image(w,h); - uint8_t *LUT=new uint8_t[256]; - for (int i=0;i<256;i++) { - LUT[i]=(uint8_t)min(0xFF,max(0,(int)(i/amount))); - } - for (int i=0;iRGBdata[i]=LUT[RGBdata[i]]; - } - delete[] LUT; - return other; - } + Image & operator+=(const Image &other); + Image & operator*=(const Image &other); + Image & add_wrap(const Image &other); + Image & operator*=(const float &amount); + Image * operator*(const float &amount); + Image * operator+(const float &amount); + Image * operator-(const float &amount); + Image * operator/(const float &amount); uint8_t *RGBdata; uint8_t *Adata; uint16_t *Zdata; @@ -262,4 +169,4 @@ namespace Rotor { cv::Mat rgb; }; -} \ No newline at end of file +} -- cgit v1.2.3