DGtal 1.3.0
Loading...
Searching...
No Matches
ImageHelper.h
1
17#pragma once
18
31#if defined(ImageHelper_RECURSES)
32#error Recursive header files inclusion detected in ImageHelper.h
33#else // defined(ImageHelper_RECURSES)
35#define ImageHelper_RECURSES
36
37#if !defined ImageHelper_h
39#define ImageHelper_h
40
42// Inclusions
43#include <iostream>
44#include <algorithm>
45#include <functional>
46
47#include "DGtal/base/Common.h"
48#include "DGtal/base/BasicFunctors.h"
49#include "DGtal/base/CConstSinglePassRange.h"
50#include "DGtal/kernel/BasicPointPredicates.h"
51#include "DGtal/kernel/CPointFunctor.h"
52#include "DGtal/kernel/CPointPredicate.h"
53#include "DGtal/kernel/domains/CDomain.h"
54#include "DGtal/images/CConstImage.h"
55#include "DGtal/images/ConstImageAdapter.h"
56#include "DGtal/images/CImage.h"
57#include "DGtal/base/CQuantity.h"
58#include "DGtal/images/ImageContainerBySTLMap.h"
59#include "DGtal/images/SetValueIterator.h"
60#include "DGtal/kernel/sets/DigitalSetFromMap.h"
61#include "DGtal/kernel/sets/CDigitalSet.h"
62#include "DGtal/kernel/NumberTraits.h"
63#include "DGtal/base/ConstAlias.h"
64
66
67namespace DGtal
68{
69
71
85 template<typename I, typename O, typename P>
86 void setFromPointsRangeAndPredicate(const I& itb, const I& ite, const O& ito, const P& aPred);
87
105 template<typename I, typename O, typename F>
106 void setFromPointsRangeAndFunctor(const I& itb, const I& ite,
107 const O& ito, const F& aFunctor,
108 const typename F::Value& aThreshold = 0);
109
124 template<typename I, typename O>
125 void setFromImage(const I& aImg,
126 const O& ito,
127 const typename I::Value& aThreshold = 0);
128
144 template<typename I, typename O>
145 void setFromImage(const I& aImg,
146 const O& ito,
147 const typename I::Value& low,
148 const typename I::Value& up);
149
150
163 template<typename It, typename Im>
164 void imageFromRangeAndValue(const It& itb, const It& ite, Im& aImg,
165 const typename Im::Value& aValue = 0);
166
178 template<typename R, typename I>
179 void imageFromRangeAndValue(const R& aRange, I& aImg,
180 const typename I::Value& aValue = 0);
181
192 template<typename I, typename F>
193 void imageFromFunctor(I& aImg, const F& aFun);
194
204 template<typename I1, typename I2>
205 void imageFromImage(I1& aImg1, const I2& aImg2);
206
249 template<typename I, typename S>
250 bool insertAndSetValue(I& aImg, S& aSet,
251 const typename I::Point& aPoint,
252 const typename I::Value& aValue );
253
297 template<typename I, typename S>
298 bool insertAndAlwaysSetValue(I& aImg, S& aSet,
299 const typename I::Point& aPoint,
300 const typename I::Value& aValue );
301
330 template<typename I, typename S>
331 bool findAndGetValue(const I& aImg, const S& aSet,
332 const typename I::Point& aPoint,
333 typename I::Value& aValue );
334
335
336
337
346 template<typename Image, typename PointPredicate, typename TValue=DGtal::int32_t>
348 {
349 public:
350
351 typedef typename Image::Point Point;
352 typedef TValue Value;
353
357
358 /*BOOST_CONCEPT_USAGE(ImageToConstantFunctor)
359 {
360 Point p1;
361 typename PointPredicate::Point p2;
362 ConceptUtils::sameType( p1, p2 );
363 }*/
364
376 bool reverseValues = false )
377 : myImage(&anImage),
378 myPointPred(&aPointPred),
379 myVal(aVal),
380 reverse(reverseValues)
381 {}
382
389 Value operator()( const Point &aPoint ) const
390 {
391 if ((myImage->domain().isInside(aPoint)))
392 {
393 if( reverse )
394 {
395 if( !myPointPred->operator()(aPoint) )
396 {
397 return myVal;
398 }
399 else
400 {
402 }
403 }
404 else
405 {
406 if( myPointPred->operator()(aPoint) )
407 {
408 return myVal;
409 }
410 else
411 {
413 }
414 }
415 }
416 else
417 {
419 }
420 }
421
422 private:
423
426
428 const PointPredicate *myPointPred;
429
432
435 };
436
437
438
439
440
441} // namespace DGtal
442
444// Includes inline functions
445#include "DGtal/images/ImageHelper.ih"
446// //
448
449#endif // !defined ImageHelper_h
450
451#undef ImageHelper_RECURSES
452#endif // else defined(ImageHelper_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Value operator()(const Point &aPoint) const
Definition: ImageHelper.h:389
BOOST_CONCEPT_ASSERT((concepts::CConstImage< Image >))
Value myVal
constant value when functor answer true.
Definition: ImageHelper.h:431
bool reverse
reverse values returned by the predicate. (Some shapes consider inner as > 0, others as < 0)
Definition: ImageHelper.h:434
const Image * myImage
const pointor to an image
Definition: ImageHelper.h:425
const PointPredicate * myPointPred
const pointor to a predicate on points
Definition: ImageHelper.h:428
BOOST_CONCEPT_ASSERT((concepts::CPointPredicate< PointPredicate >))
ImageToConstantFunctor(ConstAlias< Image > anImage, ConstAlias< PointPredicate > aPointPred, Value aVal=NumberTraits< Value >::ONE, bool reverseValues=false)
Definition: ImageHelper.h:373
BOOST_CONCEPT_ASSERT((concepts::CQuantity< Value >))
Aim: implements association bewteen points lying in a digital domain and values.
Definition: Image.h:70
const Domain & domain() const
Definition: Image.h:192
DGtal is the top-level namespace which contains all DGtal functions and types.
void setFromImage(const I &aImg, const O &ito, const typename I::Value &aThreshold=0)
bool findAndGetValue(const I &aImg, const S &aSet, const typename I::Point &aPoint, typename I::Value &aValue)
void imageFromFunctor(I &aImg, const F &aFun)
bool insertAndSetValue(I &aImg, S &aSet, const typename I::Point &aPoint, const typename I::Value &aValue)
void imageFromImage(I1 &aImg1, const I2 &aImg2)
void imageFromRangeAndValue(const It &itb, const It &ite, Im &aImg, const typename Im::Value &aValue=0)
bool insertAndAlwaysSetValue(I &aImg, S &aSet, const typename I::Point &aPoint, const typename I::Value &aValue)
void setFromPointsRangeAndFunctor(const I &itb, const I &ite, const O &ito, const F &aFunctor, const typename F::Value &aThreshold=0)
void setFromPointsRangeAndPredicate(const I &itb, const I &ite, const O &ito, const P &aPred)
useful functions
Aim: The traits class for all models of Cinteger.
Definition: NumberTraits.h:564
Aim: Defines the concept describing a read-only image, which is a refinement of CPointFunctor.
Definition: CConstImage.h:95
Aim: Defines a predicate on a point.
Aim: defines the concept of quantity in DGtal.
Definition: CQuantity.h:93
const Point aPoint(3, 4)