[Insight-users] how to take into account of pixel size in saving image

Sylvain Jaume sylvain.jaume at kitware.com
Thu Dec 1 10:19:02 EST 2005


Hi Isabelle,

Have you tried Meta image format?

Best,
Sylvain

Renaud Isabelle wrote:

> Hi,
>  
> I read the chapter about image formats in the software guide. However, 
> it doesn't say what image format are taking into account the pixel 
> size. i tried with BMP,PNG,JPEG, no one is working!!.
>  
> ISabelle
>
> */Gaetan Lehmann <gaetan.lehmann at jouy.inra.fr>/* a écrit :
>
>
>     Hi Isabelle,
>
>     You should try to resample your image with the resample image
>     filters or use
>     an image format which store spacing.
>     There is a chapter about that in the insight software guide.
>
>     Regards,
>
>     Gaetan
>
>
>     On Wednesday 30 November 2005 23:04, Renaud Isabelle wrote:
>     > 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 !
>
>
> ------------------------------------------------------------------------
> *Appel audio GRATUIT partout dans le monde* avec le nouveau Yahoo! 
> Messenger
> Téléchargez le ici ! 
> <http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com> 
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>  
>


More information about the Insight-users mailing list