X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=lib%2FCheckBoard.cpp;h=34a6749d7d08d01103c9f64ad17feeeea2cd3eba;hb=1a574b510e27eb5b5f00bd37bf451cedd1b0a8d4;hp=cb3bdc69a2da882c2ce2560bcf3c205fd7160fea;hpb=ef1b2d78a9c08ea55e470608a6a8fe0fa1ad6099;p=creaRigidRegistration.git diff --git a/lib/CheckBoard.cpp b/lib/CheckBoard.cpp index cb3bdc6..34a6749 100644 --- a/lib/CheckBoard.cpp +++ b/lib/CheckBoard.cpp @@ -1,12 +1,20 @@ #include "CheckBoard.h" - /* * Constructor */ //------------------------------------------------------------ -CheckBoard::CheckBoard() +CheckBoard::CheckBoard() : + image1(NULL), + image2(NULL), + squaresX(0), + squaresY(0), + newImage(NULL), + processed(false), + resample(NULL), + result(NULL) { +/* image1=NULL; image2=NULL; squaresX=0; @@ -16,6 +24,7 @@ CheckBoard::CheckBoard() newImage = NULL; resample = NULL; result = NULL; +*/ } /* @@ -27,7 +36,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 +45,6 @@ void CheckBoard::calculateImage() if(image1!=NULL && image2!=NULL) { - // IMAGE 1 // Information from image1 @@ -44,7 +52,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 +71,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 +89,6 @@ void CheckBoard::calculateImage() result = resample->GetOutput(); result->Update(); createImage(result,image2,dimImg2[0],dimImg2[1]); - } //if else if (numPixelsImg1>numPixelsImg2) { @@ -94,7 +101,7 @@ void CheckBoard::calculateImage() initialize(dimImg1, spcImg1); result = resample->GetOutput(); - + result->Update(); createImage(image1,result,dimImg1[0],dimImg1[1]); @@ -114,11 +121,11 @@ void CheckBoard::calculateImage() result = resample->GetOutput(); result->Update(); - + createImage(image1,result,dimImg1[0],dimImg1[1]); } //else - + resample->Delete(); processed=true; } @@ -137,8 +144,6 @@ void CheckBoard::initialize(int dimensions[], double spacing[]) newImage->SetDimensions(dimensions); newImage->AllocateScalars(); newImage->Update(); - - } //------------------------------------------------------------ @@ -247,7 +252,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 +264,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 +272,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 +346,3 @@ void CheckBoard::setRows(int rows) { squaresY=rows; } -