VImage8.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137
  1. // VIPS image wrapper
  2. /*
  3. This file is part of VIPS.
  4. VIPS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA
  16. */
  17. /*
  18. These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk
  19. */
  20. #ifndef VIPS_VIMAGE_H
  21. #define VIPS_VIMAGE_H
  22. #include <list>
  23. #include <complex>
  24. #include <vector>
  25. #include <cstring>
  26. #include <vips/vips.h>
  27. VIPS_NAMESPACE_START
  28. /* Small utility things.
  29. */
  30. VIPS_CPLUSPLUS_API std::vector<double> to_vectorv( int n, ... );
  31. VIPS_CPLUSPLUS_API std::vector<double> to_vector( double value );
  32. VIPS_CPLUSPLUS_API std::vector<double> to_vector( int n, double array[] );
  33. VIPS_CPLUSPLUS_API std::vector<double> negate( std::vector<double> value );
  34. VIPS_CPLUSPLUS_API std::vector<double> invert( std::vector<double> value );
  35. enum VSteal {
  36. NOSTEAL = 0,
  37. STEAL = 1
  38. };
  39. /* A smart VipsObject pointer class ... use g_object_ref()/_unref() for
  40. * lifetime management.
  41. */
  42. class VObject
  43. {
  44. private:
  45. // can be NULL, see eg. VObject()
  46. VipsObject *vobject;
  47. public:
  48. VObject( VipsObject *new_vobject, VSteal steal = STEAL ) :
  49. vobject( new_vobject )
  50. {
  51. // we allow NULL init, eg. "VImage a;"
  52. g_assert( !new_vobject ||
  53. VIPS_IS_OBJECT( new_vobject ) );
  54. #ifdef VIPS_DEBUG_VERBOSE
  55. printf( "VObject constructor, obj = %p, steal = %d\n",
  56. new_vobject, steal );
  57. if( new_vobject ) {
  58. printf( " obj " );
  59. vips_object_print_name( VIPS_OBJECT( new_vobject ) );
  60. printf( "\n" );
  61. }
  62. #endif /*VIPS_DEBUG_VERBOSE*/
  63. if( !steal ) {
  64. #ifdef VIPS_DEBUG_VERBOSE
  65. printf( " reffing object\n" );
  66. #endif /*VIPS_DEBUG_VERBOSE*/
  67. g_object_ref( vobject );
  68. }
  69. }
  70. VObject() :
  71. vobject( 0 )
  72. {
  73. }
  74. // copy constructor
  75. VObject( const VObject &a ) :
  76. vobject( a.vobject )
  77. {
  78. g_assert( VIPS_IS_OBJECT( a.vobject ) );
  79. #ifdef VIPS_DEBUG_VERBOSE
  80. printf( "VObject copy constructor, obj = %p\n",
  81. vobject );
  82. printf( " reffing object\n" );
  83. #endif /*VIPS_DEBUG_VERBOSE*/
  84. g_object_ref( vobject );
  85. }
  86. // assignment ... we must delete the old ref
  87. // old can be NULL, new must not be NULL
  88. VObject &operator=( const VObject &a )
  89. {
  90. VipsObject *old_vobject;
  91. #ifdef VIPS_DEBUG_VERBOSE
  92. printf( "VObject assignment\n" );
  93. printf( " reffing %p\n", a.vobject );
  94. printf( " unreffing %p\n", vobject );
  95. #endif /*VIPS_DEBUG_VERBOSE*/
  96. g_assert( !vobject ||
  97. VIPS_IS_OBJECT( vobject ) );
  98. g_assert( a.vobject &&
  99. VIPS_IS_OBJECT( a.vobject ) );
  100. // delete the old ref at the end ... otherwise "a = a;" could
  101. // unref before reffing again
  102. old_vobject = vobject;
  103. vobject = a.vobject;
  104. g_object_ref( vobject );
  105. if( old_vobject )
  106. g_object_unref( old_vobject );
  107. return( *this );
  108. }
  109. // this mustn't be virtual: we want this class to only be a pointer,
  110. // no vtable allowed
  111. ~VObject()
  112. {
  113. #ifdef VIPS_DEBUG_VERBOSE
  114. printf( "VObject destructor\n" );
  115. printf( " unreffing %p\n", vobject );
  116. #endif /*VIPS_DEBUG_VERBOSE*/
  117. g_assert( !vobject ||
  118. VIPS_IS_OBJECT( vobject ) );
  119. if( vobject )
  120. g_object_unref( vobject );
  121. }
  122. VipsObject *get_object() const
  123. {
  124. g_assert( !vobject ||
  125. VIPS_IS_OBJECT( vobject ) );
  126. return( vobject );
  127. }
  128. bool is_null() const
  129. {
  130. return vobject == 0;
  131. }
  132. };
  133. class VIPS_CPLUSPLUS_API VImage;
  134. class VIPS_CPLUSPLUS_API VInterpolate;
  135. class VIPS_CPLUSPLUS_API VSource;
  136. class VIPS_CPLUSPLUS_API VTarget;
  137. class VIPS_CPLUSPLUS_API VOption;
  138. class VOption
  139. {
  140. private:
  141. struct Pair {
  142. const char *name;
  143. // the thing we pass to and from our caller
  144. GValue value;
  145. // an input or output parameter ... we guess the direction
  146. // from the arg to set()
  147. bool input;
  148. // the pointer we write output values to
  149. union {
  150. bool *vbool;
  151. int *vint;
  152. double *vdouble;
  153. VImage *vimage;
  154. std::vector<double> *vvector;
  155. VipsBlob **vblob;
  156. };
  157. Pair( const char *name ) :
  158. name( name ), input( false ), vimage( 0 )
  159. {
  160. // argh = {0} won't work wil vanilla C++
  161. memset( &value, 0, sizeof( GValue ) );
  162. }
  163. ~Pair()
  164. {
  165. g_value_unset( &value );
  166. }
  167. };
  168. std::list<Pair *> options;
  169. public:
  170. VOption()
  171. {
  172. }
  173. virtual ~VOption();
  174. VOption *set( const char *name, bool value );
  175. VOption *set( const char *name, int value );
  176. VOption *set( const char *name, double value );
  177. VOption *set( const char *name, const char *value );
  178. VOption *set( const char *name, const VImage value );
  179. VOption *set( const char *name, const VInterpolate value );
  180. VOption *set( const char *name, const VSource value );
  181. VOption *set( const char *name, const VTarget value );
  182. VOption *set( const char *name, std::vector<VImage> value );
  183. VOption *set( const char *name, std::vector<double> value );
  184. VOption *set( const char *name, std::vector<int> value );
  185. VOption *set( const char *name, VipsBlob *value );
  186. VOption *set( const char *name, bool *value );
  187. VOption *set( const char *name, int *value );
  188. VOption *set( const char *name, double *value );
  189. VOption *set( const char *name, VImage *value );
  190. VOption *set( const char *name, std::vector<double> *value );
  191. VOption *set( const char *name, VipsBlob **blob );
  192. void set_operation( VipsOperation *operation );
  193. void get_operation( VipsOperation *operation );
  194. };
  195. class VImage : VObject
  196. {
  197. public:
  198. using VObject::is_null;
  199. VImage( VipsImage *image, VSteal steal = STEAL ) :
  200. VObject( (VipsObject *) image, steal )
  201. {
  202. }
  203. // an empty (NULL) VImage, eg. "VImage a;"
  204. VImage() :
  205. VObject( 0 )
  206. {
  207. }
  208. VipsImage *
  209. get_image() const
  210. {
  211. return( (VipsImage *) VObject::get_object() );
  212. }
  213. int
  214. width() const
  215. {
  216. return( vips_image_get_width( get_image() ) );
  217. }
  218. int
  219. height() const
  220. {
  221. return( vips_image_get_height( get_image() ) );
  222. }
  223. int
  224. bands() const
  225. {
  226. return( vips_image_get_bands( get_image() ) );
  227. }
  228. VipsBandFormat
  229. format() const
  230. {
  231. return( vips_image_get_format( get_image() ) );
  232. }
  233. VipsCoding
  234. coding() const
  235. {
  236. return( vips_image_get_coding( get_image() ) );
  237. }
  238. VipsInterpretation
  239. interpretation() const
  240. {
  241. return( vips_image_get_interpretation( get_image() ) );
  242. }
  243. VipsInterpretation
  244. guess_interpretation() const
  245. {
  246. return( vips_image_guess_interpretation( get_image() ) );
  247. }
  248. double
  249. xres() const
  250. {
  251. return( vips_image_get_xres( get_image() ) );
  252. }
  253. double
  254. yres() const
  255. {
  256. return( vips_image_get_yres( get_image() ) );
  257. }
  258. int
  259. xoffset() const
  260. {
  261. return( vips_image_get_xoffset( get_image() ) );
  262. }
  263. int
  264. yoffset() const
  265. {
  266. return( vips_image_get_yoffset( get_image() ) );
  267. }
  268. bool
  269. has_alpha() const
  270. {
  271. return( vips_image_hasalpha( get_image() ) );
  272. }
  273. const char *
  274. filename() const
  275. {
  276. return( vips_image_get_filename( get_image() ) );
  277. }
  278. const void *
  279. data() const
  280. {
  281. return( vips_image_get_data( get_image() ) );
  282. }
  283. void
  284. set( const char *field, int value )
  285. {
  286. vips_image_set_int( this->get_image(), field, value );
  287. }
  288. void
  289. set( const char *field, int *value, int n )
  290. {
  291. vips_image_set_array_int( this->get_image(), field, value, n );
  292. }
  293. void
  294. set( const char *field, std::vector<int> value )
  295. {
  296. vips_image_set_array_int( this->get_image(), field, &value[0],
  297. static_cast<int>( value.size() ) );
  298. }
  299. void
  300. set( const char *field, double value )
  301. {
  302. vips_image_set_double( this->get_image(), field, value );
  303. }
  304. void
  305. set( const char *field, const char *value )
  306. {
  307. vips_image_set_string( this->get_image(), field, value );
  308. }
  309. void
  310. set( const char *field,
  311. VipsCallbackFn free_fn, void *data, size_t length )
  312. {
  313. vips_image_set_blob( this->get_image(), field,
  314. free_fn, data, length );
  315. }
  316. GType
  317. get_typeof( const char *field ) const
  318. {
  319. return( vips_image_get_typeof( this->get_image(), field ) );
  320. }
  321. int
  322. get_int( const char *field ) const
  323. {
  324. int value;
  325. if( vips_image_get_int( this->get_image(), field, &value ) )
  326. throw( VError() );
  327. return( value );
  328. }
  329. void
  330. get_array_int( const char *field, int **out, int *n ) const
  331. {
  332. if( vips_image_get_array_int( this->get_image(), field, out, n ) )
  333. throw( VError() );
  334. }
  335. std::vector<int>
  336. get_array_int( const char *field ) const
  337. {
  338. int length;
  339. int *array;
  340. if( vips_image_get_array_int( this->get_image(), field, &array, &length ) )
  341. throw( VError() );
  342. std::vector<int> vector( array, array + length );
  343. return( vector );
  344. }
  345. double
  346. get_double( const char *field ) const
  347. {
  348. double value;
  349. if( vips_image_get_double( this->get_image(), field, &value ) )
  350. throw( VError() );
  351. return( value );
  352. }
  353. const char *
  354. get_string( const char *field ) const
  355. {
  356. const char *value;
  357. if( vips_image_get_string( this->get_image(), field, &value ) )
  358. throw( VError() );
  359. return( value );
  360. }
  361. const void *
  362. get_blob( const char *field, size_t *length ) const
  363. {
  364. const void *value;
  365. if( vips_image_get_blob( this->get_image(), field,
  366. &value, length ) )
  367. throw( VError() );
  368. return( value );
  369. }
  370. bool
  371. remove( const char *name ) const
  372. {
  373. return( vips_image_remove( get_image(), name ) );
  374. }
  375. static VOption *
  376. option()
  377. {
  378. return( new VOption() );
  379. }
  380. static void call_option_string( const char *operation_name,
  381. const char *option_string, VOption *options = 0 );
  382. static void call( const char *operation_name, VOption *options = 0 );
  383. static VImage
  384. new_memory()
  385. {
  386. return( VImage( vips_image_new_memory() ) );
  387. }
  388. static VImage
  389. new_temp_file( const char *file_format = ".v" )
  390. {
  391. VipsImage *image;
  392. if( !(image = vips_image_new_temp_file( file_format )) )
  393. throw( VError() );
  394. return( VImage( image ) );
  395. }
  396. static VImage new_from_file( const char *name, VOption *options = 0 );
  397. static VImage
  398. new_from_memory( void *data, size_t size,
  399. int width, int height, int bands, VipsBandFormat format )
  400. {
  401. VipsImage *image;
  402. if( !(image = vips_image_new_from_memory( data, size,
  403. width, height, bands, format )) )
  404. throw( VError() );
  405. return( VImage( image ) );
  406. }
  407. static VImage new_from_buffer( const void *buf, size_t len,
  408. const char *option_string, VOption *options = 0 );
  409. static VImage new_from_buffer( const std::string &buf,
  410. const char *option_string, VOption *options = 0 );
  411. static VImage new_from_source( VSource source,
  412. const char *option_string, VOption *options = 0 );
  413. static VImage new_matrix( int width, int height );
  414. static VImage
  415. new_matrix( int width, int height, double *array, int size )
  416. {
  417. VipsImage *image;
  418. if( !(image = vips_image_new_matrix_from_array( width, height,
  419. array, size )) )
  420. throw( VError() );
  421. return( VImage( image ) );
  422. }
  423. static VImage new_matrixv( int width, int height, ... );
  424. VImage
  425. new_from_image( std::vector<double> pixel ) const
  426. {
  427. VipsImage *image;
  428. if( !(image = vips_image_new_from_image( this->get_image(),
  429. &pixel[0], static_cast<int>( pixel.size() ) )) )
  430. throw( VError() );
  431. return( VImage( image ) );
  432. }
  433. VImage
  434. new_from_image( double pixel ) const
  435. {
  436. return( new_from_image( to_vectorv( 1, pixel ) ) );
  437. }
  438. VImage
  439. copy_memory() const
  440. {
  441. VipsImage *image;
  442. if( !(image = vips_image_copy_memory( this->get_image() )) )
  443. throw( VError() );
  444. return( VImage( image ) );
  445. }
  446. VImage write( VImage out ) const;
  447. void write_to_file( const char *name, VOption *options = 0 ) const;
  448. void write_to_buffer( const char *suffix, void **buf, size_t *size,
  449. VOption *options = 0 ) const;
  450. void write_to_target( const char *suffix, VTarget target,
  451. VOption *options = 0 ) const;
  452. void *
  453. write_to_memory( size_t *size ) const
  454. {
  455. void *result;
  456. if( !(result = vips_image_write_to_memory( this->get_image(),
  457. size )) )
  458. throw( VError() );
  459. return( result );
  460. }
  461. #include "vips-operators.h"
  462. // a few useful things
  463. VImage
  464. linear( double a, double b, VOption *options = 0 ) const
  465. {
  466. return( this->linear( to_vector( a ), to_vector( b ),
  467. options ) );
  468. }
  469. VImage
  470. linear( std::vector<double> a, double b, VOption *options = 0 ) const
  471. {
  472. return( this->linear( a, to_vector( b ), options ) );
  473. }
  474. VImage
  475. linear( double a, std::vector<double> b, VOption *options = 0 ) const
  476. {
  477. return( this->linear( to_vector( a ), b, options ) );
  478. }
  479. std::vector<VImage> bandsplit( VOption *options = 0 ) const;
  480. VImage bandjoin( VImage other, VOption *options = 0 ) const;
  481. VImage
  482. bandjoin( double other, VOption *options = 0 ) const
  483. {
  484. return( bandjoin( to_vector( other ), options ) );
  485. }
  486. VImage
  487. bandjoin( std::vector<double> other, VOption *options = 0 ) const
  488. {
  489. return( bandjoin_const( other, options ) );
  490. }
  491. VImage composite( VImage other, VipsBlendMode mode,
  492. VOption *options = 0 ) const;
  493. std::complex<double> minpos( VOption *options = 0 ) const;
  494. std::complex<double> maxpos( VOption *options = 0 ) const;
  495. VImage
  496. fliphor( VOption *options = 0 ) const
  497. {
  498. return( flip( VIPS_DIRECTION_HORIZONTAL, options ) );
  499. }
  500. VImage
  501. flipver( VOption *options = 0 ) const
  502. {
  503. return( flip( VIPS_DIRECTION_VERTICAL, options ) );
  504. }
  505. VImage
  506. rot90( VOption *options = 0 ) const
  507. {
  508. return( rot( VIPS_ANGLE_D90, options ) );
  509. }
  510. VImage
  511. rot180( VOption *options = 0 ) const
  512. {
  513. return( rot( VIPS_ANGLE_D180, options ) );
  514. }
  515. VImage
  516. rot270( VOption *options = 0 ) const
  517. {
  518. return( rot( VIPS_ANGLE_D270, options ) );
  519. }
  520. VImage
  521. dilate( VImage mask, VOption *options = 0 ) const
  522. {
  523. return( morph( mask, VIPS_OPERATION_MORPHOLOGY_DILATE,
  524. options ) );
  525. }
  526. VImage
  527. erode( VImage mask, VOption *options = 0 ) const
  528. {
  529. return( morph( mask, VIPS_OPERATION_MORPHOLOGY_ERODE,
  530. options ) );
  531. }
  532. VImage
  533. median( int size = 3, VOption *options = 0 ) const
  534. {
  535. return( rank( size, size, (size * size) / 2, options ) );
  536. }
  537. VImage
  538. floor( VOption *options = 0 ) const
  539. {
  540. return( round( VIPS_OPERATION_ROUND_FLOOR, options ) );
  541. }
  542. VImage
  543. ceil( VOption *options = 0 ) const
  544. {
  545. return( round( VIPS_OPERATION_ROUND_CEIL, options ) );
  546. }
  547. VImage
  548. rint( VOption *options = 0 ) const
  549. {
  550. return( round( VIPS_OPERATION_ROUND_RINT, options ) );
  551. }
  552. VImage
  553. bandand( VOption *options = 0 ) const
  554. {
  555. return( bandbool( VIPS_OPERATION_BOOLEAN_AND, options ) );
  556. }
  557. VImage
  558. bandor( VOption *options = 0 ) const
  559. {
  560. return( bandbool( VIPS_OPERATION_BOOLEAN_OR, options ) );
  561. }
  562. VImage
  563. bandeor( VOption *options = 0 ) const
  564. {
  565. return( bandbool( VIPS_OPERATION_BOOLEAN_EOR, options ) );
  566. }
  567. VImage
  568. real( VOption *options = 0 ) const
  569. {
  570. return( complexget( VIPS_OPERATION_COMPLEXGET_REAL, options ) );
  571. }
  572. VImage
  573. imag( VOption *options = 0 ) const
  574. {
  575. return( complexget( VIPS_OPERATION_COMPLEXGET_IMAG, options ) );
  576. }
  577. VImage
  578. polar( VOption *options = 0 ) const
  579. {
  580. return( complex( VIPS_OPERATION_COMPLEX_POLAR, options ) );
  581. }
  582. VImage
  583. rect( VOption *options = 0 ) const
  584. {
  585. return( complex( VIPS_OPERATION_COMPLEX_RECT, options ) );
  586. }
  587. VImage
  588. conj( VOption *options = 0 ) const
  589. {
  590. return( complex( VIPS_OPERATION_COMPLEX_CONJ, options ) );
  591. }
  592. VImage
  593. sin( VOption *options = 0 ) const
  594. {
  595. return( math( VIPS_OPERATION_MATH_SIN, options ) );
  596. }
  597. VImage
  598. cos( VOption *options = 0 ) const
  599. {
  600. return( math( VIPS_OPERATION_MATH_COS, options ) );
  601. }
  602. VImage
  603. tan( VOption *options = 0 ) const
  604. {
  605. return( math( VIPS_OPERATION_MATH_TAN, options ) );
  606. }
  607. VImage
  608. asin( VOption *options = 0 ) const
  609. {
  610. return( math( VIPS_OPERATION_MATH_ASIN, options ) );
  611. }
  612. VImage
  613. acos( VOption *options = 0 ) const
  614. {
  615. return( math( VIPS_OPERATION_MATH_ACOS, options ) );
  616. }
  617. VImage
  618. atan( VOption *options = 0 ) const
  619. {
  620. return( math( VIPS_OPERATION_MATH_ATAN, options ) );
  621. }
  622. VImage
  623. log( VOption *options = 0 ) const
  624. {
  625. return( math( VIPS_OPERATION_MATH_LOG, options ) );
  626. }
  627. VImage
  628. log10( VOption *options = 0 ) const
  629. {
  630. return( math( VIPS_OPERATION_MATH_LOG10, options ) );
  631. }
  632. VImage
  633. exp( VOption *options = 0 ) const
  634. {
  635. return( math( VIPS_OPERATION_MATH_EXP, options ) );
  636. }
  637. VImage
  638. exp10( VOption *options = 0 ) const
  639. {
  640. return( math( VIPS_OPERATION_MATH_EXP10, options ) );
  641. }
  642. VImage
  643. pow( VImage other, VOption *options = 0 ) const
  644. {
  645. return( math2( other, VIPS_OPERATION_MATH2_POW, options ) );
  646. }
  647. VImage
  648. pow( double other, VOption *options = 0 ) const
  649. {
  650. return( math2_const( VIPS_OPERATION_MATH2_POW,
  651. to_vector( other ), options ) );
  652. }
  653. VImage
  654. pow( std::vector<double> other, VOption *options = 0 ) const
  655. {
  656. return( math2_const( VIPS_OPERATION_MATH2_POW,
  657. other, options ) );
  658. }
  659. VImage
  660. wop( VImage other, VOption *options = 0 ) const
  661. {
  662. return( math2( other, VIPS_OPERATION_MATH2_WOP, options ) );
  663. }
  664. VImage
  665. wop( double other, VOption *options = 0 ) const
  666. {
  667. return( math2_const( VIPS_OPERATION_MATH2_WOP,
  668. to_vector( other ), options ) );
  669. }
  670. VImage
  671. wop( std::vector<double> other, VOption *options = 0 ) const
  672. {
  673. return( math2_const( VIPS_OPERATION_MATH2_WOP,
  674. other, options ) );
  675. }
  676. VImage
  677. ifthenelse( std::vector<double> th, VImage el,
  678. VOption *options = 0 ) const
  679. {
  680. return( ifthenelse( el.new_from_image( th ), el, options ) );
  681. }
  682. VImage
  683. ifthenelse( VImage th, std::vector<double> el,
  684. VOption *options = 0 ) const
  685. {
  686. return( ifthenelse( th, th.new_from_image( el ), options ) );
  687. }
  688. VImage
  689. ifthenelse( std::vector<double> th, std::vector<double> el,
  690. VOption *options = 0 ) const
  691. {
  692. return( ifthenelse( new_from_image( th ), new_from_image( el ),
  693. options ) );
  694. }
  695. VImage
  696. ifthenelse( double th, VImage el, VOption *options = 0 ) const
  697. {
  698. return( ifthenelse( to_vector( th ), el, options ) );
  699. }
  700. VImage
  701. ifthenelse( VImage th, double el, VOption *options = 0 ) const
  702. {
  703. return( ifthenelse( th, to_vector( el ), options ) );
  704. }
  705. VImage
  706. ifthenelse( double th, double el, VOption *options = 0 ) const
  707. {
  708. return( ifthenelse( to_vector( th ), to_vector( el ),
  709. options ) );
  710. }
  711. // Operator overloads
  712. VImage operator[]( int index ) const;
  713. std::vector<double> operator()( int x, int y ) const;
  714. friend VIPS_CPLUSPLUS_API VImage
  715. operator+( const VImage a, const VImage b );
  716. friend VIPS_CPLUSPLUS_API VImage
  717. operator+( const double a, const VImage b );
  718. friend VIPS_CPLUSPLUS_API VImage
  719. operator+( const VImage a, const double b );
  720. friend VIPS_CPLUSPLUS_API VImage
  721. operator+( const std::vector<double> a, const VImage b );
  722. friend VIPS_CPLUSPLUS_API VImage
  723. operator+( const VImage a, const std::vector<double> b );
  724. friend VIPS_CPLUSPLUS_API VImage &
  725. operator+=( VImage &a, const VImage b );
  726. friend VIPS_CPLUSPLUS_API VImage &
  727. operator+=( VImage &a, const double b );
  728. friend VIPS_CPLUSPLUS_API VImage &
  729. operator+=( VImage &a, const std::vector<double> b );
  730. friend VIPS_CPLUSPLUS_API VImage
  731. operator-( const VImage a, const VImage b );
  732. friend VIPS_CPLUSPLUS_API VImage
  733. operator-( const double a, const VImage b );
  734. friend VIPS_CPLUSPLUS_API VImage
  735. operator-( const VImage a, const double b );
  736. friend VIPS_CPLUSPLUS_API VImage
  737. operator-( const std::vector<double> a, const VImage b );
  738. friend VIPS_CPLUSPLUS_API VImage
  739. operator-( const VImage a, const std::vector<double> b );
  740. friend VIPS_CPLUSPLUS_API VImage &
  741. operator-=( VImage &a, const VImage b );
  742. friend VIPS_CPLUSPLUS_API VImage &
  743. operator-=( VImage &a, const double b );
  744. friend VIPS_CPLUSPLUS_API VImage &
  745. operator-=( VImage &a, const std::vector<double> b );
  746. friend VIPS_CPLUSPLUS_API VImage
  747. operator-( const VImage a );
  748. friend VIPS_CPLUSPLUS_API VImage
  749. operator*( const VImage a, const VImage b );
  750. friend VIPS_CPLUSPLUS_API VImage
  751. operator*( const double a, const VImage b );
  752. friend VIPS_CPLUSPLUS_API VImage
  753. operator*( const VImage a, const double b );
  754. friend VIPS_CPLUSPLUS_API VImage
  755. operator*( const std::vector<double> a, const VImage b );
  756. friend VIPS_CPLUSPLUS_API VImage
  757. operator*( const VImage a, const std::vector<double> b );
  758. friend VIPS_CPLUSPLUS_API VImage &
  759. operator*=( VImage &a, const VImage b );
  760. friend VIPS_CPLUSPLUS_API VImage &
  761. operator*=( VImage &a, const double b );
  762. friend VIPS_CPLUSPLUS_API VImage &
  763. operator*=( VImage &a, const std::vector<double> b );
  764. friend VIPS_CPLUSPLUS_API VImage
  765. operator/( const VImage a, const VImage b );
  766. friend VIPS_CPLUSPLUS_API VImage
  767. operator/( const double a, const VImage b );
  768. friend VIPS_CPLUSPLUS_API VImage
  769. operator/( const VImage a, const double b );
  770. friend VIPS_CPLUSPLUS_API VImage
  771. operator/( const std::vector<double> a, const VImage b );
  772. friend VIPS_CPLUSPLUS_API VImage
  773. operator/( const VImage a, const std::vector<double> b );
  774. friend VIPS_CPLUSPLUS_API VImage &
  775. operator/=( VImage &a, const VImage b );
  776. friend VIPS_CPLUSPLUS_API VImage &
  777. operator/=( VImage &a, const double b );
  778. friend VIPS_CPLUSPLUS_API VImage &
  779. operator/=( VImage &a, const std::vector<double> b );
  780. friend VIPS_CPLUSPLUS_API VImage
  781. operator%( const VImage a, const VImage b );
  782. friend VIPS_CPLUSPLUS_API VImage
  783. operator%( const VImage a, const double b );
  784. friend VIPS_CPLUSPLUS_API VImage
  785. operator%( const VImage a, const std::vector<double> b );
  786. friend VIPS_CPLUSPLUS_API VImage &
  787. operator%=( VImage &a, const VImage b );
  788. friend VIPS_CPLUSPLUS_API VImage &
  789. operator%=( VImage &a, const double b );
  790. friend VIPS_CPLUSPLUS_API VImage &
  791. operator%=( VImage &a, const std::vector<double> b );
  792. friend VIPS_CPLUSPLUS_API VImage
  793. operator<( const VImage a, const VImage b );
  794. friend VIPS_CPLUSPLUS_API VImage
  795. operator<( const double a, const VImage b );
  796. friend VIPS_CPLUSPLUS_API VImage
  797. operator<( const VImage a, const double b );
  798. friend VIPS_CPLUSPLUS_API VImage
  799. operator<( const std::vector<double> a, const VImage b );
  800. friend VIPS_CPLUSPLUS_API VImage
  801. operator<( const VImage a, const std::vector<double> b );
  802. friend VIPS_CPLUSPLUS_API VImage
  803. operator<=( const VImage a, const VImage b );
  804. friend VIPS_CPLUSPLUS_API VImage
  805. operator<=( const double a, const VImage b );
  806. friend VIPS_CPLUSPLUS_API VImage
  807. operator<=( const VImage a, const double b );
  808. friend VIPS_CPLUSPLUS_API VImage
  809. operator<=( const std::vector<double> a, const VImage b );
  810. friend VIPS_CPLUSPLUS_API VImage
  811. operator<=( const VImage a, const std::vector<double> b );
  812. friend VIPS_CPLUSPLUS_API VImage
  813. operator>( const VImage a, const VImage b );
  814. friend VIPS_CPLUSPLUS_API VImage
  815. operator>( const double a, const VImage b );
  816. friend VIPS_CPLUSPLUS_API VImage
  817. operator>( const VImage a, const double b );
  818. friend VIPS_CPLUSPLUS_API VImage
  819. operator>( const std::vector<double> a, const VImage b );
  820. friend VIPS_CPLUSPLUS_API VImage
  821. operator>( const VImage a, const std::vector<double> b );
  822. friend VIPS_CPLUSPLUS_API VImage
  823. operator>=( const VImage a, const VImage b );
  824. friend VIPS_CPLUSPLUS_API VImage
  825. operator>=( const double a, const VImage b );
  826. friend VIPS_CPLUSPLUS_API VImage
  827. operator>=( const VImage a, const double b );
  828. friend VIPS_CPLUSPLUS_API VImage
  829. operator>=( const std::vector<double> a, const VImage b );
  830. friend VIPS_CPLUSPLUS_API VImage
  831. operator>=( const VImage a, const std::vector<double> b );
  832. friend VIPS_CPLUSPLUS_API VImage
  833. operator==( const VImage a, const VImage b );
  834. friend VIPS_CPLUSPLUS_API VImage
  835. operator==( const double a, const VImage b );
  836. friend VIPS_CPLUSPLUS_API VImage
  837. operator==( const VImage a, const double b );
  838. friend VIPS_CPLUSPLUS_API VImage
  839. operator==( const std::vector<double> a, const VImage b );
  840. friend VIPS_CPLUSPLUS_API VImage
  841. operator==( const VImage a, const std::vector<double> b );
  842. friend VIPS_CPLUSPLUS_API VImage
  843. operator!=( const VImage a, const VImage b );
  844. friend VIPS_CPLUSPLUS_API VImage
  845. operator!=( const double a, const VImage b );
  846. friend VIPS_CPLUSPLUS_API VImage
  847. operator!=( const VImage a, const double b );
  848. friend VIPS_CPLUSPLUS_API VImage
  849. operator!=( const std::vector<double> a, const VImage b );
  850. friend VIPS_CPLUSPLUS_API VImage
  851. operator!=( const VImage a, const std::vector<double> b );
  852. friend VIPS_CPLUSPLUS_API VImage
  853. operator&( const VImage a, const VImage b );
  854. friend VIPS_CPLUSPLUS_API VImage
  855. operator&( const double a, const VImage b );
  856. friend VIPS_CPLUSPLUS_API VImage
  857. operator&( const VImage a, const double b );
  858. friend VIPS_CPLUSPLUS_API VImage
  859. operator&( const std::vector<double> a, const VImage b );
  860. friend VIPS_CPLUSPLUS_API VImage
  861. operator&( const VImage a, const std::vector<double> b );
  862. friend VIPS_CPLUSPLUS_API VImage &
  863. operator&=( VImage &a, const VImage b );
  864. friend VIPS_CPLUSPLUS_API VImage &
  865. operator&=( VImage &a, const double b );
  866. friend VIPS_CPLUSPLUS_API VImage &
  867. operator&=( VImage &a, const std::vector<double> b );
  868. friend VIPS_CPLUSPLUS_API VImage
  869. operator|( const VImage a, const VImage b );
  870. friend VIPS_CPLUSPLUS_API VImage
  871. operator|( const double a, const VImage b );
  872. friend VIPS_CPLUSPLUS_API VImage
  873. operator|( const VImage a, const double b );
  874. friend VIPS_CPLUSPLUS_API VImage
  875. operator|( const std::vector<double> a, const VImage b );
  876. friend VIPS_CPLUSPLUS_API VImage
  877. operator|( const VImage a, const std::vector<double> b );
  878. friend VIPS_CPLUSPLUS_API VImage &
  879. operator|=( VImage &a, const VImage b );
  880. friend VIPS_CPLUSPLUS_API VImage &
  881. operator|=( VImage &a, const double b );
  882. friend VIPS_CPLUSPLUS_API VImage &
  883. operator|=( VImage &a, const std::vector<double> b );
  884. friend VIPS_CPLUSPLUS_API VImage
  885. operator^( const VImage a, const VImage b );
  886. friend VIPS_CPLUSPLUS_API VImage
  887. operator^( const double a, const VImage b );
  888. friend VIPS_CPLUSPLUS_API VImage
  889. operator^( const VImage a, const double b );
  890. friend VIPS_CPLUSPLUS_API VImage
  891. operator^( const std::vector<double> a, const VImage b );
  892. friend VIPS_CPLUSPLUS_API VImage
  893. operator^( const VImage a, const std::vector<double> b );
  894. friend VIPS_CPLUSPLUS_API VImage &
  895. operator^=( VImage &a, const VImage b );
  896. friend VIPS_CPLUSPLUS_API VImage &
  897. operator^=( VImage &a, const double b );
  898. friend VIPS_CPLUSPLUS_API VImage &
  899. operator^=( VImage &a, const std::vector<double> b );
  900. friend VIPS_CPLUSPLUS_API VImage
  901. operator<<( const VImage a, const VImage b );
  902. friend VIPS_CPLUSPLUS_API VImage
  903. operator<<( const VImage a, const double b );
  904. friend VIPS_CPLUSPLUS_API VImage
  905. operator<<( const VImage a, const std::vector<double> b );
  906. friend VIPS_CPLUSPLUS_API VImage &
  907. operator<<=( VImage &a, const VImage b );
  908. friend VIPS_CPLUSPLUS_API VImage &
  909. operator<<=( VImage &a, const double b );
  910. friend VIPS_CPLUSPLUS_API VImage &
  911. operator<<=( VImage &a, const std::vector<double> b );
  912. friend VIPS_CPLUSPLUS_API VImage
  913. operator>>( const VImage a, const VImage b );
  914. friend VIPS_CPLUSPLUS_API VImage
  915. operator>>( const VImage a, const double b );
  916. friend VIPS_CPLUSPLUS_API VImage
  917. operator>>( const VImage a, const std::vector<double> b );
  918. friend VIPS_CPLUSPLUS_API VImage &
  919. operator>>=( VImage &a, const VImage b );
  920. friend VIPS_CPLUSPLUS_API VImage &
  921. operator>>=( VImage &a, const double b );
  922. friend VIPS_CPLUSPLUS_API VImage &
  923. operator>>=( VImage &a, const std::vector<double> b );
  924. };
  925. VIPS_NAMESPACE_END
  926. #endif /*VIPS_VIMAGE_H*/