SMIL  0.9.1
DMorphMImage.hpp
1 /*
2  * Copyright (c) 2011-2016, Matthieu FAESSEL and ARMINES
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of Matthieu FAESSEL, or ARMINES nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _D_MORPHM_IMAGE_HPP
31 #define _D_MORPHM_IMAGE_HPP
32 
33 #include "Core/include/private/DImage.hxx"
34 #include "Core/include/private/DSharedImage.hpp"
35 
36 #include <morphee/image/include/private/image_T.hpp>
37 #include <morphee/image/include/imageInterface.hpp>
38 #include <morphee/image/include/imageUtils.hpp>
39 
40 #ifdef SWIGPYTHON
41 #include <boost/python.hpp>
42 #endif // SWIGPYTHON
43 
44 namespace smil
45 {
57  template <class T> class MorphmInt : public SharedImage<T>
58  {
59  public:
61 
62  MorphmInt(morphee::Image<T> &img)
63  {
64  BaseObject::className = "MorphmInt";
65  parentClass::init();
66  if (!img.isAllocated())
67  ERR_MSG("Source image isn't allocated");
68  else {
69  typename morphee::Image<T>::i_coordinate_system s = img.getSize();
70 
71  this->attach(img.rawPointer(), s[0], s[1], s[2]);
72  }
73  }
74  MorphmInt(morphee::ImageInterface &imgInt)
75  {
76  BaseObject::className = "MorphmInt";
77  parentClass::init();
78  if (!imgInt.isAllocated())
79  ERR_MSG("Source image isn't allocated");
80  else {
81  morphee::Image<T> *mIm = dynamic_cast<morphee::Image<T> *>(&imgInt);
82  if (!mIm)
83  ERR_MSG("Error in morphM dynamic_cast");
84  else {
85  typename morphee::Image<T>::i_coordinate_system s = mIm->getSize();
86  this->attach(mIm->rawPointer(), s[0], s[1], s[2]);
87  }
88  }
89  }
90 #if defined Py_PYCONFIG_H || defined SWIGPYTHON
91  MorphmInt(PyObject *obj)
92  {
93  BaseObject::className = "MorphmInt";
94  parentClass::init();
95  morphee::ImageInterface *imgInt =
96  boost::python::extract<morphee::ImageInterface *>(obj);
97  if (imgInt) {
98  if (!imgInt->isAllocated())
99  ERR_MSG("Source image isn't allocated");
100  else {
101  morphee::Image<T> *mIm = dynamic_cast<morphee::Image<T> *>(imgInt);
102  if (!mIm)
103  ERR_MSG("Error in morphM dynamic_cast");
104  else {
105  typename morphee::Image<T>::i_coordinate_system s = mIm->getSize();
106  this->attach(mIm->rawPointer(), s[0], s[1], s[2]);
107  }
108  }
109  }
110  }
111 #endif // Py_PYCONFIG_H
112  };
113 
116 } // namespace smil
117 
118 #endif // _D_MORPHM_IMAGE_HPP
Author Vincent Morard Date : 7 march 2011 See : Morard V. and Dokladal P. and Decenciere E...
Definition: DApplyThreshold.hpp:36
Image that uses an existing (1D) data pointer.
Definition: DImage.hpp:53
MorphM Image Interface.
Definition: DMorphMImage.hpp:57