[Insight-developers] itkImageFileWriter

Luis Ibanez luis.ibanez at kitware.com
Fri Jun 17 13:14:20 EDT 2005


Leila,

Also... if your image is the output of a filter,
you *should not* change manually the origin and
spacing. It is only up to the filter to set this
values.

This is unfortunately a weak point in the ITK
support for const-correctness. The output returned
by ITK filters should have been declared *const*.

It is unfortunate that we missed the oportunity
for making this safe and consistent at the level
of GetOutput().

If you really need to change the origin, then
you should use the "ChangeInformationImageFilter".


    Regards,


       Luis


------------------------
Karthik Krishnan wrote:
> 
> 
> Leila baghdadi wrote:
> 
>> Hi guys,
>>
>> I just noticed something weird!
>>
>> I created an image and set the origin of my image before I used
>> itkImageFileWriter to write it but then it changes the origin
>>
>> the this the code that I have
>>
>>  size[0] = 300;
>>  size[1] = 270;
>>  size[2] = 270;
>>
>>  m_TriangleToImage->SetSize(size);
>>  float origin[3];
>>  
>>  
>>  origin[0] = -14.95;
>>  origin[0] = -13.45;
>>  
>>
> BUG... origin[1] :)  
> 
>>  origin[2] = -13.45;
>>
>>  m_TriangleToImage->SetOrigin(origin);
>>  float spacing[3];
>>  spacing[0] = 1;
>>  spacing[1] = 1;
>>  spacing[2] = 1;
>>
>>  m_TriangleToImage->SetSpacing(spacing);
>>
>>  m_TriangleToImage->Update();
>>
>>  m_ImageWriter->SetInput(m_TriangleToImage->GetOutput() );
>>  m_ImageWriter->SetFileName("myimage.mhd");
>>  m_ImageWriter->UseInputMetaDataDictionaryOn();
>>  m_ImageWriter->Update();
>>  
>>
>> and then if I look at the .mhd file
>>
>>
>> ObjectType = Image
>> NDims = 3
>> BinaryData = True
>> BinaryDataByteOrderMSB = False
>> TransformMatrix = 1 0 0 0 1 0 0 0 1
>> Offset = -13.45 5.60519e-44 -13.45
>> CenterOfRotation = 0 0 0
>> ElementSpacing = 1 1 1
>> DimSize = 300 270 270
>> AnatomicalOrientation = ???
>> ElementType = MET_UCHAR
>> ElementDataFile = myimage.raw
>>
>>
>> also how does ordering of data come into effect with these classes, it
>> is always xyz??
>>
>> Thanks for your time
>>
>>
>> Leila
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>>  
>>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
> 
> 





More information about the Insight-developers mailing list