X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageReader.txx;h=fd1c5755c6670b805c6da83f650768d732f0fab2;hb=55225641fb149bc6d4da4f5a910a66083c8af3cd;hp=cdddf06e95b06c55ca3abe2926548111a2728d31;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git
diff --git a/vv/vvImageReader.txx b/vv/vvImageReader.txx
index cdddf06..fd1c575 100644
--- a/vv/vvImageReader.txx
+++ b/vv/vvImageReader.txx
@@ -1,162 +1,175 @@
/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
-Program: vv
-Module: $RCSfile: vvImageReader.txx,v $
-Language: C++
-Date: $Date: 2010/01/06 13:31:57 $
-Version: $Revision: 1.1 $
-Author : Pierre Seroul (pierre.seroul@gmail.com)
+ Authors belong to:
+ - University of LYON http://www.universite-lyon.fr/
+ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+ - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
-Copyright (C) 2008
-Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
-CREATIS-LRMN 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.
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, version 3 of the License.
+ It is distributed under dual licence
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ - BSD See included LICENSE.txt file
+ - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ ======================================================================-====*/
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-
-=========================================================================*/
-#ifndef vvImageReader_TXX
-#define vvImageReader_TXX
-#include
+#ifndef VVIMAGEREADER_TXX
+#define VVIMAGEREADER_TXX
+#include
#include
#include
+#include
+
+#include
#include "clitkCommon.h"
-#include "itkImageToVTKImageFilter.h"
#include "vvFromITK.h"
#include "vvConstants.h"
+//----------------------------------------------------------------------------
template
void vvImageReader::UpdateWithDim(std::string InputPixelType)
{
- if (mType == VECTORFIELD)
- UpdateWithDimAndInputPixelType,VImageDimension>();
- else if (InputPixelType == "short")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "unsigned_short")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "char")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "unsigned_char")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "int")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "double")
- UpdateWithDimAndInputPixelType();
- else if (InputPixelType == "float")
- UpdateWithDimAndInputPixelType();
- else
- std::cerr << "Error, input pixel type : " << InputPixelType << " unknown !" << std::endl;
+ if (mType == VECTORFIELD)
+ UpdateWithDimAndInputPixelType,VImageDimension>();
+ else if (InputPixelType == "short")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "unsigned_short")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "char")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "unsigned_char")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "int")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "unsigned_int")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "double")
+ UpdateWithDimAndInputPixelType();
+ else if (InputPixelType == "float")
+ UpdateWithDimAndInputPixelType();
+ else
+ std::cerr << "Error, input pixel type : " << InputPixelType << " unknown !" << std::endl;
+
+ if (CLITK_EXPERIMENTAL && mLastError.size()==0) {
+ ReadNkiImageTransform();
+ ReadMatImageTransform();
+ }
}
-//====================================================================
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
template
void vvImageReader::UpdateWithDimAndInputPixelType()
{
- if (mType == MERGEDWITHTIME) // In this case we can load the images
- // one at the time to avoid excessive
- // memory use
- {
- typedef itk::Image< InputPixelType, VImageDimension-1 > InputImageType;
- typedef itk::ImageFileReader ReaderType;
- typename ReaderType::Pointer reader = ReaderType::New();
- typedef itk::ImageToVTKImageFilter ConnectorType;
- typename ConnectorType::Pointer connector = ConnectorType::New();
- connector->SetInput(reader->GetOutput());
- mImage=vvImage::New();
- for (std::vector::const_iterator i=mInputFilenames.begin();i!=mInputFilenames.end();i++)
- {
- std::cout << (*i) << std::endl;
- reader->SetFileName(*i);
- try {
- reader->Update();
- }
- catch ( itk::ExceptionObject & err ) {
- std::cerr << "Error while reading " << mInputFilenames[0].c_str()
- << " " << err << std::endl;
- std::stringstream error;
- error << err;
- mLastError = error.str();
- return;
- }
- try {
- connector->Update();
- }
- catch ( itk::ExceptionObject & err ) {
- std::cerr << "Error while setting vvImage from ITK (MERGEDWITHTIME)"
- << " " << err << std::endl;
- }
- vtkImageData *image = vtkImageData::New();
- image->DeepCopy(connector->GetOutput());
- mImage->AddImage(image);
- }
+
+ // DD(mType);
+
+ if (mType == MERGEDWITHTIME) // In this case we can load the images
+ // one at the time to avoid excessive
+ // memory use
+ {
+ typedef itk::Image< InputPixelType, VImageDimension-1 > InputImageType;
+ typedef itk::ImageFileReader ReaderType;
+ typename ReaderType::Pointer reader = ReaderType::New();
+ typedef itk::ImageToVTKImageFilter ConnectorType;
+ typename ConnectorType::Pointer connector = ConnectorType::New();
+ connector->SetInput(reader->GetOutput());
+ mImage=vvImage::New();
+ for (std::vector::const_iterator i=mInputFilenames.begin(); i!=mInputFilenames.end(); i++) {
+ std::cout << (*i) << std::endl;
+ reader->SetFileName(*i);
+ try {
+ reader->Update();
+ } catch ( itk::ExceptionObject & err ) {
+ std::cerr << "Error while reading " << mInputFilenames[0].c_str()
+ << " " << err << std::endl;
+ std::stringstream error;
+ error << err;
+ mLastError = error.str();
+ return;
+ }
+ try {
+ connector->Update();
+ } catch ( itk::ExceptionObject & err ) {
+ std::cerr << "Error while setting vvImage from ITK (MERGEDWITHTIME)"
+ << " " << err << std::endl;
+ }
+ vtkImageData *image = vtkImageData::New();
+ image->DeepCopy(connector->GetOutput());
+ mImage->AddImage(image);
}
- else
- {
- if (mInputFilenames.size() > 1)
- {
- typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
- typedef itk::ImageSeriesReader ReaderType;
- typename ReaderType::Pointer reader = ReaderType::New();
- for (std::vector::const_iterator i=mInputFilenames.begin();i!=mInputFilenames.end();i++)
- std::cout << (*i) << std::endl;
- reader->SetFileNames(mInputFilenames);
- //if (mUseAnObserver) {
- //reader->AddObserver(itk::ProgressEvent(), mObserver);
- //}
- try {
- reader->Update();
- }
- catch ( itk::ExceptionObject & err ) {
- std::cerr << "Error while reading image series:" << err << std::endl;
- std::stringstream error;
- error << err;
- mLastError = error.str();
- return;
- }
- if (mType == IMAGEWITHTIME)
- mImage=vvImageFromITK(reader->GetOutput(),true);
- else
- mImage=vvImageFromITK(reader->GetOutput());
- }
- else
- {
- typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
- typedef itk::ImageFileReader ReaderType;
- typename ReaderType::Pointer reader = ReaderType::New();
- reader->SetFileName(mInputFilenames[0]);
- //if (mUseAnObserver) {
- //reader->AddObserver(itk::ProgressEvent(), mObserver);
- //}
- try {
- reader->Update();
- }
- catch ( itk::ExceptionObject & err ) {
- std::cerr << "Error while reading " << mInputFilenames[0].c_str()
- << " " << err << std::endl;
- std::stringstream error;
- error << err;
- mLastError = error.str();
- return;
- }
- if (mType == IMAGEWITHTIME)
- mImage=vvImageFromITK(reader->GetOutput(),true);
- else
- mImage=vvImageFromITK(reader->GetOutput());
- }
+ } else {
+ if (mInputFilenames.size() > 1) {
+ typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
+ typedef itk::ImageSeriesReader ReaderType;
+ typename ReaderType::Pointer reader = ReaderType::New();
+ for (std::vector::const_iterator i=mInputFilenames.begin(); i!=mInputFilenames.end(); i++)
+ std::cout << (*i) << std::endl;
+ reader->SetFileNames(mInputFilenames);
+ //if (mUseAnObserver) {
+ //reader->AddObserver(itk::ProgressEvent(), mObserver);
+ //}
+ try {
+ reader->Update();
+ } catch ( itk::ExceptionObject & err ) {
+ std::cerr << "Error while reading image series:" << err << std::endl;
+ std::stringstream error;
+ error << err;
+ mLastError = error.str();
+ return;
+ }
+
+ // DD(reader->GetOutput()->GetImageDimension());
+ // DD(reader->GetOutput()->GetNumberOfComponentsPerPixel());
+ // for(unsigned int i=0; i GetOutput()->GetImageDimension(); i++) {
+ // DD(reader->GetOutput()->GetSpacing()[i]);
+ // }
+
+ if (mType == IMAGEWITHTIME)
+ mImage=vvImageFromITK(reader->GetOutput(),true);
+ else
+ mImage=vvImageFromITK(reader->GetOutput());
+ } else {
+ typedef itk::Image< InputPixelType, VImageDimension > InputImageType;
+ typedef itk::ImageFileReader ReaderType;
+ typename ReaderType::Pointer reader = ReaderType::New();
+ reader->SetFileName(mInputFilenames[0]);
+ //if (mUseAnObserver) {
+ //reader->AddObserver(itk::ProgressEvent(), mObserver);
+ //}
+ try {
+ reader->Update();
+ } catch ( itk::ExceptionObject & err ) {
+ std::cerr << "Error while reading " << mInputFilenames[0].c_str()
+ << " " << err << std::endl;
+ std::stringstream error;
+ error << err;
+ mLastError = error.str();
+ return;
+ }
+
+ // DD(reader->GetOutput()->GetImageDimension());
+ // DD(reader->GetOutput()->GetNumberOfComponentsPerPixel());
+ // for(unsigned int i=0; i GetOutput()->GetImageDimension(); i++) {
+ // DD(reader->GetOutput()->GetSpacing()[i]);
+ // DD(reader->GetOutput()->GetOrigin()[i]);
+ // }
+
+
+ if (mType == IMAGEWITHTIME)
+ mImage=vvImageFromITK(reader->GetOutput(),true);
+ else
+ mImage=vvImageFromITK(reader->GetOutput());
}
+ }
}
-//====================================================================
+//----------------------------------------------------------------------------
#endif /* end #define vvImageReader_TXX */