[Insight-users] Spacing problem

Miri Trope miritrope at gmail.com
Sat Dec 31 14:39:43 EST 2011


Hi all,

The process below describes my algorithm that generates an output image that
looks spacious (output image is attached).

* note that all the input images have the same size
- manipulate on each input image the DanielssonDistanceMapImageFilt
er
- on each pixel's output image set the addition of the corresponding pixel's
value from the distance maps images

The problem is the spacing of the output image, although I maintained the
spacing at the initializing stage.

The code:

//manipulate DanielssonDistanceMapImageFilt
er on im1, im2

       typedef itk::ImageRegionIterator                <ImageType>
iteratorType;
       typedef itk::ImageRegionConstIterator   <ImageType>
constIteratorType;

       //maintain origin
       //----------------
       const ImageType::PointType& inputOrigin = im1->GetOrigin();
       double outputOrigin[ 3 ];
       for(unsigned int i=0; i< 3; i++)
       {
               outputOrigin[i] = inputOrigin[i];
       }

       //generating output Image
       //------------------------
       ImageType::Pointer outputImage = ImageType::New();
       outputImage->SetOrigin(outputOrigin);
       outputImage->SetSpacing(im1->GetSpacing());
       outputImage->SetRegions(im1->GetLargestPossibleRegion());
       outputImage->CopyInformation(im1);
       outputImage->Allocate();
       outputImage->FillBuffer(0);
       outputImage->Update();

       // generate iterators
       constIteratorType im1_iterator (im1, im1->
GetLargestPossibleRegion());
       constIteratorType im2_iterator (im2,
im2->GetLargestPossibleRegion());

       // generate writeable output iterator
       iteratorType output_iterator (outputImage,
outputImage->GetLargestPossibleRegion());

       //add values from disMap images im1 and im2 in order to set in the
output
image
       for(im1_iterator.GoToBegin(), im2_iterator.GoToBegin();
               !im1_iterator.IsAtEnd();
           im1_iterator ++, im2_iterator ++, output_iterator ++)
       {
               outputPix_value = im1_iterator.Get() + im2_iterator.Get();
               //set this pixel to outputImage
               output_iterator.Set(outputPix_value);
       }//for
       outputImage->Update();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111231/6dd20011/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Spacious.JPG
Type: image/jpeg
Size: 14854 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111231/6dd20011/attachment.jpeg>


More information about the Insight-users mailing list