X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FvvImageReader.txx;h=551e42626ba7313a84bb687f2fe8322c78d93962;hb=1dfeba065d7121eb27aa44a792095af817652683;hp=9b0e21ae6c17f8fd498008272c53fa84a9aaaa5c;hpb=2191f760d44987f901445c4105c577df7995b25d;p=clitk.git diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index 9b0e21a..551e426 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -61,7 +60,7 @@ void vvImageReader::UpdateWithDim(std::string InputPixelType) else std::cerr << "Error, input pixel type : " << InputPixelType << " unknown !" << std::endl; - if (CLITK_EXPERIMENTAL && mLastError.size()==0) { + if (mLastError.size()==0) { //ReadNkiImageTransform(); ReadMatImageTransform(); } @@ -73,8 +72,6 @@ void vvImageReader::UpdateWithDim(std::string InputPixelType) template void vvImageReader::UpdateWithDimAndInputPixelType() { - itk::AnalyzeImageIO *analyzeImageIO = NULL; - if (mType == MERGEDWITHTIME) // In this case we can load the images // one at the time to avoid excessive // memory use @@ -89,6 +86,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType() reader->SetFileName(*i); try { mImage->AddItkImage(reader->GetOutput()); + mImage->ComputeScalarRangeBase(reader->GetOutput()); } catch ( itk::ExceptionObject & err ) { std::cerr << "Error while reading " << mInputFilenames[0].c_str() << " " << err << std::endl; @@ -97,7 +95,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() mLastError = error.str(); return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } } else if (mType == SLICED) { mImage=vvImage::New(); @@ -124,17 +121,15 @@ void vvImageReader::UpdateWithDimAndInputPixelType() filter->SetExtractionRegion(extractedRegion); filter->SetInput(reader->GetOutput()); filter->ReleaseDataFlagOn(); -#if ITK_VERSION_MAJOR == 4 filter->SetDirectionCollapseToSubmatrix(); -#endif try { mImage->AddItkImage(filter->GetOutput()); + mImage->ComputeScalarRangeBase(filter->GetOutput()); } catch ( itk::ExceptionObject & err ) { std::cerr << "Error while slicing " << mInputFilenames[0].c_str() << "(slice #" << mSlice << ") " << err << std::endl; return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } else { if (mInputFilenames.size() > 1) { typedef itk::Image< InputPixelType, VImageDimension > InputImageType; @@ -177,23 +172,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() mLastError = error.str(); return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); - } - } - - // For unknown analyze orientations, we set identity - if(analyzeImageIO) { - const double m[16] = {1.,0.,0.,0., - 0.,0.,1.,0., - 0.,-1.,0.,0., - 0.,0.,0.,1.}; - // TODO SR and BP: check on the list of transforms and not the first only - int i; - for(i=0; i<16 && m[i]==mImage->GetTransform()[0]->GetMatrix()->GetElement(i%4, i/4); i++); - if(i==16) { - itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " - << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()[0]->Identity(); } } } @@ -203,8 +181,6 @@ void vvImageReader::UpdateWithDimAndInputPixelType() template void vvImageReader::UpdateWithDimAndInputVectorPixelType() { - itk::AnalyzeImageIO *analyzeImageIO = NULL; - typedef itk::Image< InputPixelType, VImageDimension > InputImageType; typename InputImageType::Pointer input; @@ -239,7 +215,6 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() mLastError = error.str(); return; } - analyzeImageIO = dynamic_cast( reader->GetImageIO() ); } typedef itk::Image< itk::Vector, VImageDimension > VectorImageType; @@ -251,24 +226,6 @@ void vvImageReader::UpdateWithDimAndInputVectorPixelType() casted_input = caster->GetOutput(); mImage = vvImageFromITK >(casted_input, mType == IMAGEWITHTIME || mType == VECTORFIELDWITHTIME); - - // For unknown analyze orientations, we set identity - if (analyzeImageIO) - { - const double m[16] = {1.,0.,0.,0., - 0.,0.,1.,0., - 0.,-1.,0.,0., - 0.,0.,0.,1.}; - int i; - for (i = 0; i < 16 && m[i] == mImage->GetTransform()[0]->GetMatrix()->GetElement(i % 4, i / 4); i++) - ; - if (i == 16) - { - itkWarningMacro(<< "Analyze image file format detected with unknown orientation. " - << "Forcing identity orientation, use other file format if not ok."); - mImage->GetTransform()[0]->Identity(); - } - } } //----------------------------------------------------------------------------