Commit 11f27cd1 authored by Marc Modat's avatar Marc Modat

Removed the size_t with openmp when a windows compiler is used

parent a19900e3
......@@ -17,7 +17,7 @@
#include "_reg_tools.h"
#include "reg_aladin.h"
#ifdef _WINDOWS
#ifdef _WIN32
# include <time.h>
#endif
......
......@@ -15,7 +15,7 @@
#include <limits>
#include <string.h>
#ifdef _WINDOWS
#ifdef _WIN32
#include <time.h>
#endif
......
......@@ -20,7 +20,11 @@ double reg_getKLDivergence1(nifti_image *referenceImage,
int *mask)
{
size_t voxelNumber = (size_t)referenceImage->nx*referenceImage->ny*referenceImage->nz;
size_t voxel;
#ifdef _WINDOWS
int voxel;
#else
size_t voxel;
#endif
DTYPE *refPtr=static_cast<DTYPE *>(referenceImage->data);
DTYPE *warPtr=static_cast<DTYPE *>(warpedImage->data);
......@@ -121,8 +125,12 @@ void reg_getKLDivergenceVoxelBasedGradient1(nifti_image *referenceImage,
nifti_image *jacobianDetImg,
int *mask)
{
size_t voxelNumber = (size_t)referenceImage->nx*referenceImage->ny*referenceImage->nz;
size_t voxel;
size_t voxelNumber = (size_t)referenceImage->nx*referenceImage->ny*referenceImage->nz;
#ifdef _WINDOWS
int voxel;
#else
size_t voxel;
#endif
DTYPE *refPtr=static_cast<DTYPE *>(referenceImage->data);
DTYPE *warPtr=static_cast<DTYPE *>(warpedImage->data);
......
......@@ -510,8 +510,12 @@ void reg_f3d<T>::GetSimilarityMeasureGradient()
/* The similarity measure gradient is converted from voxel space to real space */
mat44 *floatingMatrix_xyz=NULL;
int controlPointNumber=this->controlPointGrid->nx*this->controlPointGrid->ny*this->controlPointGrid->nz;
int i;
size_t controlPointNumber=(size_t)this->controlPointGrid->nx*this->controlPointGrid->ny*this->controlPointGrid->nz;
#ifdef _WINDOWS
int i;
#else
size_t i;
#endif
if(this->currentFloating->sform_code>0)
floatingMatrix_xyz = &(this->currentFloating->sto_xyz);
else floatingMatrix_xyz = &(this->currentFloating->qto_xyz);
......@@ -635,38 +639,46 @@ void reg_f3d<T>::SetGradientImageToZero()
template <class T>
T reg_f3d<T>::NormaliseGradient()
{
// First compute the gradient max length for normalisation purpose
T maxGradValue=0;
// First compute the gradient max length for normalisation purpose
// T maxGradValue=0;
size_t voxNumber = this->transformationGradient->nx *
this->transformationGradient->ny *
this->transformationGradient->nz;
T *ptrX = static_cast<T *>(this->transformationGradient->data);
T *ptrY = &ptrX[voxNumber];
T *ptrZ = NULL;
float *length=(float *)calloc(voxNumber,sizeof(float));
if(this->transformationGradient->nz>1){
T *ptrZ = &ptrY[voxNumber];
for(int i=0; i<voxNumber; i++){
ptrZ = &ptrY[voxNumber];
for(size_t i=0; i<voxNumber; i++){
T valX=0,valY=0,valZ=0;
if(this->optimiseX==true)
valX = *ptrX++;
if(this->optimiseY==true)
valY = *ptrY++;
if(this->optimiseZ==true)
valZ = *ptrZ++;
T length = (T)(sqrt(valX*valX + valY*valY + valZ*valZ));
maxGradValue = (length>maxGradValue)?length:maxGradValue;
valZ = *ptrZ++;
length[i] = (float)(sqrt(valX*valX + valY*valY + valZ*valZ));
// T length = (T)(sqrt(valX*valX + valY*valY + valZ*valZ));
// maxGradValue = (length>maxGradValue)?length:maxGradValue;
}
}
else{
for(int i=0; i<voxNumber; i++){
for(size_t i=0; i<voxNumber; i++){
T valX=0,valY=0;
if(this->optimiseX==true)
valX = *ptrX++;
if(this->optimiseY==true)
valY = *ptrY++;
T length = (T)(sqrt(valX*valX + valY*valY));
maxGradValue = (length>maxGradValue)?length:maxGradValue;
}
valY = *ptrY++;
length[i] = (float)(sqrt(valX*valX + valY*valY));
// T length = (T)(sqrt(valX*valX + valY*valY));
// maxGradValue = (length>maxGradValue)?length:maxGradValue;
}
}
reg_heapSort(length,voxNumber);
T maxGradValue = (T)(length[90*voxNumber/100 - 1]);
free(length);
if(strcmp(this->executableName,"NiftyReg F3D")==0){
// The gradient is normalised if we are running F3D
......@@ -675,9 +687,47 @@ T reg_f3d<T>::NormaliseGradient()
printf("[NiftyReg DEBUG] Objective function gradient maximal length: %g\n",maxGradValue);
#endif
ptrX = static_cast<T *>(this->transformationGradient->data);
for(size_t i=0;i<this->transformationGradient->nvox;++i){
*ptrX++ /= maxGradValue;
}
if(this->transformationGradient->nz>1){
ptrX = static_cast<T *>(this->transformationGradient->data);
ptrY = &ptrX[voxNumber];
ptrZ = &ptrY[voxNumber];
for(size_t i=0;i<voxNumber;++i){
T valX=0,valY=0,valZ=0;
if(this->optimiseX==true)
valX = *ptrX;
if(this->optimiseY==true)
valY = *ptrY;
if(this->optimiseZ==true)
valZ = *ptrZ;
T tempLength = (float)(sqrt(valX*valX + valY*valY + valZ*valZ));
if(tempLength>maxGradValue){
*ptrX *= maxGradValue / tempLength;
*ptrY *= maxGradValue / tempLength;
*ptrZ *= maxGradValue / tempLength;
}
*ptrX++ /= maxGradValue;
*ptrY++ /= maxGradValue;
*ptrZ++ /= maxGradValue;
}
}
else{
ptrX = static_cast<T *>(this->transformationGradient->data);
ptrY = &ptrX[voxNumber];
for(size_t i=0;i<voxNumber;++i){
T valX=0,valY=0;
if(this->optimiseX==true)
valX = *ptrX;
if(this->optimiseY==true)
valY = *ptrY;
T tempLength = (float)(sqrt(valX*valX + valY*valY));
if(tempLength>maxGradValue){
*ptrX *= maxGradValue / tempLength;
*ptrY *= maxGradValue / tempLength;
}
*ptrX++ /= maxGradValue;
*ptrY++ /= maxGradValue;
}
}
}
// Returns the largest gradient distance
return maxGradValue;
......@@ -849,8 +899,8 @@ void reg_f3d<T>::GetApproximatedGradient()
{
// Loop over every control point
T *gridPtr = static_cast<T *>(this->controlPointGrid->data);
T *gradPtr = static_cast<T *>(this->transformationGradient->data);
T eps = this->controlPointGrid->dx / 1000.f;
T *gradPtr = static_cast<T *>(this->transformationGradient->data);
T eps = this->controlPointGrid->dx / 1000.f;
for(size_t i=0; i<this->controlPointGrid->nvox;i++)
{
T currentValue = this->optimiser->GetBestDOF()[i];
......
......@@ -575,12 +575,12 @@ void reg_f3d2<T>::UpdateParameters(float scale)
// Reorient the warped grids if necessary
#ifdef _WIN32
long node, nodeNumber;
long node;
#else
size_t node, nodeNumber;
size_t node;
#endif
// Reorient the forward grid in the backward space
nodeNumber=this->backwardControlPointGrid->nx*this->backwardControlPointGrid->ny*this->backwardControlPointGrid->nz;
size_t nodeNumber=(size_t)this->backwardControlPointGrid->nx*this->backwardControlPointGrid->ny*this->backwardControlPointGrid->nz;
T *propVelFieldPtrX=static_cast<T *>(forward2backward->data);
T *propVelFieldPtrY=&propVelFieldPtrX[nodeNumber];
......
......@@ -817,10 +817,15 @@ void reg_f3d_sym<T>::GetSimilarityMeasureGradient()
/* The gradient is converted from voxel space to real space */
mat44 *referenceMatrix_xyz=NULL;
int controlPointNumber=this->backwardControlPointGrid->nx *
size_t controlPointNumber=
(size_t)this->backwardControlPointGrid->nx *
this->backwardControlPointGrid->ny *
this->backwardControlPointGrid->nz;
int i;
this->backwardControlPointGrid->nz;
#ifdef _WINDOWS
int i;
#else
size_t i;
#endif
if(this->currentReference->sform_code>0)
referenceMatrix_xyz = &(this->currentReference->sto_xyz);
else referenceMatrix_xyz = &(this->currentReference->qto_xyz);
......
......@@ -140,14 +140,19 @@ void reg_fem_getDeformationField(float *nodePositions,
float *femInterpolationWeight
)
{
int voxelNumber=deformationFieldImage->nx*
deformationFieldImage->ny*
deformationFieldImage->nz;
size_t voxelNumber=
(size_t)deformationFieldImage->nx*
deformationFieldImage->ny*
deformationFieldImage->nz;
float *defPtrX = static_cast<float *>(deformationFieldImage->data);
float *defPtrY = &defPtrX[voxelNumber];
float *defPtrZ = &defPtrY[voxelNumber];
int voxel;
#ifdef _WINDOWS
int voxel;
#else
size_t voxel;
#endif
float coefficients[4];
float positionA[3], positionB[3], positionC[3], positionD[3];
#ifdef _OPENMP
......
......@@ -2001,7 +2001,12 @@ void reg_defField_compose2D(nifti_image *deformationField,
df_voxel2Real=&(deformationField->qto_xyz);
}
size_t i, index;
#ifdef _WINDOWS
int i;
#else
size_t i;
#endif
size_t index;
int a, b, pre[2];
DTYPE realDefX, realDefY, voxelX, voxelY;
DTYPE defX, defY, relX[2], relY[2], basis;
......@@ -2091,7 +2096,12 @@ void reg_defField_compose3D(nifti_image *deformationField,
df_real2Voxel=&deformationField->qto_ijk;
df_voxel2Real=&deformationField->qto_xyz;
}
size_t i, tempIndex, index;
#ifdef _WINDOWS
int i;
#else
size_t i;
#endif
size_t tempIndex, index;
int a, b, c, currentX, currentY, currentZ, pre[3];
DTYPE realDefX, realDefY, realDefZ, voxelX, voxelY, voxelZ, tempBasis;
......
......@@ -23,7 +23,7 @@
#define reg_pow2(a) ((a)*(a))
#define reg_ceil(a) (ceil(a))
#define reg_round(a) ((a)>0.0 ?(int)((a)+0.5):(int)((a)-0.5))
#ifdef _WINDOWS
#ifdef _WIN32
#define reg_floor(a) ((a)>0?(int)(a):(int)((a)-1))
#else
#define reg_floor(a) ((a)>=0?(int)(a):floor(a))
......
......@@ -151,11 +151,16 @@ void reg_getEntropies1(nifti_image *referenceImage,
int num_fixed_volumes = referenceImage->nt;
int num_warped_volumes = warpedImage->nt;
int i, j, index;
int i, j;
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
if(num_fixed_volumes>1 || num_warped_volumes>1) approx=true;
int fixedVoxelNumber = referenceImage->nx * referenceImage->ny * referenceImage->nz;
size_t fixedVoxelNumber = (size_t)referenceImage->nx * referenceImage->ny * referenceImage->nz;
DTYPE *referenceImagePtr = static_cast<DTYPE *>(referenceImage->data);
DTYPE *warpedImagePtr = static_cast<DTYPE *>(warpedImage->data);
......@@ -712,7 +717,7 @@ void reg_getVoxelBasedNMIGradientUsingPW3D(nifti_image *referenceImage,
if(num_fixed_volumes>1 || num_warped_volumes>1) approx=true;
int fixedVoxelNumber = referenceImage->nx * referenceImage->ny * referenceImage->nz;
size_t fixedVoxelNumber = (size_t)referenceImage->nx * referenceImage->ny * referenceImage->nz;
DTYPE *referenceImagePtr = static_cast<DTYPE *>(referenceImage->data);
DTYPE *warpedImagePtr = static_cast<DTYPE *>(warpedImage->data);
......@@ -790,7 +795,12 @@ void reg_getVoxelBasedNMIGradientUsingPW3D(nifti_image *referenceImage,
GradTYPE warped_common[3];
GradTYPE der_term[3];
int index, currentIndex, relative_pos, i, j, lc, jc;
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
int currentIndex, relative_pos, i, j, lc, jc;
int fixed_flat_index, warped_flat_index;
DTYPE temp;
GradTYPE reg;
......
......@@ -298,11 +298,11 @@ void reg_conjugateGradient<T>::Initialise(size_t nvox,
template <class T>
void reg_conjugateGradient<T>::UpdateGradientValues()
{
#if defined (_WIN32)
int i;
#ifdef _WINDOWS
int i;
#else
// size_t i;
int i;
size_t i;
#endif
size_t num=this->dofNumber;
size_t num_b=this->dofNumber_b;
......
......@@ -49,8 +49,8 @@ void CubicSplineResampleImage3D(nifti_image *floatingImage,
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
SourceTYPE *resultIntensityPtr = static_cast<SourceTYPE *>(warpedImage->data);
FieldTYPE *deformationFieldPtrX = static_cast<FieldTYPE *>(deformationField->data);
size_t resultVoxelNumber = warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t resultVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
FieldTYPE *deformationFieldPtrY = &deformationFieldPtrX[resultVoxelNumber];
FieldTYPE *deformationFieldPtrZ = &deformationFieldPtrY[resultVoxelNumber];
......@@ -76,8 +76,12 @@ void CubicSplineResampleImage3D(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
FieldTYPE xBasis[4], yBasis[4], zBasis[4], relative;
int a, b, c, Y, Z, previous[3];
size_t index;
int a, b, c, Y, Z, previous[3];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
SourceTYPE *zPointer, *yzPointer, *xyzPointer;
FieldTYPE xTempNewValue, yTempNewValue, intensity, world[3], position[3];
#ifdef _OPENMP
......@@ -214,8 +218,12 @@ void CubicSplineResampleImage2D(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
FieldTYPE xBasis[4], yBasis[4], relative;
int a, b, Y, previous[2];
size_t index;
int a, b, Y, previous[2];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
SourceTYPE *yPointer, *xyPointer;
FieldTYPE xTempNewValue, intensity, world[2], position[2];
#ifdef _OPENMP
......@@ -317,8 +325,8 @@ void TrilinearResampleImage(nifti_image *floatingImage,
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
SourceTYPE *resultIntensityPtr = static_cast<SourceTYPE *>(warpedImage->data);
FieldTYPE *deformationFieldPtrX = static_cast<FieldTYPE *>(deformationField->data);
size_t targetVoxelNumber = warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t targetVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
FieldTYPE *deformationFieldPtrY = &deformationFieldPtrX[targetVoxelNumber];
FieldTYPE *deformationFieldPtrZ = &deformationFieldPtrY[targetVoxelNumber];
......@@ -342,8 +350,12 @@ void TrilinearResampleImage(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
FieldTYPE xBasis[2], yBasis[2], zBasis[2], relative;
int a, b, c, X, Y, Z, previous[3];
size_t index;
int a, b, c, X, Y, Z, previous[3];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
SourceTYPE *zPointer, *xyzPointer;
FieldTYPE xTempNewValue, yTempNewValue, intensity, world[3], position[3];
#ifdef _OPENMP
......@@ -483,8 +495,8 @@ void BilinearResampleImage(nifti_image *floatingImage,
// The resampling scheme is applied along each time
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
SourceTYPE *resultIntensityPtr = static_cast<SourceTYPE *>(warpedImage->data);
size_t targetVoxelNumber = warpedImage->nx*warpedImage->ny;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny;
size_t targetVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny;
FieldTYPE *deformationFieldPtrX = static_cast<FieldTYPE *>(deformationField->data);
FieldTYPE *deformationFieldPtrY = &deformationFieldPtrX[targetVoxelNumber];
......@@ -510,8 +522,12 @@ void BilinearResampleImage(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
FieldTYPE xBasis[2], yBasis[2], relative;
int a, b, X, Y, previous[3];
size_t index;
int a, b, X, Y, previous[3];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
SourceTYPE *xyPointer;
FieldTYPE xTempNewValue, intensity, world[2], position[2];
#ifdef _OPENMP
......@@ -616,8 +632,8 @@ void NearestNeighborResampleImage(nifti_image *floatingImage,
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
SourceTYPE *resultIntensityPtr = static_cast<SourceTYPE *>(warpedImage->data);
FieldTYPE *deformationFieldPtrX = static_cast<FieldTYPE *>(deformationField->data);
size_t targetVoxelNumber = warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t targetVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
FieldTYPE *deformationFieldPtrY = &deformationFieldPtrX[targetVoxelNumber];
FieldTYPE *deformationFieldPtrZ = &deformationFieldPtrY[targetVoxelNumber];
......@@ -644,8 +660,12 @@ void NearestNeighborResampleImage(nifti_image *floatingImage,
SourceTYPE intensity;
FieldTYPE world[3];
FieldTYPE position[3];
int previous[3];
size_t index;
int previous[3];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
#ifdef _OPENMP
#pragma omp parallel for default(none) \
private(index, intensity, world, position, previous) \
......@@ -699,8 +719,8 @@ void NearestNeighborResampleImage2D(nifti_image *floatingImage,
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
SourceTYPE *resultIntensityPtr = static_cast<SourceTYPE *>(warpedImage->data);
FieldTYPE *deformationFieldPtrX = static_cast<FieldTYPE *>(deformationField->data);
size_t targetVoxelNumber = warpedImage->nx*warpedImage->ny;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny;
size_t targetVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny;
FieldTYPE *deformationFieldPtrY = &deformationFieldPtrX[targetVoxelNumber];
int *maskPtr = &mask[0];
......@@ -726,8 +746,12 @@ void NearestNeighborResampleImage2D(nifti_image *floatingImage,
SourceTYPE intensity;
FieldTYPE world[2];
FieldTYPE position[2];
int previous[2];
size_t index;
int previous[2];
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
#ifdef _OPENMP
#pragma omp parallel for default(none) \
private(index, intensity, world, position, previous) \
......@@ -1028,8 +1052,8 @@ void reg_bilinearResampleGradient(nifti_image *floatingImage,
nifti_image *deformationField,
float paddingValue)
{
size_t floatingVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t warpedVoxelNumber = warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t floatingVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t warpedVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny*warpedImage->nz;
DTYPE *floatingIntensityX = static_cast<DTYPE *>(floatingImage->data);
DTYPE *floatingIntensityY = &floatingIntensityX[floatingVoxelNumber];
DTYPE *warpedIntensityX = static_cast<DTYPE *>(warpedImage->data);
......@@ -1208,8 +1232,8 @@ void reg_trilinearResampleGradient(nifti_image *floatingImage,
nifti_image *deformationField,
float paddingValue)
{
size_t floatingVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t warpedVoxelNumber = warpedImage->nx*warpedImage->ny*warpedImage->nz;
size_t floatingVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t warpedVoxelNumber = (size_t)warpedImage->nx*warpedImage->ny*warpedImage->nz;
DTYPE *floatingIntensityX = static_cast<DTYPE *>(floatingImage->data);
DTYPE *floatingIntensityY = &floatingIntensityX[floatingVoxelNumber];
DTYPE *floatingIntensityZ = &floatingIntensityY[floatingVoxelNumber];
......@@ -1495,8 +1519,8 @@ void TrilinearImageGradient(nifti_image *floatingImage,
int *mask,
float paddingValue)
{
int targetVoxelNumber = resultGradientImage->nx*resultGradientImage->ny*resultGradientImage->nz;
int sourceVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t targetVoxelNumber = (size_t)resultGradientImage->nx*resultGradientImage->ny*resultGradientImage->nz;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
int gradientOffSet = targetVoxelNumber*resultGradientImage->nt;
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
GradientTYPE *resultGradientImagePtr = static_cast<GradientTYPE *>(resultGradientImage->data);
......@@ -1528,7 +1552,12 @@ void TrilinearImageGradient(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
int previous[3], index, a, b, c, X, Y, Z;
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
int previous[3], a, b, c, X, Y, Z;
FieldTYPE position[3], xBasis[2], yBasis[2], zBasis[2];
FieldTYPE deriv[2];deriv[0]=-1;deriv[1]=1;
FieldTYPE relative, world[3], grad[3], coeff;
......@@ -1676,8 +1705,8 @@ void BilinearImageGradient(nifti_image *floatingImage,
int *mask,
float paddingValue)
{
int targetVoxelNumber = resultGradientImage->nx*resultGradientImage->ny;
int sourceVoxelNumber = floatingImage->nx*floatingImage->ny;
size_t targetVoxelNumber = (size_t)resultGradientImage->nx*resultGradientImage->ny;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny;
unsigned int gradientOffSet = targetVoxelNumber*resultGradientImage->nt;
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
......@@ -1710,7 +1739,12 @@ void BilinearImageGradient(nifti_image *floatingImage,
FieldTYPE position[3], xBasis[2], yBasis[2], relative, world[2], grad[2];
FieldTYPE deriv[2];deriv[0]=-1;deriv[1]=1;
FieldTYPE coeff, xTempNewValue, yTempNewValue;
int previous[3], index, a, b, X, Y;
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
int previous[3], a, b, X, Y;
SourceTYPE *xyPointer;
#ifdef _OPENMP
......@@ -1801,9 +1835,9 @@ void CubicSplineImageGradient3D(nifti_image *floatingImage,
int *mask,
float paddingValue)
{
size_t targetVoxelNumber = resultGradientImage->nx*resultGradientImage->ny*resultGradientImage->nz;
size_t sourceVoxelNumber = floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t gradientOffSet = targetVoxelNumber*resultGradientImage->nt;
size_t targetVoxelNumber = (size_t)resultGradientImage->nx*resultGradientImage->ny*resultGradientImage->nz;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny*floatingImage->nz;
size_t gradientOffSet = (size_t)targetVoxelNumber*resultGradientImage->nt;
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
GradientTYPE *resultGradientImagePtr = static_cast<GradientTYPE *>(resultGradientImage->data);
......@@ -1835,7 +1869,12 @@ void CubicSplineImageGradient3D(nifti_image *floatingImage,
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
int previous[3], index, c, Z, b, Y, a;
int previous[3], c, Z, b, Y, a;
#ifdef _WINDOWS
int index;
#else
size_t index;
#endif
FieldTYPE xBasis[4], yBasis[4], zBasis[4], xDeriv[4], yDeriv[4], zDeriv[4];
FieldTYPE coeff, position[3], relative, world[3], grad[3];
FieldTYPE xxTempNewValue, yyTempNewValue, zzTempNewValue, xTempNewValue, yTempNewValue;
......@@ -1954,9 +1993,9 @@ void CubicSplineImageGradient2D(nifti_image *floatingImage,
nifti_image *resultGradientImage,
int *mask)
{
int targetVoxelNumber = resultGradientImage->nx*resultGradientImage->ny;
int sourceVoxelNumber = floatingImage->nx*floatingImage->ny;
unsigned int gradientOffSet = targetVoxelNumber*resultGradientImage->nt;
size_t targetVoxelNumber = (size_t)resultGradientImage->nx*resultGradientImage->ny;
size_t sourceVoxelNumber = (size_t)floatingImage->nx*floatingImage->ny;
size_t gradientOffSet = (size_t)targetVoxelNumber*resultGradientImage->nt;
SourceTYPE *sourceIntensityPtr = static_cast<SourceTYPE *>(floatingImage->data);
GradientTYPE *resultGradientImagePtr = static_cast<GradientTYPE *>(resultGradientImage->data);
......@@ -1983,11 +2022,16 @@ void CubicSplineImageGradient2D(nifti_image *floatingImage,
GradientTYPE *resultGradientPtrX = &resultGradientImagePtr[targetVoxelNumber*t];
GradientTYPE *resultGradientPtrY = &resultGradientPtrX[gradientOffSet];
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];
SourceTYPE *sourceIntensity = &sourceIntensityPtr[t*sourceVoxelNumber];