From e29416b325ace3497929a9adfcf297845b4ecae4 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 26 Jul 2013 15:05:15 +0200 Subject: [PATCH] Add clitkImageUncertainty (for gate dose uncertainty) --- tools/CMakeLists.txt | 5 +++ tools/clitkImageUncertainty.cxx | 57 ++++++++++++++++----------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index b67e4ab..a1c6bf3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -294,6 +294,11 @@ IF (CLITK_BUILD_TOOLS) TARGET_LINK_LIBRARIES(clitkMergeAsciiDoseActor ITKCommon clitkCommon) SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeAsciiDoseActor) + WRAP_GGO(clitkImageUncertainty_GGO_C clitkImageUncertainty.ggo) + ADD_EXECUTABLE(clitkImageUncertainty clitkImageUncertainty.cxx clitkImageUncertainty_ggo.c) + TARGET_LINK_LIBRARIES(clitkImageUncertainty clitkCommon ${ITK_LIBRARIES}) + SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageUncertainty) + #========================================================= option(CLITK_USE_ROOT "Build experimental tools using root" OFF) if (CLITK_USE_ROOT) diff --git a/tools/clitkImageUncertainty.cxx b/tools/clitkImageUncertainty.cxx index 6fc003b..bf5759f 100644 --- a/tools/clitkImageUncertainty.cxx +++ b/tools/clitkImageUncertainty.cxx @@ -1,19 +1,19 @@ /*========================================================================= - + Program: clitk Module: $RCSfile: clitkImageUncertainty.cxx,v $ Language: C++ Date: $Date: 2011/03/03 15:03:30 $ Version: $Revision: 1.3 $ - + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + =========================================================================*/ #ifndef CLITKIMAGEUNCERTAINTY_CXX @@ -24,10 +24,10 @@ * @file clitkImageUncertainty.cxx * @author David Sarrut * @date 04 Jul 2006 14:03:57 - * - * @brief - * - * + * + * @brief + * + * =================================================*/ // clitk include @@ -51,31 +51,31 @@ int main(int argc, char * argv[]) { typedef float PixelType; const unsigned int Dimension=3; typedef itk::Image< PixelType, Dimension > ImageType; - + // Read images - ImageType::Pointer input = + ImageType::Pointer input = clitk::readImage(args_info.input_arg, args_info.verbose_flag); - ImageType::Pointer inputSquared = + ImageType::Pointer inputSquared = clitk::readImage(args_info.inputSquared_arg, args_info.verbose_flag); // Create Output ImageType::Pointer output = ImageType::New(); output->SetRegions(input->GetLargestPossibleRegion()); output->CopyInformation(input); - output->Allocate(); + output->Allocate(); // Loop typedef itk::ImageRegionConstIterator ConstIteratorType; ConstIteratorType pi(input, input->GetLargestPossibleRegion()); ConstIteratorType pii(inputSquared, inputSquared->GetLargestPossibleRegion()); - pi.Begin(); - pii.Begin(); + pi.GoToBegin(); + pii.GoToBegin(); typedef itk::ImageRegionIterator IteratorType; IteratorType po(output, output->GetLargestPossibleRegion()); - po.Begin(); - + po.GoToBegin(); + int NumberOfEvents = args_info.NumberOfEvents_arg; - while ( !pi.IsAtEnd() ) { + while ( !pi.IsAtEnd() ) { double squared = pii.Get(); double mean = pi.Get(); double uncert = sqrt((NumberOfEvents*squared - mean*mean) / ((NumberOfEvents-1)*(mean*mean))); @@ -85,7 +85,7 @@ int main(int argc, char * argv[]) { ++pii; ++po; } -// *po = sqrt( (NumberOfEvents*squared - mean*mean) / +// *po = sqrt( (NumberOfEvents*squared - mean*mean) / // ((NumberOfEvents-1)*(mean*mean)) ); // ++po; @@ -97,21 +97,20 @@ int main(int argc, char * argv[]) { clitk::writeImage(output, args_info.output_arg, args_info.verbose_flag); } else { - std::ofstream os; - clitk::openFileForWriting(os, args_info.output_arg); - typedef itk::ImageRegionConstIterator IteratorType; - IteratorType pi(output, output->GetLargestPossibleRegion()); - pi.Begin(); - os << "# Image size = " << output->GetLargestPossibleRegion().GetSize() << std::endl; + std::ofstream os; + clitk::openFileForWriting(os, args_info.output_arg); + typedef itk::ImageRegionConstIterator IteratorType; + IteratorType pi(output, output->GetLargestPossibleRegion()); + pi.GoToBegin(); + os << "# Image size = " << output->GetLargestPossibleRegion().GetSize() << std::endl; os << "# Image spacing = " << output->GetSpacing() << std::endl; os << "# Number of events = " << NumberOfEvents << std::endl; - while (!pi.IsAtEnd()) { - os << pi.Get() << std::endl; - ++pi; - } + while (!pi.IsAtEnd()) { + os << pi.Get() << std::endl; + ++pi; + } } } #endif /* end #define CLITKIMAGEUNCERTAINTY_CXX */ - -- 2.45.1