IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
PatchBasedBilateral2dImgLvl3.h
1 // PatchBasedBilateral2dImgLvl3.h:
3 // -------------------------
4 //
14 
15 #ifndef __IPSDKIPLFILTERING_PATCHBASEDBILATERAL2DIMGLVL3_H__
16 #define __IPSDKIPLFILTERING_PATCHBASEDBILATERAL2DIMGLVL3_H__
17 
20 
21 // Attributes headers
22 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Strip/YStrip2d/OutYStrip2d.h>
23 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Strip/YStrip2dWithKernel/InKnlYStrip2d.h>
24 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/InPatchBasedBilateralParams.h>
25 
26 namespace ipsdk {
27 namespace imaproc {
28 namespace filter {
29 
32 
33 // declare processing algorithm
34 IPSDK_DECLARE_PROCESSING_ALGORITHM(IPSDKIPLFiltering, PatchBasedBilateral2dImg,
35  ipsdk::imaproc::matchSize(_pInKnlYStrip2d, _pOutYStrip2d),
36  (((ipsdk)(imaproc)(attr))(InKnlYStrip2d))
37  (((ipsdk)(imaproc)(attr))(InPatchBasedBilateralParams))
38  (((ipsdk)(imaproc)(attr))(OutYStrip2d)))
39 
40  // implementation of image processing data identifier retrieval method
41  // for function selector usage
42  IPSDK_DECLARE_ALGORITHM_FUNCTION_SELECTOR(((STRIP)(InKnlYStrip2d))
43  ((STRIP)(OutYStrip2d)));
44 
45  // declaration of parsed data during processing
46  IPSDK_DECLARE_ALGORITHM_PARSED_DATA(((LINESTRIP)(InKnlYStrip2d))
47  ((LINESTRIP)(OutYStrip2d)));
48 
49 // methods
50 public:
51 
52 protected:
56 
57  template <typename BufInType, typename BufOutType,
58  ipsdk::eInstructionSet::domain ISFma, ipsdk::eInstructionSet::domain IS>
59  ipsdk::BoolResult genericProcessFunction(const ipsdk::processor::ProcessingInfo& info);
60 
61  template <typename BufInType, typename BufOutType,
62  typename ComputationType,
63  eDataType::domain eComputationType,
64  ipsdk::eInstructionSet::domain ISFma, ipsdk::eInstructionSet::domain IS>
65  ipsdk::BoolResult computationTGenericProcessFunction(const ipsdk::processor::ProcessingInfo& info);
66 
68 
69  template <typename ComputationType,
70  eDataType::domain eComputationType>
71  void
72  retrieveIntermediaryBuffers(
74  const ipInt32 kernelRadius,
75  const ipInt32 patchSz,
76  HybridBufferPtr& pCurSquareDiffs,
77  FragHybridBufferPtr*& pCurAvgXSquareDiffs,
78  HybridBufferPtr*& pCurSimilarities,
79  FragHybridBufferPtr*& pCurWeights,
80  HybridBufferPtr& pCurWeightSums,
81  HybridBufferPtr& pCurWeightMaxima,
82  HybridBufferPtr& pCurWeightedIntensitiesSums);
83 
84  template <typename BufInType, typename ComputationType, ipsdk::eInstructionSet::domain IS>
85  void computeSimilaritiesFromPrevRow(
86  const ipUInt32 nbElts,
87  const ipUInt32 patchSz,
88  const BufInType* pCurInBuf,
89  const BufInType* pOtherInBuf,
90  ComputationType* pCurSquareDiffsBuf,
91  FragHybridBufferPtr pCurAvgXSquareDiffs,
92  ComputationType* pCurSimilarities);
93 
94  template <typename ComputationType, ipsdk::eInstructionSet::domain ISFma, ipsdk::eInstructionSet::domain IS>
95  void
96  computeSimilarityWeightsForCurKnlElt(
97  const ipUInt64 otherIx,
98  const ipUInt64 nbElts,
99  const ipReal64 sigma2,
100  const ipReal64 twicePatchSimilaritySigmaSq,
101  const ComputationType* pSimilaritiesBuf,
102  ComputationType* pWeightsBuf);
103 
104  template <eInstructionSet::domain ISFma, eInstructionSet::domain IS, typename BufInType, typename ComputationType>
105  void
106  computeSimilarityWeights(
107  HybridBufferPtr* pCurSimilarities,
108  ComputationType* pCurSquareDiffsBuf,
109  FragHybridBufferPtr* pCurAvgXSquareDiffs,
110  FragHybridBufferPtr* pCurSimilarityWeights,
112 
113 // attributes
114 protected:
117  HybridBufferPtr _pInitialSquareDiffs;
118  HybridBufferPtr _pMainSquareDiffs;
119  HybridBufferPtr _pFinalSquareDiffs;
120 
121  boost::scoped_array<FragHybridBufferPtr> _pInitialAvgXSquareDiffs;
122  boost::scoped_array<FragHybridBufferPtr> _pMainAvgXSquareDiffs;
123  boost::scoped_array<FragHybridBufferPtr> _pFinalAvgXSquareDiffs;
124 
125  boost::scoped_array<HybridBufferPtr> _pInitialSimilarities;
126  boost::scoped_array<HybridBufferPtr> _pMainSimilarities;
127  boost::scoped_array<HybridBufferPtr> _pFinalSimilarities;
128 
129  boost::scoped_array<FragHybridBufferPtr> _pInitialSimilarityWeights;
130  boost::scoped_array<FragHybridBufferPtr> _pMainSimilarityWeights;
131  boost::scoped_array<FragHybridBufferPtr> _pFinalSimilarityWeights;
132 
133  std::vector<std::pair<ipInt32, ipInt32> > _ptsInKernel;
134  ipUInt64 _nbPointsInKernel;
135  ipUInt64 _nbHalfPointsInKernel;
136 
137  HybridBufferPtr _pInitialWeightSums;
138  HybridBufferPtr _pInitialWeightMaxima;
139  HybridBufferPtr _pInitialWeightedIntensitiesSums;
140 
141  HybridBufferPtr _pMainWeightSums;
142  HybridBufferPtr _pMainWeightMaxima;
143  HybridBufferPtr _pMainWeightedIntensitiesSums;
144 
145  HybridBufferPtr _pFinalWeightSums;
146  HybridBufferPtr _pFinalWeightMaxima;
147  HybridBufferPtr _pFinalWeightedIntensitiesSums;
149 };
150 
154 } // end of namespace filter
155 } // end of namespace imaproc
156 } // end of namespace ipsdk
157 
158 #endif // __IPSDKIPLFILTERING_PATCHBASEDBILATERAL2DIMGLVL3_H__
boost::shared_ptr< FragHybridBuffer > FragHybridBufferPtr
uint64_t ipUInt64
double ipReal64
ipsdk::core::ExecResult preProcess()
method called before processing
int32_t ipInt32
#define IPSDK_DECLARE_PROCESSING_ALGORITHM(libraryName, algoName, RuleString, attributeSeq)
#define IPSDK_DECLARE_ALGORITHM_PARSED_DATA(dataSeq)
#define IPSDK_DECLARE_ALGORITHM_FUNCTION_SELECTOR(dataTypeSeq)
boost::shared_ptr< HybridBuffer > HybridBufferPtr
Definition of import/export macro for library.
uint32_t ipUInt32