From: eduardo.davila@creatis.insa-lyon.fr Date: Tue, 25 Jun 2024 17:20:54 +0000 (+0200) Subject: #3472 Bug in Transparency Box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=e2d24feebab040581ef1ce23c8a6acb89a4d81b4;p=creaRigidRegistration.git #3472 Bug in Transparency Box --- diff --git a/lib/Transparency.cxx b/lib/Transparency.cxx index 6b3549f..60706c5 100644 --- a/lib/Transparency.cxx +++ b/lib/Transparency.cxx @@ -105,7 +105,7 @@ void Transparency::calculateImage() #else //... #endif - createImage(result,_image2,dimImg2[0],dimImg2[1]); + createImage(result,_image2,dimImg1[0],dimImg1[1]); } else if (numPixelsImg1>numPixelsImg2) { //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -133,9 +133,9 @@ void Transparency::calculateImage() #else result->Modified(); #endif - createImage(_image1,result,dimImg1[0],dimImg1[1]); + createImage(_image1,result,dimImg2[0],dimImg2[1]); } else { - //If both images have the same number of pixels, the resultant image will have the + //If both images have the same number of pixels, the resultant image will have the //properties of the first image. //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -164,7 +164,7 @@ void Transparency::calculateImage() #endif createImage(_image1,result,dimImg1[0],dimImg1[1]); } //else - resample->Delete(); + resample->Delete(); _processed=true; } } @@ -189,102 +189,84 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX { if(_type == VTK_CHAR) { - //POINTERS: + //POINTERS: char* dataImagePointer1 = NULL; char* dataImagePointer2 = NULL; char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_SIGNED_CHAR) - { - //POINTERS: + } else if(_type == VTK_SIGNED_CHAR) { + //POINTERS: signed char* dataImagePointer1 = NULL; signed char* dataImagePointer2 = NULL; signed char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_UNSIGNED_CHAR) - { - //POINTERS: + } else if(_type == VTK_UNSIGNED_CHAR) { + //POINTERS: unsigned char* dataImagePointer1 = NULL; unsigned char* dataImagePointer2 = NULL; unsigned char* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_SHORT) - { - //POINTERS: + } else if(_type == VTK_SHORT) { + //POINTERS: short* dataImagePointer1 = NULL; short* dataImagePointer2 = NULL; short* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_UNSIGNED_SHORT) - { - //POINTERS: + } else if(_type == VTK_UNSIGNED_SHORT) { + //POINTERS: unsigned short* dataImagePointer1 = NULL; unsigned short* dataImagePointer2 = NULL; unsigned short* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_INT) - { - //POINTERS: + } else if(_type == VTK_INT) { + //POINTERS: int* dataImagePointer1 = NULL; int* dataImagePointer2 = NULL; int* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_UNSIGNED_INT) - { - //POINTERS: + } else if(_type == VTK_UNSIGNED_INT) { + //POINTERS: unsigned int* dataImagePointer1 = NULL; unsigned int* dataImagePointer2 = NULL; unsigned int* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_LONG) - { - //POINTERS: + } else if(_type == VTK_LONG) { + //POINTERS: long* dataImagePointer1 = NULL; long* dataImagePointer2 = NULL; long* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_UNSIGNED_LONG) - { - //POINTERS: + } else if(_type == VTK_UNSIGNED_LONG) { + //POINTERS: unsigned long* dataImagePointer1 = NULL; unsigned long* dataImagePointer2 = NULL; unsigned long* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_FLOAT) - { - //POINTERS: + } else if(_type == VTK_FLOAT) { + //POINTERS: float* dataImagePointer1 = NULL; float* dataImagePointer2 = NULL; float* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } - else if(_type == VTK_DOUBLE) - { - //POINTERS: + } else if(_type == VTK_DOUBLE) { + //POINTERS: double* dataImagePointer1 = NULL; double* dataImagePointer2 = NULL; double* dataImageResultPointer = NULL; createImageByType(dataImagePointer1, dataImagePointer2, dataImageResultPointer, img1, img2, sizeX, sizeY); - } + } else { + printf("EED Error. Transparency::createImage Format not defined (%d) \n", _type); + } //EED 2017-01-01 Migration VTK7 #if VTK_MAJOR_VERSION <= 5 @@ -292,6 +274,8 @@ void Transparency::createImage(vtkImageData *img1, vtkImageData *img2, int sizeX #else _newImage->Modified(); #endif + + } template @@ -309,7 +293,7 @@ void Transparency::createImageByType(T* dataImagePointer1, T* dataImagePointer2, dataImagePointer2 = (T*)img2->GetScalarPointer(i,j,0); dataImageResultPointer = (T*)_newImage->GetScalarPointer(i,j,0); *dataImageResultPointer = (T)*dataImagePointer1*_percent + (T)*dataImagePointer2*(1-_percent); - } // for h + } // for j } // for i } @@ -321,8 +305,7 @@ vtkImageData* Transparency::getImage() { if(_processed){ return _newImage; - } - else{ + } else { return NULL; } }