X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FCheckBoard.cpp;h=a0ae2d74423d1a9dc21a4ae4039a1d72d2bb2c75;hb=de35484154f0fc838c0aa515db96994166bba17d;hp=cb3bdc69a2da882c2ce2560bcf3c205fd7160fea;hpb=1b82b60c6337722f1a97bc8f7d6eadcc90352017;p=creaRigidRegistration.git diff --git a/lib/CheckBoard.cpp b/lib/CheckBoard.cpp index cb3bdc6..a0ae2d7 100644 --- a/lib/CheckBoard.cpp +++ b/lib/CheckBoard.cpp @@ -1,12 +1,22 @@ #include "CheckBoard.h" - /* * Constructor */ //------------------------------------------------------------ CheckBoard::CheckBoard() +: // use 'Initialization List'! //JPR + image1(NULL); + image2(NULL); + squaresX(0); + squaresY(0); + newImage(NULL); + processed(false); + newImage(NULL); + resample(NULL); + result(NULL); { +/* image1=NULL; image2=NULL; squaresX=0; @@ -16,6 +26,7 @@ CheckBoard::CheckBoard() newImage = NULL; resample = NULL; result = NULL; +*/ } /* @@ -27,7 +38,7 @@ CheckBoard::~CheckBoard() //if (image1 != NULL ) { image1->Delete(); } //if (image2 != NULL ) { image2->Delete(); } if (newImage != NULL ) { newImage->Delete(); } - if (result != NULL ) { result->Delete(); } + if (result != NULL ) { result->Delete(); } } //------------------------------------------------------------ @@ -36,7 +47,6 @@ void CheckBoard::calculateImage() if(image1!=NULL && image2!=NULL) { - // IMAGE 1 // Information from image1 @@ -44,7 +54,7 @@ void CheckBoard::calculateImage() image1->GetExtent(extImg1); type = image1->GetScalarType(); - + // The Z dimension is 1 for a 2D image dimImg1[0] = extImg1[1] - extImg1[0]+1; dimImg1[1] = extImg1[3] - extImg1[2]+1; @@ -63,7 +73,7 @@ void CheckBoard::calculateImage() long numPixelsImg1 = dimImg1[0]*dimImg1[1]; long numPixelsImg2 = dimImg2[0]*dimImg2[1]; - + double factorX = 1; double factorY = 1; resample = vtkImageResample::New(); @@ -81,7 +91,6 @@ void CheckBoard::calculateImage() result = resample->GetOutput(); result->Update(); createImage(result,image2,dimImg2[0],dimImg2[1]); - } //if else if (numPixelsImg1>numPixelsImg2) { @@ -94,7 +103,7 @@ void CheckBoard::calculateImage() initialize(dimImg1, spcImg1); result = resample->GetOutput(); - + result->Update(); createImage(image1,result,dimImg1[0],dimImg1[1]); @@ -114,11 +123,11 @@ void CheckBoard::calculateImage() result = resample->GetOutput(); result->Update(); - + createImage(image1,result,dimImg1[0],dimImg1[1]); } //else - + resample->Delete(); processed=true; } @@ -137,8 +146,6 @@ void CheckBoard::initialize(int dimensions[], double spacing[]) newImage->SetDimensions(dimensions); newImage->AllocateScalars(); newImage->Update(); - - } //------------------------------------------------------------ @@ -247,7 +254,6 @@ void CheckBoard::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX, createImageByType(dataImagePointer1,dataImagePointer2,dataImageResultPointer,img1,img2,sizeX,sizeY); } - //std::cout << "The image has been checkboardized!" << std::endl; newImage->Update(); // newImage->Modified(); @@ -260,7 +266,7 @@ void CheckBoard::createImageByType(T* dataImagePointer1, T* dataImagePointer2, T dataImagePointer1 = (T*) img1->GetScalarPointer(0,0,0); dataImagePointer2 = (T*) img2->GetScalarPointer(0,0,0); dataImageResultPointer = (T*) newImage->GetScalarPointer(0,0,0); - + if(squaresX == 0) { squaresX = 1; @@ -268,11 +274,12 @@ void CheckBoard::createImageByType(T* dataImagePointer1, T* dataImagePointer2, T if(squaresY == 0) { squaresY = 1; - } + } int divX = sizeX/squaresX; int divY = sizeY/squaresY; - int i, j, counterX, counterY; + int i, j; + int counterX=0, counterY; // JPR : uninitialized for(i = 0; i < sizeX; i++) { counterY = 0; @@ -341,4 +348,3 @@ void CheckBoard::setRows(int rows) { squaresY=rows; } -