[Insight-users] how to take into account of pixel size in saving
image
Renaud Isabelle
renauisa at yahoo.fr
Wed Nov 30 17:04:49 EST 2005
Hi,
I have to save an image of 55*239 pixels with spacing as 0.1496*0.01925.
This seems to be easy. However, the image saved is not taking into account my pixel size but just the number of my pixels.
ImageType::IndexType start;
start.Fill(0);
ImageType::SizeType sz;
sz[0] = 239;
sz[1] = 55;
ImageType::RegionType region;
region.SetSize( sz );
region.SetIndex( start );
ImageType::Pointer shifty = ImageType::New();
shifty->SetRegions( region );
shifty->Allocate();
ImageType::SpacingType spacing ;
spacing[0] = 0.01925;
spacing[1] = 0.1496;
shifty->SetSpacing( spacing );
//compute shifty somehow
typedef itk::RescaleIntensityImageFilter<
ImageType, WriteImageType > RescaleFilterType;
RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
rescaler->SetOutputMinimum( 0 );
rescaler->SetOutputMaximum( 255 );
rescaler->SetInput( shifty );
typedef itk::ImageFileWriter< WriteImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("shifty.jpg");
writer->SetInput( rescaler->GetOutput() );
writer->Update();
By taking into account the pixel size, the saved image should be almost twice heigher than large. However, taking into account only the number of pixels, my saved image is 4 times larger than heigh.
This is a medical image so my pixel size is very important to be aware of the physical dimensions of the image.
Isabelle
---------------------------------
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20051130/519c54b5/attachment.htm
More information about the Insight-users
mailing list