diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-04 11:10:55 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-04 11:10:55 +0000 |
| commit | 741cba373d7e982026de91ee1ceeb18a8f64b367 (patch) | |
| tree | d165081cc737cb10e2846b7de16686dd7077311c /rotord/src/cvimage.cpp | |
| parent | fb420b3af414ce8f12481b0df099f24f33c641e0 (diff) | |
min/max
Diffstat (limited to 'rotord/src/cvimage.cpp')
| -rw-r--r-- | rotord/src/cvimage.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/rotord/src/cvimage.cpp b/rotord/src/cvimage.cpp index 2d0f8e2..7aae63e 100644 --- a/rotord/src/cvimage.cpp +++ b/rotord/src/cvimage.cpp @@ -150,6 +150,30 @@ namespace Rotor { } return *this; } + Image & Image::min(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot min images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl; + } + else { + for (int i=0;i<w*h*3;i++){ + //calculate with tables + rgb.data[i]=pixels.min[rgb.data[i]][other.rgb.data[i]]; + } + } + return *this; + } + Image & Image::max(const Image &other) { + if (other.w!=w||other.h!=h) { + cerr<<"Rotor: cannot min images with different sizes! (wanted "<<w<<"x"<<h<<", got "<<other.w<<"x"<<other.h<<")"<<endl; + } + else { + for (int i=0;i<w*h*3;i++){ + //calculate with tables + rgb.data[i]=pixels.max[rgb.data[i]][other.rgb.data[i]]; + } + } + return *this; + } Image & Image::operator=(const Image &other) { //can be optimised? was trying to use other.data.clone() setup(other.w,other.h); @@ -215,8 +239,8 @@ namespace Rotor { cv::Mat& Image::get_mipmap(int level){ if (mipmaps.find(level)!=mipmaps.end()) return mipmaps[level]; //levels start at 1 - int nw=max(1.0,w/pow(2,level)); - int nh=max(1.0,h/pow(2,level)); + int nw=std::max(1.0,w/pow(2,level)); + int nh=std::max(1.0,h/pow(2,level)); cv::Mat mip;; cv::resize(rgb,mip,cv::Size(nw,nh),0,0,cv::INTER_AREA ); mipmaps[level]=mip; |
