33 template<
typename SrcVolumeType,
typename DstVolumeType,
typename AccumulationType>
39 ,m_uKernelSize(uKernelSize)
42 assert(m_uKernelSize >= 3);
43 m_uKernelSize = std::max(m_uKernelSize, static_cast<uint32_t>(3));
46 assert(m_uKernelSize % 2 == 1);
47 if(m_uKernelSize % 2 == 0)
53 template<
typename SrcVolumeType,
typename DstVolumeType,
typename AccumulationType>
56 int32_t iSrcMinX = m_regSrc.getLowerCorner().getX();
57 int32_t iSrcMinY = m_regSrc.getLowerCorner().getY();
58 int32_t iSrcMinZ = m_regSrc.getLowerCorner().getZ();
60 int32_t iSrcMaxX = m_regSrc.getUpperCorner().getX();
61 int32_t iSrcMaxY = m_regSrc.getUpperCorner().getY();
62 int32_t iSrcMaxZ = m_regSrc.getUpperCorner().getZ();
64 int32_t iDstMinX = m_regDst.getLowerCorner().getX();
65 int32_t iDstMinY = m_regDst.getLowerCorner().getY();
66 int32_t iDstMinZ = m_regDst.getLowerCorner().getZ();
72 typename SrcVolumeType::Sampler srcSampler(m_pVolSrc);
74 for(
int32_t iSrcZ = iSrcMinZ, iDstZ = iDstMinZ; iSrcZ <= iSrcMaxZ; iSrcZ++, iDstZ++)
76 for(
int32_t iSrcY = iSrcMinY, iDstY = iDstMinY; iSrcY <= iSrcMaxY; iSrcY++, iDstY++)
78 for(
int32_t iSrcX = iSrcMinX, iDstX = iDstMinX; iSrcX <= iSrcMaxX; iSrcX++, iDstX++)
80 AccumulationType tSrcVoxel(0);
81 srcSampler.setPosition(iSrcX, iSrcY, iSrcZ);
83 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1ny1nz());
84 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1ny0pz());
85 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1ny1pz());
86 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx0py1nz());
87 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx0py0pz());
88 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx0py1pz());
89 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1py1nz());
90 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1py0pz());
91 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1nx1py1pz());
93 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1ny1nz());
94 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1ny0pz());
95 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1ny1pz());
96 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px0py1nz());
97 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px0py0pz());
98 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px0py1pz());
99 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1py1nz());
100 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1py0pz());
101 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel0px1py1pz());
103 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1ny1nz());
104 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1ny0pz());
105 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1ny1pz());
106 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px0py1nz());
107 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px0py0pz());
108 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px0py1pz());
109 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1py1nz());
110 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1py0pz());
111 tSrcVoxel +=
static_cast<AccumulationType
>(srcSampler.peekVoxel1px1py1pz());
116 m_pVolDst->setVoxelAt(iSrcX, iSrcY, iSrcZ, static_cast<typename DstVolumeType::VoxelType>(tSrcVoxel));
122 template<
typename SrcVolumeType,
typename DstVolumeType,
typename AccumulationType>
125 const uint32_t border = (m_uKernelSize - 1) / 2;
137 for(
int32_t z = satLowerCorner.
getZ(); z <= satUpperCorner.
getZ(); z++)
139 for(
int32_t y = satLowerCorner.
getY(); y <= satUpperCorner.
getY(); y++)
141 for(
int32_t x = satLowerCorner.
getX(); x <= satUpperCorner.
getX(); x++)
152 satIterCont.
m_Iter = &satVolumeIter;
155 typename SrcVolumeType::Sampler srcVolumeIter(m_pVolSrc);
159 srcIterCont.
m_Iter = &srcVolumeIter;
164 AccumulationType previousSum =
static_cast<AccumulationType
>(satVolumeIter.
peekVoxel1nx0py0pz());
165 AccumulationType currentVal =
static_cast<AccumulationType
>(srcVolumeIter.getVoxel());
167 satVolumeIter.
setVoxel(previousSum + currentVal);
188 for(
int32_t z = satLowerCorner.
getZ(); z <= satUpperCorner.
getZ(); z++)
190 for(
int32_t y = satLowerCorner.
getY(); y <= satUpperCorner.
getY(); y++)
192 for(
int32_t x = satLowerCorner.
getX(); x <= satUpperCorner.
getX(); x++)
194 AccumulationType previousSum =
static_cast<AccumulationType
>(satVolume.
getVoxelAt(x,y-1,z));
195 AccumulationType currentSum =
static_cast<AccumulationType
>(satVolume.
getVoxelAt(x,y,z));
197 satVolume.
setVoxelAt(x,y,z,previousSum + currentSum);
202 for(
int32_t z = satLowerCorner.
getZ(); z <= satUpperCorner.
getZ(); z++)
204 for(
int32_t y = satLowerCorner.
getY(); y <= satUpperCorner.
getY(); y++)
206 for(
int32_t x = satLowerCorner.
getX(); x <= satUpperCorner.
getX(); x++)
208 AccumulationType previousSum =
static_cast<AccumulationType
>(satVolume.
getVoxelAt(x,y,z-1));
209 AccumulationType currentSum =
static_cast<AccumulationType
>(satVolume.
getVoxelAt(x,y,z));
211 satVolume.
setVoxelAt(x,y,z,previousSum + currentSum);
217 const Vector3DInt32& v3dDstLowerCorner = m_regDst.getLowerCorner();
218 const Vector3DInt32& v3dDstUpperCorner = m_regDst.getUpperCorner();
220 const Vector3DInt32& v3dSrcLowerCorner = m_regSrc.getLowerCorner();
222 for(
int32_t iDstZ = v3dDstLowerCorner.
getZ(), iSrcZ = v3dSrcLowerCorner.
getZ(); iDstZ <= v3dDstUpperCorner.
getZ(); iDstZ++, iSrcZ++)
224 for(
int32_t iDstY = v3dDstLowerCorner.
getY(), iSrcY = v3dSrcLowerCorner.
getY(); iDstY <= v3dDstUpperCorner.
getY(); iDstY++, iSrcY++)
226 for(
int32_t iDstX = v3dDstLowerCorner.
getX(), iSrcX = v3dSrcLowerCorner.
getX(); iDstX <= v3dDstUpperCorner.
getX(); iDstX++, iSrcX++)
228 int32_t satLowerX = iSrcX - border - 1;
229 int32_t satLowerY = iSrcY - border - 1;
230 int32_t satLowerZ = iSrcZ - border - 1;
232 int32_t satUpperX = iSrcX + border;
233 int32_t satUpperY = iSrcY + border;
234 int32_t satUpperZ = iSrcZ + border;
236 AccumulationType a = satVolume.
getVoxelAt(satLowerX,satLowerY,satLowerZ);
237 AccumulationType b = satVolume.
getVoxelAt(satUpperX,satLowerY,satLowerZ);
238 AccumulationType c = satVolume.
getVoxelAt(satLowerX,satUpperY,satLowerZ);
239 AccumulationType d = satVolume.
getVoxelAt(satUpperX,satUpperY,satLowerZ);
240 AccumulationType e = satVolume.
getVoxelAt(satLowerX,satLowerY,satUpperZ);
241 AccumulationType f = satVolume.
getVoxelAt(satUpperX,satLowerY,satUpperZ);
242 AccumulationType g = satVolume.
getVoxelAt(satLowerX,satUpperY,satUpperZ);
243 AccumulationType h = satVolume.
getVoxelAt(satUpperX,satUpperY,satUpperZ);
245 AccumulationType sum = h+c-d-g-f-a+b+e;
246 uint32_t sideLength = border * 2 + 1;
247 AccumulationType average = sum / (sideLength*sideLength*sideLength);
249 m_pVolDst->setVoxelAt(iDstX, iDstY, iDstZ, static_cast<typename DstVolumeType::VoxelType>(average));