1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKIMAGELOG_CXX
19 #define CLITKIMAGELOG_CXX
21 =================================================
22 * @file clitkImageLog.cxx
23 * @author Jef Vandemeulebroucke <Jef@creatis.insa-lyon.fr>
24 * @date 04 April 2008 15:28:32
28 * Take an inverse normalized log of the image intensity
29 =================================================*/
32 #include "clitkImageLog_ggo.h"
34 #include "clitkCommon.h"
37 #include "itkImageFileReader.h"
38 #include "itkImageFileWriter.h"
39 #include "itkImageRegionIterator.h"
41 int main(int argc, char * argv[]) {
44 GGO(clitkImageLog, args_info);
47 typedef float PixelType;
48 const unsigned int Dimension=3;
49 typedef itk::Image<PixelType, Dimension> ImageType;
50 typedef itk::ImageFileReader<ImageType> ImageReaderType;
51 typedef itk::ImageFileWriter<ImageType> ImageWriterType;
52 typedef itk::ImageRegionIterator<ImageType> IteratorType;
55 ImageReaderType::Pointer reader= ImageReaderType::New();
56 reader->SetFileName(args_info.input_arg);
58 ImageType::Pointer input = reader->GetOutput();
61 IteratorType pi (input, input->GetLargestPossibleRegion());
64 PixelType max=std::numeric_limits<unsigned short>::max();
75 pi.Set(-log((PixelType)(max-pi.Get()+1)/(PixelType)max));
80 ImageWriterType::Pointer writer= ImageWriterType::New();
81 writer->SetFileName(args_info.output_arg);
82 writer->SetInput(input);
89 #endif /* end #define CLITKIMAGELOG_CXX */