IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
LawTexture3dImgLvl1.h
1 // LawTexture3dImgLvl1.h:
3 // ----------------------
4 //
14 
15 #ifndef __IPSDKIPLSTATS_LAWTEXTURE3DIMGLVL1_H__
16 #define __IPSDKIPLSTATS_LAWTEXTURE3DIMGLVL1_H__
17 
23 
25 
26 // Attributes headers
27 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/InOptLawTextureKernel3dTypes.h>
28 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/InOptLawTexPreProcParams.h>
29 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/DataItem/InOptLawTexPostProcParams.h>
30 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Input/3d/InSingleImg3d.h>
31 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/OutRealImg.h>
32 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/Working/Optional/OutOptWk1RealImg.h>
33 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/Working/Optional/OutOptWk2RealImg.h>
34 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/Working/Optional/OutOptWk3RealImg.h>
35 #include <IPSDKIPL/IPSDKIPLAttributes/Attribute/Image/Output/Working/OutWk1RealImg.h>
36 
37 #include <map>
38 #include <set>
39 
40 namespace ipsdk {
41 namespace imaproc {
42 namespace stats {
43 
44 struct LawTex3dConvolRes;
45 typedef boost::shared_ptr<LawTex3dConvolRes> LawTex3dConvolResPtr;
46 
49 
50 // declare processor class
51 IPSDK_DECLARE_LVL1_PROCESSOR(REP_ASYNC1, IPSDKIPLStats, LawTexture3dImg,
52  ipsdk::imaproc::matchSize(_pInSingleImg3d, _pOutWk1RealImg) &&
53  (ipsdk::processor::ifIsSet(_pOutOptWk1RealImg,
54  ipsdk::imaproc::matchSize(_pInSingleImg3d, _pOutOptWk1RealImg))) &&
55  (ipsdk::processor::ifIsSet(_pOutOptWk2RealImg,
56  ipsdk::imaproc::matchSize(_pInSingleImg3d, _pOutOptWk2RealImg))),
57  (((ipsdk)(imaproc)(attr))(InSingleImg3d))
58  (((ipsdk)(imaproc)(attr))(InOptLawTextureKernel3dTypes))
59  (((ipsdk)(imaproc)(attr))(InOptLawTexPreProcParams))
60  (((ipsdk)(imaproc)(attr))(InOptLawTexPostProcParams))
61  (((ipsdk)(imaproc)(attr))(OutRealImg)(customOutput)(outputLawTexture3d(_pInSingleImg3d, _pInOptLawTextureKernel3dTypes)))
62  (((ipsdk)(imaproc)(attr))(OutWk1RealImg)(ipsdk::imaproc::duplicateInOut)(_pInSingleImg3d)(ipsdk::image::eImageBufferType::eIBT_Real32))
63  (((ipsdk)(imaproc)(attr))(OutOptWk1RealImg))
64  (((ipsdk)(imaproc)(attr))(OutOptWk2RealImg))
65  (((ipsdk)(imaproc)(attr))(OutOptWk3RealImg)))
66 
67 // methods
68 public:
69 
70 protected:
71  typedef std::string FinalImageId;
72  typedef std::string WorkImageId;
73  typedef std::map<FinalImageId, std::pair<image::ImagePtr, WorkImageId> > MapImages;
74 
75  processor::RetrievalResult meanSmoothing(
76  const image::ImageConstPtr& pInImg,
77  const image::ImagePtr& pOutImg,
78  const ipUInt32 halfKnlSize,
79  const core::BasePriority& priority,
80  core::ActionProviderPtr& pProvider);
81 
82  processor::RetrievalResult gaussianSmoothing(
83  const image::ImageConstPtr& pInImg,
84  const image::ImagePtr& pOutImg,
85  const ipReal32 stdDev,
86  const attr::GaussianCoverage& gaussianCoverage,
87  const core::BasePriority& priority,
88  core::ActionProviderPtr& pProvider);
89 
90  processor::RetrievalResult smoothInputImg(
91  const core::BasePriority& priority,
92  core::ActionProviderPtr& pProvider);
93 
94  processor::RetrievalResult subtractSmoothedToInputImg(
95  const core::BasePriority& priority,
96  core::ActionProviderPtr& pProvider);
97 
99  const image::ImageConstPtr& pInImg,
100  const KernelXYZPtr& pKnl,
101  const image::ImagePtr& pOutImg,
102  const core::BasePriority& priority,
103  core::ActionProviderPtr& pProvider);
104 
105  processor::RetrievalResult convolveXKernel(
106  char kernelId,
107  const core::BasePriority& priority,
108  core::ActionProviderPtr& pProvider);
109 
110  processor::RetrievalResult convolveYKernel(
111  const std::string& kernelId,
112  const core::BasePriority& priority,
113  core::ActionProviderPtr& pProvider);
114 
115  processor::RetrievalResult convolveZKernel(
116  const std::string& kernelId,
117  const core::BasePriority& priority,
118  core::ActionProviderPtr& pProvider);
119 
120  processor::RetrievalResult computeAbsImg(
121  const core::BasePriority& priority,
122  core::ActionProviderPtr& pProvider);
123 
125  const std::string& kernelId,
126  const image::ImagePtr& pLastImgConvol3D,
127  const core::BasePriority& priority,
128  core::ActionProviderPtr& pProvider);
129 
130  processor::RetrievalResult divideImageByScalar(
131  const image::ImagePtr& pImg,
132  const ipUInt32 scalar,
133  const core::BasePriority& priority,
134  core::ActionProviderPtr& pProvider);
135 
136  processor::RetrievalResult computeEnergyMap(
137  const core::BasePriority& priority,
138  core::ActionProviderPtr& pProvider);
139 
140  processor::RetrievalResult provideProcessor(
141  const boost::shared_ptr<core::BaseAction>& pProcessor,
142  const core::BasePriority& priority,
143  core::ActionProviderPtr& pProvider);
144 
145  void build1DKernels();
146  BoolResult buildConvolQueues();
147 
148  BoolResult insertKernelType(const std::string& id, const ipUInt32 frameIx);
149 
150  image::ImagePtr takeGreatestAvailableElementInImagesMapWithKeyGreaterThan(
151  const WorkImageId& id);
152 
153  image::ImagePtr takeElementInImagesMap(
154  const FinalImageId& finalId,
155  const WorkImageId& workId);
156 
157  BoolResult pickImage(const WorkImageId& id, image::ImagePtr& pImg);
158  BoolResult takeInitializedOptWk1Image(const WorkImageId& id, image::ImagePtr& pImg);
159  BoolResult takeInitializedOptWk2Image(const WorkImageId& id, image::ImagePtr& pImg);
160  BoolResult takeInitializedOptWk3Image(const WorkImageId& id, image::ImagePtr& pImg);
161  void releaseImage(const WorkImageId& id);
162  bool doAllConvolsLeftStartWithSameLetter() const;
163  bool doAllConvolsLeftStartWithTwoSameLetters() const;
164 
165 // attributes
166 protected:
167  std::map<char, KernelXYZPtr> _mapKnlX;
168  std::map<char, KernelXYZPtr> _mapKnlY;
169  std::map<char, KernelXYZPtr> _mapKnlZ;
170 
171  MapImages _workImages;
172  std::map<std::string, LawTex3dConvolResPtr> _convolsToCompute;
173 
174  // border policy used for convolutions
175  image::Border3dPolicyPtr _pBorder3dPolicy;
176 
177  WorkImageId _optWk1RealImgId;
178  WorkImageId _optWk2RealImgId;
179  WorkImageId _optWk3RealImgId;
180 };
181 
184 
185 } // end of namespace stats
186 } // end of namespace imaproc
187 } // end of namespace ipsdk
188 
189 #endif // __IPSDKIPLSTATS_LAWTEXTURE3DIMGLVL1_H__
boost::shared_ptr< Border3dPolicy > Border3dPolicyPtr
ProcessingResult< eRetrievalResultType > RetrievalResult
#define IPSDK_DECLARE_LVL1_PROCESSOR(ProcType, libraryName, algoName, RuleString, attributeSeq)
boost::shared_ptr< BaseImage > ImagePtr
boost::shared_ptr< KernelXYZ > KernelXYZPtr
processor::OutputInitializerPtr duplicateInOut(const boost::weak_ptr< OutputAttributeType > &pOutputAttribute, const boost::weak_ptr< InputAttributeType > &pInputAttribute, const eImageInitializerStoragePolicy &storagePolicy=eImageInitializerStoragePolicy::eIISP_Inherit)
boost::enable_if_c< AttributeType::g_bOptional, RulePtr >::type ifIsSet(const boost::shared_ptr< AttributeType > &pAttribute, const RulePtr &pRuleTrue)
IPSDKIPLSTATS_API CustomImageInfoPtr outputLawTexture3d(const ImageAttributeConstPtr &pInputImgAttribute, const boost::shared_ptr< attr::InOptLawTextureKernel3dTypes > &pInKernelTypesAttribute)
function allowing to create a Law&#39;s texture 3d filter output image initializer
processor::OutputInitializerPtr customOutput(const boost::weak_ptr< OutputAttributeType > &pOutputAttribute, const CustomImageInfoPtr &pCustomImageInfo)
Utility functions for Law&#39;s texture filter attribute output initialization management.
Definition of import/export macro for library.
boost::shared_ptr< const BaseImage > ImageConstPtr
boost::shared_ptr< BaseActionProvider > ActionProviderPtr
float ipReal32
uint32_t ipUInt32