[Insight-users] CastImageFilter Error
Ariel Hernán Curiale
curiale at gmail.com
Wed Jul 11 03:38:30 EDT 2012
Thanks all for your quickly response.
I use gcc-4.2 (llvm-gcc-4.2) and the code is this:
const unsigned int Dimension = 2;
/*The files' names*/
std::string imageFixedName = argv[1];
std::string imageMovingName = argv[2];
std::string imageOutputName = argv[3];
size_t ext_pos = imageOutputName.find_last_of( '.' );
std::string ext( imageOutputName, ext_pos );
typedef unsigned char OutputPixelType;
typedef double PixelType;
typedef float InternalPixelType;
typedef itk::Image < InternalPixelType, Dimension > InternalImageType;
InternalImageType::Pointer CertaintyImage;
InternalImageType::Pointer InternalMovingImage;
typedef itk::Vector< float, Dimension > VectorPixelType;
typedef itk::Image < VectorPixelType, Dimension > DeformationFieldType;
typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
typedef itk::Image < PixelType, Dimension > FixedImageType;
typedef itk::Image < PixelType, Dimension > MovingImageType;
typedef itk::ImageFileReader < FixedImageType > FixedImageReaderType;
FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
fixedImageReader->SetFileName( imageFixedName );
try{
fixedImageReader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
typedef itk::ImageFileReader < MovingImageType > MovingImageReaderType;
MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
movingImageReader->SetFileName( imageMovingName );
try
{
movingImageReader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
MovingImageType::Pointer movingImage = movingImageReader->GetOutput();
std::cout<< movingImage<<std::endl;
typedef itk::CastImageFilter < MovingImageType, InternalImageType > MovingCasterType;
MovingCasterType::Pointer movingImageCaster = MovingCasterType::New();
movingImageCaster->SetInput( movingImageReader->GetOutput() );
std::cout<<"0"<<std::endl;
try
{
movingImageCaster->Update();
}
catch( itk::ExceptionObject & err )
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return -1;
}
std::cout<<"1"<<std::endl;
The movingImageReader->GetOutput() is
>> Image (0x7fc201cda600)
>> RTTI typeinfo: itk::Image<double, 2u>
>> Reference Count: 3
>> Modified Time: 307
>> Debug: Off
>> Observers:
>> none
>> Source: (0x7fc201cde1f0)
>> Source output index: 0
>> Release Data: Off
>> Data Released: False
>> Global Release Data: Off
>> PipelineMTime: 179
>> UpdateMTime: 308
>> LargestPossibleRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> BufferedRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> RequestedRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> Spacing: [1, 1]
>> Origin: [0, 0]
>> Direction:
>> 1 0
>> 0 1
>>
>> IndexToPointMatrix:
>> 1 0
>> 0 1
>>
>> PointToIndexMatrix:
>> 1 0
>> 0 1
>>
>> PixelContainer:
>> ImportImageContainer (0x7fc201cde360)
>> RTTI typeinfo: itk::ImportImageContainer<unsigned long, double>
>> Reference Count: 1
>> Modified Time: 306
>> Debug: Off
>> Observers:
>> none
>> Pointer: 0x108d15000
>> Container manages memory: true
>> Size: 480000
>> Capacity: 480000
Thanks,
__________________________________
| Ariel Hernán Curiale
| ETSI Telecomunicación
| Universidad de Valladolid
| Campus Miguel Delibes
| 47011 Valladolid, Spain
| Phone: 983-423000 ext. 5590
| Web: www.curiale.com.ar
|_________________________________
El 10/07/2012, a las 20:27, Bradley Lowekamp escribió:
> What compiler are you using? Have you tried gcc-4.2 instead of clang? I don't think that 3.20 would have been tested and build with the new clang.
>
> Brad
>
> On Jul 10, 2012, at 12:43 PM, ariel wrote:
>
>> Hi,
>>
>> I've had some troubles after xcode update (from 4.1 to 4.3.3).
>>
>> When I compiled ITK-3.20.1 I had too many warnings like this:
>> InsightToolkit-3.20.1/Utilities/vxl/core/vnl/vnl_math.h:86:36: warning:
>> in-class initializer for static data member of type 'const double' is a GNU
>> extension [-Wgnu] static VNL_DLL_DATA const double e
>> VCL_STATIC_CONST_INIT_FLOAT_DECL(2.7182818284590452354);
>>
>>
>>
>> Second, I made a simple program and I can't explain why this code exit with
>> segmentation fault:
>>
>> typedef itk::CastImageFilter < MovingImageType, InternalImageType >
>> MovingCasterType;
>> MovingCasterType::Pointer movingImageCaster =
>> MovingCasterType::New();
>> movingImageCaster->SetInput( movingImageReader->GetOutput() );
>>
>>
>> std::cout<<"0"<<std::endl;
>> try
>> {
>> movingImageCaster->Update();
>> }
>> catch( itk::ExceptionObject & err )
>> {
>> std::cout << "ExceptionObject caught !" << std::endl;
>> std::cout << err << std::endl;
>> return -1;
>> }
>>
>>
>>
>> The input of the caster filter is:
>>
>> Image (0x7fc201cda600)
>> RTTI typeinfo: itk::Image<double, 2u>
>> Reference Count: 3
>> Modified Time: 307
>> Debug: Off
>> Observers:
>> none
>> Source: (0x7fc201cde1f0)
>> Source output index: 0
>> Release Data: Off
>> Data Released: False
>> Global Release Data: Off
>> PipelineMTime: 179
>> UpdateMTime: 308
>> LargestPossibleRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> BufferedRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> RequestedRegion:
>> Dimension: 2
>> Index: [0, 0]
>> Size: [800, 600]
>> Spacing: [1, 1]
>> Origin: [0, 0]
>> Direction:
>> 1 0
>> 0 1
>>
>> IndexToPointMatrix:
>> 1 0
>> 0 1
>>
>> PointToIndexMatrix:
>> 1 0
>> 0 1
>>
>> PixelContainer:
>> ImportImageContainer (0x7fc201cde360)
>> RTTI typeinfo: itk::ImportImageContainer<unsigned long, double>
>> Reference Count: 1
>> Modified Time: 306
>> Debug: Off
>> Observers:
>> none
>> Pointer: 0x108d15000
>> Container manages memory: true
>> Size: 480000
>> Capacity: 480000
>>
>>
>> Thanks,
>> Ariel.
>>
>> --
>> View this message in context: http://itk-insight-users.2283740.n2.nabble.com/CastImageFilter-Error-tp7580458.html
>> Sent from the ITK Insight Users mailing list archive at Nabble.com.
>> _____________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Kitware offers ITK Training Courses, for more information visit:
>> http://www.kitware.com/products/protraining.php
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>
> ========================================================
> Bradley Lowekamp
> Medical Science and Computing for
> Office of High Performance Computing and Communications
> National Library of Medicine
> blowekamp at mail.nih.gov
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120711/7543a4fc/attachment-0001.htm>
More information about the Insight-users
mailing list