]> Creatis software - creaRigidRegistration.git/blobdiff - lib/CheckBoard.cpp
Feature #1766 Add licence terms for all files.
[creaRigidRegistration.git] / lib / CheckBoard.cpp
index b7668359720ac21f6e905fe60005d2e4f36c610f..f47c94c180672e44fe78dfb108c8822fc97a8540 100644 (file)
@@ -1,12 +1,46 @@
-#include "CheckBoard.h"
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
+#                        pour la Santé)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+# Previous Authors : Laurent Guigues, Jean-Pierre Roux
+# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+#
+#  This software is governed by the CeCILL-B license under French law and 
+#  abiding by the rules of distribution of free software. You can  use, 
+#  modify and/ or redistribute the software under the terms of the CeCILL-B 
+#  license as circulated by CEA, CNRS and INRIA at the following URL 
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability. 
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------      */                                                                    
 
+#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 +50,7 @@ CheckBoard::CheckBoard()
        newImage = NULL;
        resample = NULL;
        result = NULL;
+*/
 }
 
 /*
@@ -27,8 +62,7 @@ CheckBoard::~CheckBoard()
        //if (image1 != NULL ) { image1->Delete(); }
        //if (image2 != NULL ) { image2->Delete(); }
        if (newImage != NULL ) { newImage->Delete(); }
-       if (resample != NULL ) { resample->Delete(); }
-       if (result != NULL ) { result->Delete(); }
+       if (result   != NULL ) { result->Delete();   }
 }
 
 //------------------------------------------------------------
@@ -37,7 +71,6 @@ void CheckBoard::calculateImage()
 
        if(image1!=NULL && image2!=NULL)
        {
-
                // IMAGE 1
                        
                // Information from image1
@@ -45,7 +78,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;
@@ -64,7 +97,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();
@@ -82,7 +115,6 @@ void CheckBoard::calculateImage()
                        result = resample->GetOutput();
                        result->Update();
                        createImage(result,image2,dimImg2[0],dimImg2[1]);               
-                       
                } //if
                else if (numPixelsImg1>numPixelsImg2)
                {
@@ -95,7 +127,7 @@ void CheckBoard::calculateImage()
 
                        initialize(dimImg1, spcImg1);
                        result = resample->GetOutput();
-                       
+
                        result->Update();
 
                        createImage(image1,result,dimImg1[0],dimImg1[1]);
@@ -115,11 +147,11 @@ void CheckBoard::calculateImage()
 
                        result = resample->GetOutput();
                        result->Update();
-                       
+
                        createImage(image1,result,dimImg1[0],dimImg1[1]);
 
                } //else
-               
+
                resample->Delete();             
                processed=true;
        }
@@ -138,8 +170,6 @@ void CheckBoard::initialize(int dimensions[], double spacing[])
        newImage->SetDimensions(dimensions);
        newImage->AllocateScalars();
        newImage->Update();
-       
-
 }
 
 //------------------------------------------------------------
@@ -248,7 +278,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();
@@ -261,7 +290,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;
@@ -269,11 +298,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; 
@@ -342,4 +372,3 @@ void CheckBoard::setRows(int rows)
 {
        squaresY=rows;
 }
-