DGtal  1.4.beta
ImageFactoryFromImage.h
1 
17 #pragma once
18 
31 #if defined(ImageFactoryFromImage_RECURSES)
32 #error Recursive header files inclusion detected in ImageFactoryFromImage.h
33 #else // defined(ImageFactoryFromImage_RECURSES)
34 
35 #define ImageFactoryFromImage_RECURSES
36 
37 #if !defined ImageFactoryFromImage_h
38 
39 #define ImageFactoryFromImage_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/ConceptUtils.h"
46 #include "DGtal/images/CImage.h"
47 #include "DGtal/base/Alias.h"
49 
50 namespace DGtal
51 {
53  // Template class ImageFactoryFromImage
65  template <typename TImageContainer>
67  {
68 
69  // ----------------------- Types ------------------------------
70 
71  public:
73 
76 
79  typedef typename ImageContainer::Domain Domain;
80 
83 
84  // ----------------------- Standard services ------------------------------
85 
86  public:
87 
93  myImagePtr(&anImage)
94  {
95  }
96 
102 
103  private:
104 
106 
108 
109  // ----------------------- Interface --------------------------------------
110  public:
111 
113 
119  const Domain & domain() const
120  {
121  return myImagePtr->domain();
122  }
123 
125 
126 
128 
133  void selfDisplay ( std::ostream & out ) const;
134 
139  bool isValid() const
140  {
141  return (myImagePtr->isValid());
142  }
143 
151  OutputImage * requestImage(const Domain &aDomain)
152  {
153  OutputImage* outputImage = new OutputImage(aDomain);
154 
155  typename Domain::Iterator it = outputImage->domain().begin();
156  typename Domain::Iterator it_end = outputImage->domain().end();
157  for (; it != it_end; ++it)
158  {
159  outputImage->setValue(*it, (*myImagePtr)(*it));
160  }
161 
162  return outputImage;
163  }
164 
170  void flushImage(OutputImage* outputImage)
171  {
172  typename Domain::Iterator it = outputImage->domain().begin();
173  typename Domain::Iterator it_end = outputImage->domain().end();
174  for (; it != it_end; ++it)
175  {
176  myImagePtr->setValue(*it, (*outputImage)(*it));
177  }
178  }
179 
185  void detachImage(OutputImage* outputImage)
186  {
187  delete outputImage;
188  }
189 
190  // ------------------------- Protected Datas ------------------------------
191  private:
195  //ImageFactoryFromImage() {}
196 
197  // ------------------------- Private Datas --------------------------------
198  protected:
199 
202 
203  // ------------------------- Internals ------------------------------------
204  private:
205 
206  }; // end of class ImageFactoryFromImage
207 
208 
215  template <typename TImageContainer>
216  std::ostream&
217  operator<< ( std::ostream & out, const ImageFactoryFromImage<TImageContainer> & object );
218 
219 } // namespace DGtal
220 
221 
223 // Includes inline functions.
224 #include "DGtal/images/ImageFactoryFromImage.ih"
225 
226 // //
228 
229 #endif // !defined ImageFactoryFromImage_h
230 
231 #undef ImageFactoryFromImage_RECURSES
232 #endif // else defined(ImageFactoryFromImage_RECURSES)
DGtal::ImageFactoryFromImage::domain
const Domain & domain() const
Definition: ImageFactoryFromImage.h:119
DGtal::ImageFactoryFromImage::Self
ImageFactoryFromImage< TImageContainer > Self
Definition: ImageFactoryFromImage.h:72
DGtal::ImageFactoryFromImage::flushImage
void flushImage(OutputImage *outputImage)
Definition: ImageFactoryFromImage.h:170
DGtal::ImageContainerBySTLVector::Domain
TDomain Domain
Definition: ImageContainerBySTLVector.h:137
DGtal::ImageContainerBySTLVector
Definition: ImageContainerBySTLVector.h:126
DGtal::ImageFactoryFromImage
Aim: implements a factory to produce images from a "bigger/original" one according to a given domain.
Definition: ImageFactoryFromImage.h:66
DGtal::ImageFactoryFromImage::isValid
bool isValid() const
Definition: ImageFactoryFromImage.h:139
DGtal::ImageFactoryFromImage::~ImageFactoryFromImage
~ImageFactoryFromImage()
Definition: ImageFactoryFromImage.h:101
DGtal::ImageContainerBySTLVector::domain
const Domain & domain() const
DGtal::ImageContainerBySTLVector::setValue
void setValue(const Point &aPoint, const Value &aValue)
DGtal::ImageFactoryFromImage::operator=
ImageFactoryFromImage & operator=(const ImageFactoryFromImage &other)
DGtal::ImageFactoryFromImage::OutputImage
ImageContainer OutputImage
New types.
Definition: ImageFactoryFromImage.h:82
DGtal::operator<<
std::ostream & operator<<(std::ostream &out, const ATu0v1< TKSpace, TLinearAlgebra > &object)
DGtal::ImageFactoryFromImage::selfDisplay
void selfDisplay(std::ostream &out) const
DGtal::ImageFactoryFromImage::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::ImageFactoryFromImage::myImagePtr
ImageContainer * myImagePtr
Alias on the image container.
Definition: ImageFactoryFromImage.h:201
DGtal::ImageFactoryFromImage::requestImage
OutputImage * requestImage(const Domain &aDomain)
Definition: ImageFactoryFromImage.h:151
DGtal::ImageContainerBySTLVector::isValid
bool isValid() const
DGtal::ImageFactoryFromImage::detachImage
void detachImage(OutputImage *outputImage)
Definition: ImageFactoryFromImage.h:185
DGtal::HyperRectDomain_Iterator
Iterator for HyperRectDomain.
Definition: HyperRectDomain_Iterator.h:142
DGtal::ImageFactoryFromImage::ImageFactoryFromImage
ImageFactoryFromImage(Alias< ImageContainer > anImage)
Definition: ImageFactoryFromImage.h:92
DGtal::Alias
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:182
DGtal::ImageFactoryFromImage::Domain
ImageContainer::Domain Domain
Definition: ImageFactoryFromImage.h:79
TImageContainer
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer
Definition: testVoronoiMapComplete.cpp:49
DGtal::ImageFactoryFromImage::ImageContainer
TImageContainer ImageContainer
Types copied from the container.
Definition: ImageFactoryFromImage.h:78
DGtal::concepts::CImage
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:102