DGtal 1.3.0
Loading...
Searching...
No Matches
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)
35#define ImageFactoryFromImage_RECURSES
36
37#if !defined ImageFactoryFromImage_h
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
50namespace DGtal
51{
53 // Template class ImageFactoryFromImage
65 template <typename TImageContainer>
67 {
68
69 // ----------------------- Types ------------------------------
70
71 public:
73
76
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
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)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: Alias.h:183
Iterator for HyperRectDomain.
void setValue(const Point &aPoint, const Value &aValue)
const Domain & domain() const
Aim: implements a factory to produce images from a "bigger/original" one according to a given domain.
TImageContainer ImageContainer
Types copied from the container.
ImageFactoryFromImage(const ImageFactoryFromImage &other)
ImageFactoryFromImage & operator=(const ImageFactoryFromImage &other)
void selfDisplay(std::ostream &out) const
void detachImage(OutputImage *outputImage)
ImageContainer * myImagePtr
Alias on the image container.
ImageFactoryFromImage(Alias< ImageContainer > anImage)
ImageContainer OutputImage
New types.
BOOST_CONCEPT_ASSERT((concepts::CImage< TImageContainer >))
Checking concepts.
OutputImage * requestImage(const Domain &aDomain)
ImageFactoryFromImage< TImageContainer > Self
void flushImage(OutputImage *outputImage)
DGtal is the top-level namespace which contains all DGtal functions and types.
std::ostream & operator<<(std::ostream &out, const ClosedIntegerHalfPlane< TSpace > &object)
Aim: Defines the concept describing a read/write image, having an output iterator.
Definition: CImage.h:103
ImageContainerBySTLVector< HyperRectDomain< Z2i::Space >, std::unordered_set< Z2i::Point > > TImageContainer