diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/cvimage.cpp | 28 | ||||
| -rw-r--r-- | rotord/src/cvimage.h | 15 | ||||
| -rw-r--r-- | rotord/src/nodes_channels.h | 34 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 2 |
4 files changed, 69 insertions, 10 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; diff --git a/rotord/src/cvimage.h b/rotord/src/cvimage.h index a0a2cf4..ee39edf 100644 --- a/rotord/src/cvimage.h +++ b/rotord/src/cvimage.h @@ -30,14 +30,20 @@ namespace Rotor { add=new uint8_t*[256]; multiply=new uint8_t*[256]; overlay=new uint8_t*[256]; + min=new uint8_t*[256]; + max=new uint8_t*[256]; for (int i=0;i<256;i++){ add[i]=new uint8_t[256]; multiply[i]=new uint8_t[256]; overlay[i]=new uint8_t[256]; + min[i]=new uint8_t[256]; + max[i]=new uint8_t[256]; for (int j=0;j<256;j++){ add[i][j]=(uint8_t)std::min(i+j,0xFF); multiply[i][j]=(uint8_t)(((float)i)*(((float)j)/255.0f)); overlay[i][j]=j<128?(uint8_t)((i*j)>>7):255-(((0xFF-i)*(0xFF-j))>>7); + min[i][j]=j<i?j:i; + max[i][j]=j>i?j:i; } } mono_weights=new uint8_t*[3]; @@ -54,10 +60,14 @@ namespace Rotor { delete[] add[i]; delete[] multiply[i]; delete[] overlay[i]; + delete[] min[i]; + delete[] max[i]; } delete[] add; delete[] multiply; delete[] overlay; + delete[] min; + delete[] max; for (int i=0;i<3;i++) { delete[] mono_weights[i]; } @@ -67,7 +77,8 @@ namespace Rotor { uint8_t **multiply; uint8_t **overlay; uint8_t **mono_weights; - + uint8_t **max; + uint8_t **min; }; static pixeltables pixels; class Image{ @@ -208,6 +219,8 @@ namespace Rotor { Image & add_wrap(const Image &other); Image & divide_wrap(const Image &other); Image & overlay(const Image &other); + Image & min(const Image &other); + Image & max(const Image &other); Image & operator*=(const float &amount); Image & operator+=(const float &amount); Image & operator-=(const float &amount); diff --git a/rotord/src/nodes_channels.h b/rotord/src/nodes_channels.h index 1cb151e..4fdcd01 100644 --- a/rotord/src/nodes_channels.h +++ b/rotord/src/nodes_channels.h @@ -70,13 +70,15 @@ namespace Rotor { #define BLEND_wrap 5 #define BLEND_xor 6 #define BLEND_overlay 7 +#define BLEND_min 8 +#define BLEND_max 9 class Blend: public Image_node { public: Blend(){ create_image_input("image input 1","Image input 1"); create_image_input("image input 2","Image input 2"); create_parameter("amount","number","amount to blend input 2","Blend amount",0.5f,0.0f,1.0f); - create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay"}); + create_attribute("mode","Blend mode","Blend mode","blend",{"blend","screen","multiply","alpha","wrap","xor","overlay","min","max"}); title ="Blend"; description="Blend images in various modes"; NODEID="12ed7af0-2d0a-11e3-ae32-2b44203b93c9"; @@ -111,6 +113,12 @@ namespace Rotor { case BLEND_overlay: image=image.overlay(*in2); break; + case BLEND_min: + image=image.min(*in2); + break; + case BLEND_max: + image=image.max(*in2); + break; case BLEND_blend: //has to be last because of initialser of *in? go figure image*=(1.0f-parameters["amount"]->value); @@ -412,7 +420,7 @@ namespace Rotor { //calls base class constructor first create_parameter("number","number","number of echoes","Number echoes",25.0f); create_parameter("fadeto","number","amount that echoes fade out","Fadout amount",1.0f,0.0f,1.0f); - create_attribute("mode","blend mode for echoes","Blend mode","screen",{"screen","wrap"}); + create_attribute("mode","blend mode for echoes","Blend mode","screen",{"screen","wrap","min","max"}); title="Echo trails"; description="Draw trail frames additively that fade off over time"; NODEID="5b1ab684-2d0b-11e3-8fa2-970be8c360dd"; @@ -476,14 +484,30 @@ namespace Rotor { if (attributes["mode"]->value=="screen") { image+=*temp; } - else { + if (attributes["mode"]->value=="wrap") { image.add_wrap(*temp); } + if (attributes["mode"]->value=="min") { + image.min(*temp); + } + if (attributes["mode"]->value=="max") { + image.max(*temp); + } delete temp; } else { - if (attributes["mode"]->value=="screen") image+=*(images[absframe]); - else image=image.add_wrap(*(images[absframe])); + if (attributes["mode"]->value=="screen") { + image+=*(images[absframe]); + } + if (attributes["mode"]->value=="screen") { + image=image.add_wrap(*(images[absframe])); + } + if (attributes["mode"]->value=="min") { + image=image.min(*(images[absframe])); + } + if (attributes["mode"]->value=="max") { + image=image.max(*(images[absframe])); + } } } } diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index c96663f..943464d 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -114,8 +114,6 @@ inputs: [ ] -REARCHITECTING STARTS HERE - -------------------------*/ |
