[Insight-users] how to take into account of pixel size in saving
image
Gaetan Lehmann
gaetan.lehmann at jouy.inra.fr
Wed Nov 30 17:21:49 EST 2005
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 !
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/insight-users/attachments/20051130/92ff9eaa/attachment.pgp
More information about the Insight-users
mailing list