X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkImageUtilities.txx;h=8f42551f01cb67c7411795a623a8eda70646e19e;hb=e1098dccba022441144bfc1c44a2b58db7dde34e;hp=884dab91294d841610f9d2d1847907d088de994f;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/common/clitkImageUtilities.txx b/common/clitkImageUtilities.txx index 884dab9..8f42551 100644 --- a/common/clitkImageUtilities.txx +++ b/common/clitkImageUtilities.txx @@ -1,22 +1,38 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ #ifndef CLITKIMAGEUTILITIES_TXX #define CLITKIMAGEUTILITIES_TXX - /** ================================================= * @file clitkImageUtilities.txx * @author David Sarrut * @date 22 Sep 2006 10:39:48 - * - * @brief - * - * + * + * @brief + * + * =================================================*/ //==================================================================== // Compute the number of different intensities in an image template -int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, - std::vector & l) +int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, + std::vector & l) { //std::set listOfIntensities; std::map listOfIntensities; @@ -25,40 +41,41 @@ int ComputeHowManyDifferentIntensity(const typename ImageType::Pointer & image, ConstIteratorType pi(image, image->GetLargestPossibleRegion()); pi.Begin(); while (!pi.IsAtEnd()) { - if (!listOfIntensities[pi.Get()]) listOfIntensities[pi.Get()] = true; - // if (std::find(listOfIntensities.begin(), -// listOfIntensities.end(), + if (!listOfIntensities[pi.Get()]) listOfIntensities[pi.Get()] = true; + // if (std::find(listOfIntensities.begin(), +// listOfIntensities.end(), // pi.Get()) == listOfIntensities.end()) { // listOfIntensities.insert(pi.Get()); // } - ++pi; + ++pi; } - + //typename std::set::const_iterator ppi = listOfIntensities.begin(); typename std::map::const_iterator ppi = listOfIntensities.begin(); while (ppi != listOfIntensities.end()) { - l.push_back(ppi->first); - ++ppi; + l.push_back(ppi->first); + ++ppi; } return listOfIntensities.size(); } //==================================================================== - + //==================================================================== template -void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, - const typename MaskImageType::Pointer & mask, - const std::vector & listOfIntensities, - std::map > & mapOfLabelsAndWeights) { +void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, + const typename MaskImageType::Pointer & mask, + const std::vector & listOfIntensities, + std::map > & mapOfLabelsAndWeights) +{ // Check size if (input->GetLargestPossibleRegion() != mask->GetLargestPossibleRegion()) { - itkGenericExceptionMacro(<< "Input and mask images have not the same size" - << std::endl - << "Input = " << input->GetLargestPossibleRegion() - << std::endl - << "Mask = " << mask->GetLargestPossibleRegion()); + itkGenericExceptionMacro(<< "Input and mask images have not the same size" + << std::endl + << "Input = " << input->GetLargestPossibleRegion() + << std::endl + << "Mask = " << mask->GetLargestPossibleRegion()); } // reset weights list @@ -72,16 +89,16 @@ void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, pi.Begin(); pm.Begin(); while (!pi.IsAtEnd()) { - mapOfLabelsAndWeights[pm.Get()][pi.Get()]++; - ++pi; - ++pm; + mapOfLabelsAndWeights[pm.Get()][pi.Get()]++; + ++pi; + ++pm; } } //==================================================================== // //==================================================================== // template -// typename ImageType::Pointer NewImage3D(int x, int y, int z, float dx, float dy, float dz) { +// typename ImageType::Pointer NewImage3D(int x, int y, int z, float dx, float dy, float dz) { // typename ImageType::Pointer output = ImageType::New(); // typename ImageType::RegionType region; // typename ImageType::SizeType size; @@ -91,7 +108,7 @@ void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, // region.SetSize(size); // output->SetRegions(region); // output->Allocate(); -// typename ImageType::SpacingType spacing; +// typename ImageType::SpacingType spacing; // spacing[0] = dx; // spacing[1] = dy; // spacing[2] = dz;