[Insight-users] Spacing problem

Cagatay Bilgin bilgincc at gmail.com
Wed Oct 24 20:54:34 EDT 2012


Not sure if this is related but try setting the spacing and orientation
after you allocate the image.

Cagatay

On Wed, Oct 24, 2012 at 3:06 PM, Wolfram Timm <comail at mac.com> wrote:

> Hi,
>
> I don't get the background of this problem:
>
> Inside a DLL I am trying to create a 3D ITK image of type unsigned short.
> This works (filewriter successful), when spacing is 1.0 for each dimension.
> Inside the DLL I get an Access Violation even preventing throwing the
> exception when choosing a different spacing like 0.2, 0.2, 2.0 (yes, awful
> anisotropy). This is independent of the use of ITKImportFilter or creating
> just an ITK image.
>
> Here's the relevant code (afaik):
>
> typedef unsigned short PixelType;
> typedef itk::Image< PixelType, 3 > ImageType;
>
>   ImageType::Pointer img = ImageType::New();
>
>   ImageType::SizeType size;
>   size[0] = 512;
>   size[1] = 512;
>   size[2] = 86;
>
>   ImageType::IndexType start;
>   start.Fill(0);
>
>   ImageType::RegionType region;
>   region.SetIndex(start);
>   region.SetSize(size);
>
>   img->SetRegions(region);
>
>   double origin[3];
>   origin[0] = 0.0;
>   origin[1] = 0.0;
>   origin[2] = 0.0;
>   img->SetOrigin(origin);
>
>   ImportImageFilterType::SpacingType spacing;
>   spacing[0] = 0.2;
>   spacing[1] = 0.2;
>   spacing[2] = 2.0;
>   img->SetSpacing(spacing);
>
>   try
>       {
>       log("img pre Allocate()");
>       img->Allocate();
>       log("img pos Allocate()");
>   }
>   catch( itk::ExceptionObject & exp )
>   {
>       log("Exception caught !");
>       log((string)exp.GetDescription());
>   }
>
>   WriterType::Pointer writer = WriterType::New();
>
>   writer->SetFileName("d:\\temp\\i.tif");
>
>   writer->SetInput(img);
>
>   try
>   {
>       writer->Update();
>   }
>   catch( itk::ExceptionObject & exp )
>   {
>       log("Exception caught !");
>       log((string)exp.GetDescription());
>   }
>
>
> Any help really is appreciated, since I don't get the problem here.
>
> Thanks.
> Wolfram
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> 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
>



-- 
Cemal Cagatay Bilgin
Life Sciences Division
Lawrence Berkeley National Lab
MS977, One Cyclotron Road
Berkeley, CA 94720, USA
Email: ccbilgin at lbl.gov <hchang at lbl.gov>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20121024/cd5e1b9b/attachment.htm>


More information about the Insight-users mailing list