Image Component Library (ICL)
Quick.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLQt/src/ICLQt/Quick.h **
10 ** Module : ICLQt **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/StringUtils.h>
35 #include <ICLUtils/Exception.h>
36 #include <ICLCore/Img.h>
37 
38 namespace icl{
39  namespace utils{}
40  namespace math{}
41  namespace core{}
42  namespace filter{}
43  namespace io{}
44  namespace qt{}
45  namespace geom{}
46  namespace cv{}
47  namespace markers{}
48  namespace physics{}
49 }
50 
51 #ifndef ICL_NO_USING_NAMESPACES
52 using namespace icl;
53 using namespace icl::utils;
54 using namespace icl::math;
55 using namespace icl::core;
56 using namespace icl::filter;
57 using namespace icl::io;
58 using namespace icl::qt;
59 using namespace icl::geom;
60 using namespace icl::cv;
61 using namespace icl::markers;
62 using namespace icl::physics;
63 #endif
64 
66 using namespace std;
67 
69 namespace icl{
70  namespace qt{
71 
72  #ifdef ICL_HAVE_QT
73 
75  ICLQt_API std::string openFileDialog(const std::string &filter = "",
76  const std::string &caption="open file",
77  const std::string &initialDirectory="_____last",
78  void *parentWidget=0) ;
79 
81 
82  ICLQt_API std::string saveFileDialog(const std::string &filter = "",
83  const std::string &caption="save file",
84  const std::string &initialDirectory="_____last",
85  void *parentWidget=0) ;
86 
88 
91  std::string textInputDialog(const std::string &caption="text ...",
92  const std::string &message="please write your text here",
93  const std::string &initialText="",
94  void *parentWidget=0,
95  core::ImgBase *visImage=0,
96  std::vector<std::string> completionOptions=std::vector<std::string>()) ;
97 
98 
100 
101  ICLQt_API std::string execute_process(const std::string &command);
102  #endif
103 
104  #define ICL_QUICK_DEPTH depth32f
105  #define ICL_QUICK_TYPE icl32f
106 
107 
110 
112  /* {{{ open */
114 
118  template<class T> ICLQt_API
119  core::Img<T> zeros(int width, int height, int channels=1);
120 
121  /***/
122  inline ImgQ zeros(int width, int height, int channels=1){
123  return zeros<ICL_QUICK_TYPE>(width,height,channels);
124  }
125 
126 
128 
132  template<class T> ICLQt_API
133  core::Img<T> ones(int width, int height, int channels=1);
134 
136  inline ImgQ ones(int width, int height, int channels=1){ return ones<ICL_QUICK_TYPE>(width,height,channels); }
139 
142  template<class T> ICLQt_API
143  core::Img<T> load(const std::string &filename);
144 
146  inline ImgQ load(const std::string &filename) { return load<ICL_QUICK_TYPE>(filename); }
149 
153  template<class T> ICLQt_API
154  core::Img<T> load(const std::string &filename, core::format fmt);
155 
157  inline ImgQ load(const std::string &filename, core::format fmt) { return load<ICL_QUICK_TYPE>(filename,fmt); }
160 
166  template<class T> ICLQt_API
167  core::Img<T> create(const std::string &name, core::format fmt=icl::core::formatRGB);
168 
170  inline ImgQ create(const std::string &name, core::format fmt=icl::core::formatRGB) { return create<ICL_QUICK_TYPE>(name,fmt); }
173 
181  template<class T> ICLQt_API
182  core::Img<T> grab(const std::string &dev, const std::string &devSpec,
184  bool releaseGrabber=false);
185 
187  inline ImgQ grab(const std::string &dev, const std::string &devSpec,
189  bool releaseGrabber=false){
190  return grab<ICL_QUICK_TYPE>(dev,devSpec,size,fmt,releaseGrabber);
191  }
195  /* }}} */
196 
198  /* {{{ open */
199 
201 
204  ICLQt_API core::Img8u cvt8u(const ImgQ &image);
205 
207 
210  ICLQt_API core::Img16s cvt16s(const ImgQ &image);
211 
213 
216  ICLQt_API core::Img32s cvt32s(const ImgQ &image);
217 
219 
222  ICLQt_API core::Img32f cvt32f(const ImgQ &image);
223 
225 
228  ICLQt_API core::Img64f cvt64f(const ImgQ &image);
229 
231 
234  ICLQt_API ImgQ cvt(const core::Img8u &image);
235 
237 
241  ICLQt_API ImgQ cvt(const core::Img16s &image);
242 
244 
247  ICLQt_API ImgQ cvt(const core::Img32s &image);
248 
250 
254  ICLQt_API ImgQ cvt(const core::Img32f &image);
255 
257 
260  ICLQt_API ImgQ cvt(const core::Img64f &image);
263 
267  ICLQt_API ImgQ cvt(const core::ImgBase *image);
268 
269 
271 
274  ICLQt_API ImgQ cvt(const core::ImgBase &image);
276  /* }}} */
277 
279  /* {{{ open */
280 
282 
287  template<class T> ICLQt_API
288  core::Img<T> filter(const core::Img<T> &image, const std::string &filter);
289 
291  inline ImgQ filter(const ImgQ &image, const std::string &filter){
292  return icl::qt::filter<float>(image,filter);
293  }
296 
298  template<class T> ICLQt_API
299  core::Img<T> blur(const core::Img<T> &image, int maskRadius=1);
300 
302  inline ImgQ blur(const ImgQ &image, int maskRadius=1){
303  return icl::qt::blur<float>(image,maskRadius);
304  }
307 
311  ICLQt_API ImgQ cc(const ImgQ& image, core::format fmt);
312 
314 
315  ICLQt_API ImgQ rgb(const ImgQ &image);
316 
318 
319  ICLQt_API ImgQ hls(const ImgQ &image);
320 
322 
323  ICLQt_API ImgQ lab(const ImgQ &image);
324 
326 
327  ICLQt_API ImgQ gray(const ImgQ &image);
328 
330 
333  ICLQt_API ImgQ scale(const ImgQ& image, float factor);
334 
336 
340  ICLQt_API ImgQ scale(const ImgQ& image, int width, int height);
341 
343 
346  ICLQt_API ImgQ channel(const ImgQ &image, int channel);
347 
349 
355  ICLQt_API ImgQ levels(const ImgQ &image, icl8u levels);
356 
358 
361  ICLQt_API ImgQ thresh(const ImgQ &image, float threshold);
362 
364 
365  template<class T> ICLQt_API
366  core::Img<T> copy(const core::Img<T> &image);
367 
369 
370  template <class T> ICLQt_API
371  core::Img<T> copyroi(const core::Img<T> &image);
372 
374 
375  template<class T> ICLQt_API
376  core::Img<T> norm(const core::Img<T> &image);
377 
379 
380  ICLQt_API ImgQ flipx(const ImgQ& image);
381 
383 
384  ICLQt_API ImgQ flipy(const ImgQ& image);
385 
387  /* }}} */
388 
390  /* {{{ open */
391 
393 
396  ICLQt_API void save(const core::ImgBase &image, const std::string &filename);
397 
399 
406  ICLQt_API void show(const icl::core::ImgBase &image);
407 
409 
420  ICLQt_API void showSetup(const string &showCommand = "xv %s", const string &rmCommand = "rm -rf %s", int msecBeforeDelete = 500);
421 
423 
424  template<class T>
425  void print(const core::Img<T> &image);
426 
428  /* }}} */
429 
431  /* {{{ open */
432 
434 
437  ICLQt_API ImgQ operator+(const ImgQ &a, const ImgQ &b);
438 
440 
443  ICLQt_API ImgQ operator-(const ImgQ &a, const ImgQ &b);
444 
446 
449  ICLQt_API ImgQ operator*(const ImgQ &a, const ImgQ &b);
450 
452 
455  ICLQt_API ImgQ operator/(const ImgQ &a, const ImgQ &b);
456 
458 
461  ICLQt_API ImgQ operator+(const ImgQ &image, float val);
462 
464 
467  ICLQt_API ImgQ operator-(const ImgQ &image, float val);
468 
470 
473  ICLQt_API ImgQ operator*(const ImgQ &image, float val);
474 
476 
479  ICLQt_API ImgQ operator/(const ImgQ &image, float val);
480 
482 
485  ICLQt_API ImgQ operator+(float val, const ImgQ &image);
486 
488 
491  ICLQt_API ImgQ operator-(float val, const ImgQ &image);
492 
494 
497  ICLQt_API ImgQ operator*(float val, const ImgQ &image);
498 
500 
503  ICLQt_API ImgQ operator/(float val, const ImgQ &image);
504 
506 
507  ICLQt_API ImgQ operator-(const ImgQ &image);
508 
510  /* }}} */
511 
513  /* {{{ open */
514 
516 
517  ICLQt_API ImgQ exp(const ImgQ &image);
518 
520 
521  ICLQt_API ImgQ ln(const ImgQ &image);
522 
524 
525  ICLQt_API ImgQ sqr(const ImgQ &image);
526 
528 
529  ICLQt_API ImgQ sqrt(const ImgQ &image);
530 
532 
533  ICLQt_API ImgQ abs(const ImgQ &image);
534 
536  /* }}} */
537 
539  /* {{{ open */
540 
541 
543 
546  ICLQt_API ImgQ operator||(const ImgQ &a, const ImgQ &b);
547 
549 
552  ICLQt_API ImgQ operator&&(const ImgQ &a, const ImgQ &b);
553 
555  template<class T> ICLQt_API
556  ImgQ binOR(const ImgQ &a, const ImgQ &b);
557 
559  template<class T> ICLQt_API
560  ImgQ binXOR(const ImgQ &a, const ImgQ &b);
561 
563  template<class T> ICLQt_API
564  ImgQ binAND(const ImgQ &a, const ImgQ &b);
565 
567  /* }}} */
568 
570  /* {{{ open */
571 
573 
590  ICLQt_API ImgQ operator,(const ImgQ &a, const ImgQ &b);
591 
593 
596  ICLQt_API ImgQ operator%(const ImgQ &a, const ImgQ &b);
597 
599 
603  ICLQt_API ImgQ operator|(const ImgQ &a, const ImgQ &b);
604 
606  /* }}} */
607 
609  /* {{{ open */
610 
611 
613 
617 
619 
620  ImgROI &operator=(const ImgQ &i);
621 
623 
624  ImgROI &operator=(float val);
625 
627 
628  ImgROI &operator=(const ImgROI &r);
629 
631  operator ImgQ();
632  };
633 
635 
656  ICLQt_API ImgROI roi(ImgQ &r);
657 
659 
680 
682  /* }}} */
683 
685  /* {{{ open */
686 
688 
693  ICLQt_API void color(float r, float g = -1, float b = -1, float alpha = 255);
694 
696 
701  ICLQt_API void fill(float r, float g = -1, float b = -1, float alpha = 255);
702 
704 
707  ICLQt_API void colorinfo(float color[4], float fill[4]);
708 
710 
714  ICLQt_API void cross(ImgQ &image, int x, int y);
715 
717 
720  inline void cross(ImgQ &image, const utils::Point &p) { cross(image,p.x,p.y); }
721 
723 
730  ICLQt_API void rect(ImgQ &image, int x, int y, int w, int h, int rounding = 0);
731 
733 
737  inline void rect(ImgQ &image, const utils::Rect &r, int rounding=0){ rect(image,r.x,r.y,r.width,r.height,rounding); }
738 
740 
741  ICLQt_API void triangle(ImgQ &image, int x1, int y1, int x2, int y2, int x3, int y3);
742 
744  inline void triangle(ImgQ &image, const utils::Point &a, const utils::Point &b, const utils::Point &c){
745  triangle(image,a.x,a.y,b.x,b.y,c.x,c.y);
746  }
747 
749 
755  ICLQt_API void line(ImgQ &image, int x1, int y1, int x2, int y2);
756 
758 
762  inline void line(ImgQ &image, const utils::Point &p1, const utils::Point &p2){ line(image,p1.x,p1.y, p2.x,p2.y); }
763 
765 
768  ICLQt_API void linestrip(ImgQ &image, const std::vector<utils::Point> &pts, bool closeLoop = true);
769 
771  ICLQt_API void polygon(ImgQ &image, const std::vector<utils::Point> &corners);
772 
774 
778  ICLQt_API void pix(ImgQ &image, int x, int y);
779 
781 
784  inline void pix(ImgQ &image, const utils::Point &p){ pix(image,p.x,p.y); }
785 
787 
790  ICLQt_API void pix(ImgQ &image, const vector<utils::Point> &pts);
791 
793 
796  ICLQt_API void pix(ImgQ &image, const vector<vector<utils::Point> > &pts);
797 
799 
806  ICLQt_API void circle(ImgQ &image, int x, int y, int r);
807 
809 
816  ICLQt_API void text(ImgQ &image, int x, int y, const string &text);
817 
819 
825  inline void text(ImgQ &image, const utils::Point &p,const string &sText){ text(image,p.x,p.y,sText); }
826 
828 
832  ICLQt_API ImgQ label(const ImgQ &image, const string &text);
833 
835 
838  ICLQt_API void font(int size, const string &family = "Arial");
839 
841 
842  ICLQt_API void fontsize(int size);
844  /* }}} */
845 
847  /* {{{ open */
848 
850  ICLQt_API void tic(const std::string &label = "");
851 
853  ICLQt_API void toc();
855  /* }}} */
856 
857  } // namespace qt
858 }
859 
Definition: Any.h:38
ICLQt_API ImgQ sqrt(const ImgQ &image)
calls sqrt( each pixel)
ICLQt_API ImgQ binXOR(const ImgQ &a, const ImgQ &b)
pixels-wise binary or (each value is converted to T brefore binary or)
ICLQt_API ImgQ operator-(const ImgQ &image)
returns image*(-1)
bool operator||(const ProgArg &a, const ProgArg &b)
this allows to check if either of two progargs are defined
Definition: ProgArg.h:202
ICLQt_API void save(const core::ImgBase &image, const std::string &filename)
write an image to HD
ICLQt_API void polygon(ImgQ &image, const std::vector< utils::Point > &corners)
draws a polygon (constructed out of linestrips
void rect(ImgQ &image, const utils::Rect &r, int rounding=0)
draws a rect into an image
Definition: Quick.h:737
undocument this line if you encounter any issues!
Definition: Any.h:37
ICLQt_API ImgQ binAND(const ImgQ &a, const ImgQ &b)
pixels-wise binary or (each value is converted to T brefore binary or)
void line(ImgQ &image, const utils::Point &p1, const utils::Point &p2)
draws a line into an image
Definition: Quick.h:762
static const Size null
null is w=0, h=0
Definition: Size.h:64
ICLQt_API core::Img< T > norm(const core::Img< T > &image)
normalize an images range to [0,255]
Ipp8u icl8u
8Bit unsigned integer type for the ICL
Definition: BasicTypes.h:64
ICLQt_API std::string openFileDialog(const std::string &filter="", const std::string &caption="open file", const std::string &initialDirectory="_____last", void *parentWidget=0)
uses Qt to spawn an open-file dialog with given filter
ICLQt_API void fontsize(int size)
sets up current fontsize (only available with Qt-Support)
ICLQt_API ImgQ operator|(const ImgQ &a, const ImgQ &b)
channel concatenation of images
ICLQt_API ImgQ cc(const ImgQ &image, core::format fmt)
applies a color conversion
ICLQt_API core::Img< T > create(const std::string &name, core::format fmt=icl::core::formatRGB)
create a test image (converted to destination core::format) (affinity for floats)
Definition: AbstractCanvas.h:46
ICLQt_API ImgQ rgb(const ImgQ &image)
converts a given image to formatRGB
ICLQt_API ImgQ levels(const ImgQ &image, icl8u levels)
reduces an images quantisation levels
ICLQt_API ImgQ cvt(const core::ImgBase &image)
Converts a given core::ImgBase into an ImgQ.
Definition: DataSegmentBase.h:40
ICLQt_API ImgROI roi(ImgQ &r)
creates a ROI-struct from an image
ICLQt_API ImgQ operator,(const ImgQ &a, const ImgQ &b)
horizontal image concatenation
ICLQt_API ImgQ flipx(const ImgQ &image)
horizontal flip of an image
ICLQt_API ImgQ ln(const ImgQ &image)
calls ln( each pixel )
void text(ImgQ &image, const utils::Point &p, const string &sText)
renders a text into an image (only available with Qt-Support)
Definition: Quick.h:825
ICLQt_API core::Img< T > zeros(int width, int height, int channels=1)
create an empty (black) ImgQ (affinity for floats)
Definition: Quick.h:122
ICLQt_API void font(int size, const string &family="Arial")
sets up the current font (only available with Qt-Support)
ICLQt_API core::Img32s cvt32s(const ImgQ &image)
Converts the image into depth32s.
Definition: ColorFormatDecoder.h:40
ICLQt_API core::Img32f cvt32f(const ImgQ &image)
Converts the image into depth32f.
Definition: Quick.h:46
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
format
determines the color-format, that is associated with the images channels
Definition: Types.h:70
ICLQt_API core::Img< T > load(const std::string &filename, core::format fmt)
loads an image file and returns image in given core::format (affinity for floats)
ICLQt_API void linestrip(ImgQ &image, const std::vector< utils::Point > &pts, bool closeLoop=true)
draws a strip of connected lines
ICLQt_API ImgQ label(const ImgQ &image, const string &text)
labels an image in the upper left corner (only available with Qt-Support)
ICLQt_API ImgQ scale(const ImgQ &image, int width, int height)
scales an image to the given size
core::Img< ICL_QUICK_TYPE > ImgQ
typedef for the quick images type (this time core::Img<icl32f>)
Definition: Quick.h:109
Definition: DynMatrix.h:53
ICLQt_API core::Img< T > copy(const core::Img< T > &image)
deep copy for an image
ICLQt_API void toc()
stops a timer started with tic()
ICLQt_API ImgQ hls(const ImgQ &image)
converts a given image to formatHLS
ICLQt_API void fill(float r, float g=-1, float b=-1, float alpha=255)
sets the current fill color to given r,g,b,alpha value
void cross(ImgQ &image, const utils::Point &p)
draws a 6x6-cross into an image
Definition: Quick.h:720
ICLQt_API ImgQ operator+(float val, const ImgQ &image)
adds a constant to each pixel value
ICLQt_API ImgQ abs(const ImgQ &image)
calls abs ( each pixel)
ImgQ image
image data
Definition: Quick.h:616
Size class of the ICL.
Definition: Size.h:61
ICLQt_API void colorinfo(float color[4], float fill[4])
returns the current color state
ICLQt_API core::Img16s cvt16s(const ImgQ &image)
Converts the image into depth16.
ICLQt_API core::Img< T > filter(const core::Img< T > &image, const std::string &filter)
applies a filter operation on the source image (affinity for float)
ICLQt_API void showSetup(const string &showCommand="xv %s", const string &rmCommand="rm -rf %s", int msecBeforeDelete=500)
setup image visualisation programm
static T sqr(const T &x)
square template (faster than pow(x,2)
Definition: Macros.h:212
ICLQt_API ImgQ thresh(const ImgQ &image, float threshold)
performs an image binarisation for each channel with given threshold
ICLQt_API void tic(const std::string &label="")
starts a timer
ICLQt_API ImgQ gray(const ImgQ &image)
converts a given image to formatGray
ICLQt_API ImgQ binOR(const ImgQ &a, const ImgQ &b)
pixels-wise binary or (each value is converted to T brefore binary or)
ICLQt_API core::Img8u cvt8u(const ImgQ &image)
Converts the image into depth8u.
ICLQt_API core::Img< T > ones(int width, int height, int channels=1)
create an ImgQ that is pre-initialized with ones (affinity for floats)
ICLQt_API core::Img< T > copyroi(const core::Img< T > &image)
deep copy of an images roi
ICLQt_API ImgQ lab(const ImgQ &image)
converts a given image to formatLAB
#define ICLQt_API
Definition: CompatMacros.h:178
void triangle(ImgQ &image, const utils::Point &a, const utils::Point &b, const utils::Point &c)
draws a triangle into an image
Definition: Quick.h:744
Definition: Quick.h:48
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
ICLQt_API void color(float r, float g=-1, float b=-1, float alpha=255)
sets the current color to given r,g,b,alpha value
Definition: AbstractPlotWidget.h:48
ICLQt_API core::Img< T > grab(const std::string &dev, const std::string &devSpec, const utils::Size &size=utils::Size::null, core::format fmt=core::formatRGB, bool releaseGrabber=false)
grabs a new image from given device (affinity for floats)
ICLQt_API void circle(ImgQ &image, int x, int y, int r)
renders a filled circle into an image
ICLQt_API ImgQ flipy(const ImgQ &image)
vertical flip of an image
ICLQt_API core::Img64f cvt64f(const ImgQ &image)
Converts the image into depth64f.
bool operator &&(const ProgArg &a, const ProgArg &b)
this allows to check if two progargs are defined
Definition: ProgArg.h:170
Definition: AffineOp.h:38
ICLQt_API ImgQ operator/(float val, const ImgQ &image)
divides a constant by each pixel value
ICLQt_API std::string execute_process(const std::string &command)
executes the given command as a child process and returns it output
ICLQt_API ImgQ operator *(float val, const ImgQ &image)
multiplies each pixel value with a constant
internal stuct, used for deep image copies
Definition: Quick.h:614
Rectangle class of the ICL used e.g. for the Images ROI-rect.
Definition: Rect.h:95
ICLQt_API ImgQ channel(const ImgQ &image, int channel)
picks a specific image channel
Definition: Quick.h:47
ICLQt_API ImgQ operator%(const ImgQ &a, const ImgQ &b)
vertical image combination (as ,-operator)
std::string textInputDialog(const std::string &caption="text ...", const std::string &message="please write your text here", const std::string &initialText="", void *parentWidget=0, core::ImgBase *visImage=0, std::vector< std::string > completionOptions=std::vector< std::string >())
uses Qt to spawn a text input dialog
void print(const core::Img< T > &image)
print the images parameters to std::out
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
ICLQt_API void show(const icl::core::ImgBase &image)
shows an image using TestImages::show
ICLQt_API core::Img< T > blur(const core::Img< T > &image, int maskRadius=1)
applies gaussian blur to a given image (using a maskRadius*2+1-sized gaussian filter)
ICLQt_API std::string saveFileDialog(const std::string &filter="", const std::string &caption="save file", const std::string &initialDirectory="_____last", void *parentWidget=0)
uses Qt to spawn a save-file dialog with given filter
ICLQt_API void pix(ImgQ &image, const vector< vector< utils::Point > > &pts)
draws a set of point sets into an image
ICLQt_API ImgQ exp(const ImgQ &image)
calls exp( each pixel )
Definition: Types.h:72