summaryrefslogtreecommitdiff
path: root/rotord/src/rotor.h
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-08-17 14:27:20 +0100
committerComment <tim@gray.(none)>2013-08-17 14:27:20 +0100
commitaa99d094fde27ba5dc79dfcee2509f5ae9a58017 (patch)
tree556cfba3526b2762072359d2c4bb36a0797e7461 /rotord/src/rotor.h
parent5084f2e72df92416254905811af99f6e419de0cf (diff)
RGB levels working
Diffstat (limited to 'rotord/src/rotor.h')
-rwxr-xr-xrotord/src/rotor.h81
1 files changed, 53 insertions, 28 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 0d46bdc..199d960 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -614,50 +614,76 @@ namespace Rotor {
int interval,total,lastframe; //number of frames between displayed echoes
unordered_map<int,Image*> images;
};
- /*
class RGB_levels: public Image_node {
public:
- Luma_levels(){
+ RGB_levels(){
create_image_input("image input","Image input");
create_parameter("red_black_in","number","Red input black-point","Red input black-point",0.0f,0.0f,1.0f);
create_parameter("red_white_in","number","Red input white-point","Red input white-point",1.0f,0.0f,1.0f);
- create_parameter("red gamma","number","red gamma level","Red gamma",1.0f,0.0f,10.0f);
- create_parameter("red_black_out","number","output black point","Output black point",0.0f,0.0f,1.0f);
- create_parameter("red_white_out","number","output white point","Output white point",1.0f,0.0f,1.0f);
- create_parameter("black_in","number","input black point","Input black point",0.0f,0.0f,1.0f);
- create_parameter("white_in","number","input white point","Input white point",1.0f,0.0f,1.0f);
- create_parameter("gamma","number","gamma level","Gamma",1.0f,0.0f,10.0f);
- create_parameter("black_out","number","output black point","Output black point",0.0f,0.0f,1.0f);
- create_parameter("white_out","number","output white point","Output white point",1.0f,0.0f,1.0f);
- create_parameter("black_in","number","input black point","Input black point",0.0f,0.0f,1.0f);
- create_parameter("white_in","number","input white point","Input white point",1.0f,0.0f,1.0f);
- create_parameter("gamma","number","gamma level","Gamma",1.0f,0.0f,10.0f);
- create_parameter("black_out","number","output black point","Output black point",0.0f,0.0f,1.0f);
- create_parameter("white_out","number","output white point","Output white point",1.0f,0.0f,1.0f);
- title="Luma levels";
- description="Remap luma values of image";
+ create_parameter("red_gamma","number","Red gamma level","Red gamma",1.0f,0.01f,10.0f);
+ create_parameter("red_black_out","number","Red output black point","Red output black point",0.0f,0.0f,1.0f);
+ create_parameter("red_white_out","number","Red output white point","Red output white point",1.0f,0.0f,1.0f);
+ create_parameter("green_black_in","number","Green input black point","Green input black point",0.0f,0.0f,1.0f);
+ create_parameter("green_white_in","number","Green input white point","Green input white point",1.0f,0.0f,1.0f);
+ create_parameter("green_gamma","number","Green gamma level","Green gamma",1.0f,0.01f,10.0f);
+ create_parameter("green_black_out","number","Green output black point","Green output black point",0.0f,0.0f,1.0f);
+ create_parameter("green_white_out","number","Green output white point","Green output white point",1.0f,0.0f,1.0f);
+ create_parameter("blue_black_in","number","Blue input black point","Blue input black point",0.0f,0.0f,1.0f);
+ create_parameter("blue_white_in","number","Blue input white point","Blue input white point",1.0f,0.0f,1.0f);
+ create_parameter("blue_gamma","number","Blue gamma level","Blue gamma",1.0f,0.01f,10.0f);
+ create_parameter("blue_black_out","number","Blue output black point","Blue output black point",0.0f,0.0f,1.0f);
+ create_parameter("blue_white_out","number","Blue output white point","Blue output white point",1.0f,0.0f,1.0f);
+ title="RGB levels";
+ description="Remap RGB values of image";
LUT=nullptr;
};
- Luma_levels(map<string,string> &settings):Luma_levels() {
+ RGB_levels(map<string,string> &settings):RGB_levels() {
base_settings(settings);
}
- ~Luma_levels(){if (LUT) { delete[] LUT;} };
+ ~RGB_levels(){
+ if (LUT) {
+ for (int i=0;i<3;i++) {
+ delete[] LUT[i];
+ }
+ delete[] LUT;
+ }
+ };
void generate_LUT(){
//can check here if anything has changed
- if (LUT) delete[] LUT;
- LUT=new unsigned char[256];
+ if (LUT) {
+ for (int i=0;i<3;i++) {
+ delete[] LUT[i];
+ }
+ delete[] LUT;
+ }
+ LUT=new unsigned char*[3];
+ for (int i=0;i<3;i++){
+ LUT[i]=new unsigned char[256];
+ }
float fltmax=(255.0f/256.0f);
for (int i=0;i<256;i++){
- LUT[i]=(unsigned char)(((pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["black_in"]->value)/(parameters["white_in"]->value-parameters["black_in"]->value)))),(1.0/parameters["gamma"]->value))*(parameters["white_out"]->value-parameters["black_out"]->value))+parameters["black_out"]->value)*255.0f);
+ LUT[0][i]=(unsigned char)(((\
+ pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["red_black_in"]->value)/(parameters["red_white_in"]->value-parameters["red_black_in"]->value))))\
+ ,(1.0/parameters["red_gamma"]->value))\
+ *(parameters["red_white_out"]->value-parameters["red_black_out"]->value))+parameters["red_black_out"]->value)*255.0f);
+ LUT[1][i]=(unsigned char)(((\
+ pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["green_black_in"]->value)/(parameters["green_white_in"]->value-parameters["green_black_in"]->value))))\
+ ,(1.0/parameters["green_gamma"]->value))\
+ *(parameters["green_white_out"]->value-parameters["green_black_out"]->value))+parameters["green_black_out"]->value)*255.0f);
+ LUT[2][i]=(unsigned char)(((\
+ pow(min(fltmax,max(0.0f,(((((float)i)/256.0f)-parameters["blue_black_in"]->value)/(parameters["blue_white_in"]->value-parameters["blue_black_in"]->value))))\
+ ,(1.0/parameters["blue_gamma"]->value))\
+ *(parameters["blue_white_out"]->value-parameters["blue_black_out"]->value))+parameters["blue_black_out"]->value)*255.0f);
}
}
void apply_LUT(const Image& in){
apply_LUT(in,image);
}
void apply_LUT(const Image& in,Image &out){ //facility to apply to other images for inherited classes
- out.setup(in.w,in.h);
- for (int i=0;i<out.w*out.h*3;i++){
- out.RGBdata[i]=LUT[in.RGBdata[i]];
+ for (int i=0;i<out.w*out.h;i++){
+ out.RGBdata[i*3]=LUT[0][in.RGBdata[i*3]];
+ out.RGBdata[i*3+1]=LUT[1][in.RGBdata[i*3+1]];
+ out.RGBdata[i*3+2]=LUT[2][in.RGBdata[i*3+2]];
}
}
Image *output(const Frame_spec &frame){
@@ -668,11 +694,10 @@ namespace Rotor {
}
return &image;
}
- Luma_levels* clone(map<string,string> &_settings) { return new Luma_levels(_settings);};
+ RGB_levels* clone(map<string,string> &_settings) { return new RGB_levels(_settings);};
protected:
- unsigned char *LUT;
+ unsigned char **LUT;
};
- */
#define BLEND_blend 1
#define BLEND_screen 2
#define BLEND_multiply 3