[Insight-developers] Odd filter/writer behavior
Michael Stauffer
mstauff at verizon.net
Mon Oct 25 14:45:57 EDT 2010
Mac OSX 10.5.8
GCC 4.0.1
ITK 3.20
Hi,
I'm seeing odd behavior with a simple filter I made. The filter simply moidifies the Direction and Origin members of an input image and returns a new image.
The printing the new image's modified Direction to stdout shows the correct values. But when I then write to a new image file, the modified Direction and Origin values only show up if the filter had been instantiated and used within a code block. I've attached source files for the filter and test, and included the relevant source snippet below.
Note that in the second case, outputImage2->GetDirection() prints with correct values, but the files that's subsequently written does not. Seems very odd. I see the same behavior in another test program.
Anyone have any ideas?
source:
typedef itk::ComposeAffineTransformWithHeaderTransformImageFilter<ImageType,TransformType > ComposeFilterType;
/////////////////////////////////////////////////////////////////////////
std::cout << "test2DHeader... filter code in block..." << std::endl;
{ //This works when bracketed
// Apply transform - this filter applies its inverse
ComposeFilterType::Pointer composeFilter = ComposeFilterType::New();
composeFilter->SetInput( inputImage );
composeFilter->SetTransform( transform );
composeFilter->Update();
// Create output
outputImage1 = composeFilter->GetOutput();
}
std::cout << "test2DHeader... outputImage1.Direction: " << std::endl;
std::cout << outputImage1->GetDirection() << std::endl;
// write it out
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer1 = WriterType::New();
writer1->SetFileName( "testBlock_"+outputfilename );
writer1->SetInput( outputImage1 );
writer1->Update();
/////////////////////////////////////////////////////////////////////////
std::cout << "test2DHeader... filter code WITHOUT block..." << std::endl;
// Apply transform - this filter applies its inverse
ComposeFilterType::Pointer composeFilter = ComposeFilterType::New();
composeFilter->SetInput( inputImage );
composeFilter->SetTransform( transform );
composeFilter->Update();
// Create output
outputImage2 = composeFilter->GetOutput();
std::cout << "test2DHeader... outputImage2.Direction: " << std::endl;
std::cout << outputImage2->GetDirection() << std::endl;
// write it out
//typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer writer2 = WriterType::New();
writer2->SetFileName( "testNoBlock_"+outputfilename );
writer2->SetInput( outputImage2 );
writer2->Update();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HeaderWriteProblem.zip
Type: application/octet-stream
Size: 5951 bytes
Desc: not available
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101025/bf97d831/attachment.obj>
More information about the Insight-developers
mailing list