8 #include "vImageConvolver.hh" 9 #include "oImageDimensionsAndQuantification.hh" 10 #include "oImageSpace.hh" 11 #include "iImageConvolverStationaryIsotropicGaussian.hh" 40 cout <<
"This convolver is based on a classic stationary isotropic Gaussian kernel." << endl;
41 cout <<
"To speed up computation time, three consecutive 1D convolutions are performed." << endl;
42 cout <<
"The following options are used (in this particular order when provided as a list, separated by commas):" << endl;
43 cout <<
" FWHM: to set the isotropic FWHM (in mm)" << endl;
44 cout <<
" number of sigmas: to set the number of sigmas included in each dimension of the kernel (recommendations: at least 3. and maximum 5.)" << endl;
59 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::ReadConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
63 key_word =
"number of sigmas";
66 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::ReadConfigurationFile() -> Failed to get the '" << key_word <<
"' keyword !" << endl);
83 if (
ReadStringOption(a_optionsList, options, 2,
",",
"Stationary Isotropic Gaussian convolver configuration"))
85 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::ReadConfigurationFile() -> Failed to correctly read the list of options !" << endl);
105 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::CheckSpecificParameters() -> Number of sigmas included in the kernel must be strictly positive !" << endl);
111 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::CheckSpecificParameters() -> FWHM is negative !" << endl);
128 Cout(
"iImageConvolverStationaryIsotropicGaussian::BuildConvolutionKernel() -> Compute convolution kernel" << endl);
129 Cout(
" --> Isotropic FWHM: " <<
m_FWHM <<
" mm" << endl);
142 FLTNB two_sqrt_two_ln_two = 2.*sqrt(2.*log(2.));
148 INTNB half_kern_dimX = ((
INTNB)(half_kern_floatX));
149 if (half_kern_floatX-((
FLTNB)half_kern_dimX)>0.5) half_kern_dimX++;
150 INTNB half_kern_dimY = ((
INTNB)(half_kern_floatY));
151 if (half_kern_floatY-((
FLTNB)half_kern_dimY)>0.5) half_kern_dimY++;
152 INTNB half_kern_dimZ = ((
INTNB)(half_kern_floatZ));
153 if (half_kern_floatZ-((
FLTNB)half_kern_dimZ)>0.5) half_kern_dimZ++;
183 FLTNB sum_kernel_X = 0.;
190 FLTNB sum_kernel_Y = 0.;
197 FLTNB sum_kernel_Z = 0.;
222 Cerr(
"***** iImageConvolverStationaryIsotropicGaussian::Convolve() -> Called while not initialized !" << endl);
227 INTNB stationary_kernel = 0;
231 #pragma omp parallel for private(z) schedule(guided) 237 FLTNB kernel_integral = 0.;
238 for (
INTNB zk=0; zk<mp_dimKernelZ[stationary_kernel]; zk++)
254 INTNB indexY_pad_base = (y+mp_dimKernelY[stationary_kernel]/2)*
m_dimPadX;
258 INTNB index_img = indexZ_img_base + indexY_img_base + x;
260 INTNB index_pad_base = indexZ_pad_base + indexY_pad_base + x + mp_dimKernelX[stationary_kernel]/2;
262 for (
INTNB zk=0; zk<mp_dimKernelZ[stationary_kernel]; zk++)
275 #pragma omp parallel for private(z) schedule(guided) 289 INTNB index_img = indexZ_img_base + indexY_img_base + x;
291 INTNB index_pad_base = indexZ_pad_base + indexY_pad_base + x +
m_offsetX;
293 for (
INTNB yk=0; yk<mp_dimKernelY[stationary_kernel]; yk++)
306 #pragma omp parallel for private(z) schedule(guided) 311 INTNB indexZ_pad_base = (z+mp_dimKernelZ[stationary_kernel]/2)*m_dimPadXY;
316 INTNB indexY_pad_base = (y+mp_dimKernelY[stationary_kernel]/2)*m_dimPadX;
320 INTNB index_img = indexZ_img_base + indexY_img_base + x;
322 INTNB index_pad_base = indexZ_pad_base + indexY_pad_base + x;
324 for (
INTNB xk=0; xk<mp_dimKernelX[stationary_kernel]; xk++)
327 INTNB index_pad = index_pad_base + xk;
int ReadOptionsList(const string &a_listOptions)
int ReadStringOption(const string &a_input, T *ap_return, int a_nbElts, const string &sep, const string &a_option)
Parse the 'a_input' string corresponding to the 'a_option' into 'a_nbElts' elements, using the 'sep' separator. The results are returned in the templated 'ap_return' dynamic templated array. Call "ConvertFromString()" to perform the correct conversion depending on the type of the data to convert.
FLTNB GetVoxSizeX()
Get the voxel's size along the X axis, in mm.
FLTNB GetVoxSizeZ()
Get the voxel's size along the Z axis, in mm.
int BuildConvolutionKernel()
A private function used to build the convolution kernel specific to the child convolver.
oImageDimensionsAndQuantification * mp_ImageDimensionsAndQuantification
~iImageConvolverStationaryIsotropicGaussian()
The destructor of iImageConvolverStationaryIsotropicGaussian.
FLTNB GetVoxSizeY()
Get the voxel's size along the Y axis, in mm.
int ReadConfigurationFile(const string &a_fileOptions)
int Convolve(FLTNB *ap_outputImage)
iImageConvolverStationaryIsotropicGaussian()
The constructor of iImageConvolverStationaryIsotropicGaussian.
INTNB GetNbVoxXY()
Get the number of voxels in a slice.
#define KEYWORD_MANDATORY
void ShowHelp()
A function used to show help about the child module.
int CheckSpecificParameters()
A private function used to check the parameters settings specific to the child module.
INTNB GetNbVoxX()
Get the number of voxels along the X axis.
INTNB GetNbVoxZ()
Get the number of voxels along the Z axis.
void CopyToPaddedImage(FLTNB *ap_inputImage)
int ReadDataASCIIFile(const string &a_file, const string &a_keyword, T *ap_return, int a_nbElts, bool a_mandatoryFlag)
Look for "a_nbElts" elts in the "a_file" file matching the "a_keyword" string passed as parameter a...
This abstract class is the generic image convolver class used by the oImageConvolverManager.
INTNB GetNbVoxY()
Get the number of voxels along the Y axis.