IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
KMeansPPClusterInitLvl1.h
1 // KMeansPPClusterInitLvl1.h:
3 // -------------------------------
4 //
14 
15 #ifndef __IPSDKIPLCLASSIFICATION_KMEANSPPCLUSTERINITLVL1_H__
16 #define __IPSDKIPLCLASSIFICATION_KMEANSPPCLUSTERINITLVL1_H__
17 
22 
23 // Attributes headers
24 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/OutClustersCenters.h>
25 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Input/InHomogeneousImg.h>
26 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Value/InNbClusters.h>
27 #include <IPSDKIPL/IPSDKIPLAttributes/DataItem/Doubles.h>
28 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Enumerate/InRandomAlgoType.h>
29 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/InOut/InOutOptWk1RealImg.h>
30 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/Working/Optional/OutOptWk1RealImg.h>
31 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/OutMaxValIdx.h>
32 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/OutKMeansPPClusterInitInfo.h>
33 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Input/Optional/InOptSingleGreyMaskImg.h>
34 
35 namespace ipsdk {
36 namespace imaproc {
37 namespace classif {
38 
41 
42 // declare processor class
43 IPSDK_DECLARE_LVL1_PROCESSOR(REP_ASYNC1, IPSDKIPLClassification, KMeansPPClusterInit,
44  ipsdk::processor::ifIsSet(_pInOutOptWk1RealImg,
45  ipsdk::imaproc::matchSize(eMatchImageSizeType::eMIST_3d, _pInHomogeneousImg, _pInOutOptWk1RealImg) &&
46  ipsdk::processor::ifIsSet(_pOutOptWk1RealImg,
47  ipsdk::imaproc::matchSize(eMatchImageSizeType::eMIST_3d, _pInHomogeneousImg, _pOutOptWk1RealImg) &&
48  ipsdk::imaproc::matchSizeAndType(_pInOutOptWk1RealImg, _pOutOptWk1RealImg))) &&
49  ipsdk::processor::ifIsSet(_pInOptSingleGreyMaskImg,
50  ipsdk::imaproc::matchSize(eMatchImageSizeType::eMIST_3d, _pInHomogeneousImg, _pInOptSingleGreyMaskImg)),
51  (((ipsdk)(imaproc)(attr))(InHomogeneousImg))
52  (((ipsdk)(imaproc)(attr))(InOptSingleGreyMaskImg))
53  (((ipsdk)(imaproc)(attr))(InNbClusters))
54  (((ipsdk)(imaproc)(attr))(InRandomAlgoType))
55  (((ipsdk)(imaproc)(attr))(InOutOptWk1RealImg))
56  (((ipsdk)(imaproc)(attr))(OutOptWk1RealImg))
57  (((ipsdk)(imaproc)(attr))(OutClustersCenters)(ipsdk::processor::allocate)))
58 
59 // methods
60 public:
61 
62 protected:
63 
65  template <typename T>
66  void addClusterCenter(const ipUInt64 centerIdx, const ipUInt64 zIdx);
67 
69  void findRandomClusterCenter(ipUInt64& maxIdx, ipUInt64& zIdx);
70 
72  void mergeLvl2Results(ipUInt64& maxIdx, ipUInt64& zIdx);
73 
75  void clearIntermediateData();
76 
77 // attributes
78 protected:
79  // declaration of dispatch results collection
80  IPSDK_DECLARE_STATIC_RESULT_COLL(attr::OutMaxValIdx, OutMaxValIdxColl);
81  IPSDK_DECLARE_STATIC_RESULT_COLL(attr::OutKMeansPPClusterInitInfo, OutKMeansPPClusterInitInfoColl);
82 
83  image::ImageConstPtr _pReinterpretedInImg;
84  image::ImagePtr _pDistImg;
85  image::ImagePtr _pCumulDistImg;
86  attr::DoublesPtr _pFlattenedClustersCenters;
87  attr::DoublesPtr _pCumDistColl;
88 
89  // Storage of _pInOptSingleGreyMaskImg
90  image::ImageConstPtr _pMaskImg;
91 
92 };
93 
96 
97 } // end of namespace classif
98 } // end of namespace imaproc
99 } // end of namespace ipsdk
100 
101 #endif // __IPSDKIPLCLASSIFICATION_KMEANSPPCLUSTERINITLVL1_H__
#define IPSDK_DECLARE_LVL1_PROCESSOR(ProcType, libraryName, algoName, RuleString, attributeSeq)
uint64_t ipUInt64
boost::shared_ptr< BaseImage > ImagePtr
boost::shared_ptr< ipsdk::imaproc::attr::Doubles > DoublesPtr
shared pointer to ipsdk::imaproc::Doubles
Definition: Doubles.h:124
boost::enable_if_c< AttributeType::g_bOptional, RulePtr >::type ifIsSet(const boost::shared_ptr< AttributeType > &pAttribute, const RulePtr &pRuleTrue)
Definition of import/export macro for library.
boost::shared_ptr< const BaseImage > ImageConstPtr
#define IPSDK_DECLARE_STATIC_RESULT_COLL(AttributeType, CollType)
processor::OutputInitializerPtr allocate(const boost::weak_ptr< OutputAttributeType > &pOutputAttribute)
IPSDK_DECLARE_GPU_PROCESSING_ALGORITHM(IPSDKIPLFiltering, Convolution2dImg, ipsdk::imaproc::matchSize(_pInSubGpuImg, _pOutImg),(((ipsdk)(imaproc)(attr))(InSubGpuImg))(((ipsdk)(imaproc)(attr))(InKnlXY))(((ipsdk)(imaproc)(attr))(InNormalize))(((ipsdk)(imaproc)(attr))(InConvolBorder2d))(((ipsdk)(imaproc)(attr))(OutImg))) IPSDKCUDA_DECLARE_ALGORITHM_FUNCTION_SELECTOR((InSubGpuImg)(OutImg)) public void clearIntermediateData()
method called before processing