From f38cdcf952ac5c631ed285282e1bc2943f199101 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 30 Aug 2013 12:59:04 +0100 Subject: still image loader --- rotord/src/nodes_transform.h | 92 ++++---------------------------------------- 1 file changed, 8 insertions(+), 84 deletions(-) diff --git a/rotord/src/nodes_transform.h b/rotord/src/nodes_transform.h index 69a0af6..bb3a04f 100644 --- a/rotord/src/nodes_transform.h +++ b/rotord/src/nodes_transform.h @@ -32,6 +32,11 @@ namespace Rotor { }; Image *transform(Image *in){ if (in){ + //INTER_NEAREST - a nearest-neighbor interpolation + //INTER_LINEAR - a bilinear interpolation (used by default) + //INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method. + //INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood + //INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood int filtmode; switch(attributes["filter"]->intVal){ case TRANSFORM_nearest: @@ -83,7 +88,7 @@ namespace Rotor { // Compute rotation matrix // - cv::Point centre = cv::Point( oX*in->w, oY*in->h ); + cv::Point centre = cv::Point( oX*image.w, oY*image.h ); rot_mat = getRotationMatrix2D( centre, r, s ); // Do the transformation @@ -92,12 +97,6 @@ namespace Rotor { warpAffine( inter.rgb, image.rgb, rot_mat, image.rgb.size(), filtmode, cv::BORDER_WRAP); //BORDER_WRAP - //INTER_NEAREST - a nearest-neighbor interpolation - //INTER_LINEAR - a bilinear interpolation (used by default) - //INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method. - //INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood - //INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood - return ℑ } return nullptr; @@ -122,16 +121,9 @@ namespace Rotor { } private: }; - class Still_image: public Image_node { + class Still_image: public Transformer { public: Still_image(){ - create_parameter("transformX","number","X transformation","Transform X",0.0f); - create_parameter("transformY","number","Y transformation","Transform X",0.0f); - create_parameter("originX","number","X transformation origin","Origin X",0.5f); - create_parameter("originY","number","Y transformation origin","Origin Y",0.5f); - create_parameter("rotation","number","Rotation about origin","Rotation",0.0f); - create_parameter("scale","number","Scale about origin","Scale",1.0f); - create_attribute("filter","Filtering mode","Filter mode","linear",{"nearest","linear","area","cubic","lanczos"}); create_attribute("filename","name of image file to load","File name",""); title="Still image"; description="Load a still image and apply 2D transformation"; @@ -151,75 +143,7 @@ namespace Rotor { Still_image* clone(map &_settings) { return new Still_image(_settings);}; Image *output(const Frame_spec &frame){ if (!still.rgb.empty()){ - int filtmode; - switch(attributes["filter"]->intVal){ - case TRANSFORM_nearest: - filtmode=cv::INTER_NEAREST; - break; - case TRANSFORM_linear: - filtmode=cv::INTER_LINEAR; - break; - case TRANSFORM_area: - filtmode=cv::INTER_AREA; - break; - case TRANSFORM_cubic: - filtmode=cv::INTER_CUBIC; - break; - case TRANSFORM_lanczos: - filtmode=cv::INTER_LANCZOS4; - break; - } - - float tX=parameters["transformX"]->value; - float tY=parameters["transformY"]->value; - float oX=parameters["originX"]->value; - float oY=parameters["originY"]->value; - float r=parameters["rotation"]->value; - float s=parameters["scale"]->value; - - cerr<<"still: xform "<