[Insight-users] vtk vs mhd images
Luis Ibanez
luis.ibanez at kitware.com
Tue Mar 17 19:02:01 EDT 2009
Hi David,
This is indeed strange.
It would look like the VTKImageIO class is interpreting "signed shorts"
as "unsigned shorts".
However, with the program below, I just verified that we can write
negative numbers from a "signed short" image, into a VTK file, and
obtain the correct output image.
This made suspect the next step of your pipeline.
Questions:
A) What are you using for visualizing this .vtk and .mhd images ?
B) What are you using for computing the histogram of these two images ?
and of course:
C) Is there a chance that you can post:
1) A minimal example of source code
where you observe this behavior
and
2) Could you post your .vtk and .mhd images in a public web site ?
Please let us know,
Thanks
Luis
------ VERIFICATION CODE FOR .vtk files BEGIN ------
#include "itkImage.h"
#include "itkImageFileWriter.h"
int main()
{
typedef signed short PixelType;
const unsigned int Dimension = 3;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ImageType::Pointer image = ImageType::New();
ImageType::RegionType region;
ImageType::IndexType index;
ImageType::SizeType size;
index.Fill(0);
size.Fill(100);
region.SetIndex( index );
region.SetSize( size );
image->SetRegions( region );
image->Allocate();
image->FillBuffer( -10 );
WriterType::Pointer writer = WriterType::New();
writer->SetInput( image );
writer->SetFileName( "image.vtk" );
writer->Update();
return 0;
}
------ VERIFICATION CODE FOR .vtk files END ------
-------------------
David Pastor wrote:
> Hi everyone!
>
> sorry for dumping emails in the list lately, but I'm encountering
> unexpected problems...
>
> I'm using SubtractImageFilter to get the an output image. In order to
> preserve the intensity profile I'm using a signed short image for 2
> unsigned char input images.
>
> As I don't want negative values, I get the minimum of the image (a
> negative value) and create and offset image so adding it to the output
> of SubtractImageFilter will return an image with positive values that i
> template as unsigned short to avoid problems.
>
> Well, so far so good I think. Then, i write the final image to a .mhd
> type image and the result looks as I wanted. But if I asked it to write
> a vtk image, the resulting image is far from what I expected. Instead,
> my image is satured on the high levels and is generally brighter.
>
> The histogram shows that the values have an addition offset so the
> values closer to the maximum are satured. The mhd image has a max value
> of 456 (which is consistent with something that come from unsigned char
> images), but the vtk image is beyong 60000.
>
> Any idea about this?? Please note, that the only difference is the
> format of the output image passed in the command line. Input and code
> are exactly the same.
>
> Thanks
> David
>
>
> ------------------------------------------------------------------------
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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
More information about the Insight-users
mailing list