159#define XEL_TYPE vigra::TinyVector
161#define VECTOR_TYPE vspline::simd_type
162#include "vspline/opt/vector_promote.h"
163#include "vspline/opt/xel_of_vector.h"
168#define VECTOR_TYPE vspline::vc_simd_type
169#include "vspline/opt/vector_promote.h"
170#include "vspline/opt/xel_of_vector.h"
177#define VECTOR_TYPE vspline::hwy_simd_type
178#include "vspline/opt/vector_promote.h"
179#include "vspline/opt/xel_of_vector.h"
186#include <vigra/stdimage.hxx>
187#include <vigra/imageinfo.hxx>
188#include <vigra/impex.hxx>
189#include <vigra/quaternion.hxx>
249 const size_t & _px_height ,
250 const double & _hfov )
255 assert (
hfov >= 0.0 ) ;
268template < std::
size_t vsize = vspline::vector_traits <
float > :: size >
285 { float ( _ib.px_width - .5 ) ,
286 float ( _ib.px_height - 0.5 ) } ,
287 { float ( - _ib.u_width / 2.0 ) ,
288 float ( - _ib.u_height / 2.0 ) } ,
289 { float ( _ib.u_width / 2.0 ) ,
290 float ( _ib.u_height / 2.0 ) } ) ,
292 float ( - _ib.u_height / 2.0 ) } ,
293 { float ( _ib.u_width / 2.0 ) ,
294 float ( _ib.u_height / 2.0 ) } ,
297 { float ( _ib.px_width - .5 ) ,
298 float ( _ib.px_height - 0.5 ) } )
306 const size_t & _px_height ,
307 const double & _hfov )
315 template <
typename dtype >
317 (
const vigra::TinyVector < dtype , 2 > & ci )
const
321 vigra::TinyVector < dtype , 2 > cm ;
329 dtype azimuth = atan ( cm[0] ) ;
333 dtype fl = sqrt ( 1.0 + cm[0] * cm[0] ) ;
335 dtype elevation = - atan ( cm[1] / fl ) ;
337 return { azimuth , elevation } ;
342 template <
typename dtype >
344 (
const vigra::TinyVector < dtype , 3 > & cm3 )
const
346 vigra::TinyVector < dtype , 2 > cm { cm3[1] / cm3[0] , cm3[2] / cm3[0] } ;
362template <
typename dtype >
373 vigra::Quaternion < dtype > q_pitch ( cos ( pitch / 2.0 ) , 0.0 , sin ( pitch / 2.0 ) , 0.0 ) ;
378 vigra::Quaternion < dtype > q_yaw ( cos ( -yaw / 2.0 ) , 0.0 , 0.0 , - sin ( -yaw / 2.0 ) ) ;
381 vigra::Quaternion < dtype > total = q_yaw ;
389template <
typename dtype ,
typename qtype >
390vigra::TinyVector < dtype , 3 >
391rotate_q (
const vigra::TinyVector < dtype , 3 > & v ,
392 vigra::Quaternion < qtype > q )
394 vigra::TinyVector < dtype , 3 > result ;
395 vigra::Quaternion < dtype > vq ( 0.0 , v[0] , v[1] , v[2] ) ;
396 vigra::Quaternion < dtype > qq ( q[0] , q[1] , q[2] , q[3] ) ;
397 vigra::Quaternion < dtype > qc = conj ( qq ) ;
431template <
typename I ,
typename O ,
size_t S ,
432 template <
typename ,
typename ,
size_t >
class EV >
446 const float & _hfov )
449 img ( _extent[0] , _extent[1] , _hfov )
458 template <
class IN ,
class OUT >
464 typedef typename IN::value_type ele_type ;
481 for (
auto const & cf :
kernel )
493 const auto & dx ( cf[0] ) ;
494 const auto & dy ( cf[1] ) ;
495 const auto &
weight ( cf[2] ) ;
504 vigra::TinyVector < ele_type , 3 > p3d { 1.0f , dx , dy } ;
519 inner.eval ( ci , pickup ) ;
524 result += pickup *
weight ;
540void build_kernel (
const vigra::MultiArrayView < 2 , float > & kernel_2d ,
546 auto kernel_shape = kernel_2d.shape() ;
548 coordinate_type kernel_center ( kernel_shape[0] - 1 , kernel_shape[1] - 1 ) ;
551 assert ( kernel_shape == meta_kernel.shape() ) ;
553 for (
int x = 0 ; x < kernel_shape[0] ; x++ )
555 for (
int y = 0 ; y < kernel_shape[1] ; y++ )
557 float dx = img.
u_per_px * ( x - kernel_center [ 0 ] ) ;
558 float dy = img.
u_per_px * ( y - kernel_center [ 1 ] ) ;
559 float weight = kernel_2d [ { x , y } ] ;
561 meta_kernel [ { x , y } ] = { dx , dy , weight } ;
578int main (
int argc ,
char * argv[] )
582 std::cerr <<
"pass a colour image file as first argument" << std::endl ;
583 std::cerr <<
"and the hfov as second argument, followed by" << std::endl ;
584 std::cerr <<
"the horizontal and vertical kernel scaling factor" << std::endl ;
588 float hfov = std::atof ( argv[2] ) * M_PI / 180.0 ;
589 float sx = std::atof ( argv[3] ) ;
590 float sy = std::atof ( argv[4] ) ;
594 vigra::ImageImportInfo imageInfo ( argv[1] ) ;
596 image_base_type img ( imageInfo.width() , imageInfo.height() , hfov ) ;
608 vigra::importImage ( imageInfo , bspl.
core ) ;
626 vigra::MultiArray < 2 , float > kernel_2d ( vigra::Shape2 ( 9 , 9 ) ) ;
629 for (
int x = -4 ; x < 5 ; x++ )
631 for (
int y = -4 ; y < 5 ; y++ )
633 double kx = bf ( 0.25 * x ) ;
634 double ky = bf ( 0.25 * y ) ;
636 std::cout <<
" " << k ;
637 kernel_2d [ { x + 4 , y + 4 } ] = k ;
640 std::cout << std::endl ;
647 kernel_type meta_kernel ( vigra::Shape2 ( 9 , 9 ) ) ;
662 ( ev , meta_kernel , imageInfo.shape() , hfov ) ;
677 vigra::ImageExportInfo eximageInfo (
"metafilter3.tif" );
679 std::cout <<
"storing the target image as 'metafilter3.tif'" << std::endl ;
681 vigra::exportImage ( target ,
683 .setPixelType (
"UINT16" )
684 .setForcedRangeMapping ( 0 , 255 , 0 , 65535 ) ) ;
vigra::TinyVector< float, 2 > coordinate_type
vigra::MultiArray< 2, pixel_type > target_type
void transform(const unary_functor_type &functor, const vigra::MultiArrayView< dimension, typename unary_functor_type::in_type > &input, vigra::MultiArrayView< dimension, typename unary_functor_type::out_type > &output, int njobs=vspline::default_njobs, vspline::atomic< bool > *p_cancel=0)
implementation of two-array transform using wielding::coupled_wield.
vspline::grok_type< bspl_coordinate_type< spline_type, rc_type >, result_type, _vsize > make_safe_evaluator(const spline_type &bspl, vigra::TinyVector< int, spline_type::dimension > dspec=vigra::TinyVector< int, spline_type::dimension >(0), int shift=0)
make_safe_evaluator is a factory function, producing a functor which provides safe access to an evalu...
image_base_type(const size_t &_px_width, const size_t &_px_height, const double &_hfov)
const vspline::domain_type< coordinate_type, vsize > scale_to_model
const image_base_type image_base
image_type(const size_t &_px_width, const size_t &_px_height, const double &_hfov)
vigra::TinyVector< dtype, 2 > to_spherical(const vigra::TinyVector< dtype, 2 > &ci) const
const vspline::domain_type< coordinate_type, vsize > scale_to_image
vigra::TinyVector< dtype, 2 > to_image(const vigra::TinyVector< dtype, 3 > &cm3) const
basis_functor is an object producing the b-spline basis function value for given arguments,...
class bspline now builds on class bspline_base, adding coefficient storage, while bspline_base provid...
void prefilter(vspline::xlf_type boost=vspline::xlf_type(1), int njobs=vspline::default_njobs)
prefilter converts the knot point data in the 'core' area into b-spline coefficients....
void eval(const in_type &in, out_type &out) const
eval for unvectorized data. we dispatch on in_type, the incoming coordinate, being a 'naked' fundamen...
class grok_type is a helper class wrapping a vspline::unary_functor so that it's type becomes opaque ...
class unary_functor provides a functor object which offers a system of types for concrete unary funct...
with the definition of 'simd_traits', we can proceed to implement 'vector_traits': struct vector_trai...
includes all headers from vspline (most of them indirectly)