[Insight-users] Add SpatialObject To Image

Chris Turner cturnercomplex at googlemail.com
Wed Aug 11 16:18:45 EDT 2010


After a little more investigation it showed that
SpatialObjectToImageFilter produces an empty picture so the error has
to be somewhere here:

typedef itk::SpatialObjectToImageFilter<LineType, OutputImageType>
SpatialObjectToImageFilterType;
SpatialObjectToImageFilterType::Pointer imageFilter =
SpatialObjectToImageFilterType::New();

imageFilter->SetInput(Line);
imageFilter->SetSize( size  );  // from the image
imageFilter->SetSpacing( spacing ); // from the image
imageFilter->Update();


Also the image of the SpatialObjectToImageFilter is 250mb large while
the input image is only 512kb large.

Anybody knows where the problem is?

Thanks
Chris

On Wed, Aug 11, 2010 at 1:03 PM, Chris Turner
<cturnercomplex at googlemail.com> wrote:
> okay the problem with the white image was because of:
>
> const OutputPixelType airHounsfieldUnits  = -1000;
>
> I put it to 0 now the output image is the same as the input image.
> Means: I can't see the line.
>
> Any idea?
>
> Thanks Chris
>
> On Wed, Aug 11, 2010 at 10:06 AM, Chris Turner
> <cturnercomplex at googlemail.com> wrote:
>> Hi everyone,
>>
>> I'm having trouble adding a spatial object (a line) to an image. The
>> problem is that the resulting image is completely white (BG: 64536).
>>
>> I generate the line like it's done in the itk user guide. And this is
>> how I add an image with that line
>>
>> typedef itk::SpatialObjectToImageFilter<LineType, OutputImageType>
>> SpatialObjectToImageFilterType;
>> SpatialObjectToImageFilterType::Pointer imageFilter =
>> SpatialObjectToImageFilterType::New();
>>
>> imageFilter->SetInput(Line);
>> imageFilter->SetSize( size  );  // from the image
>> imageFilter->SetSpacing( spacing ); // from the image
>> imageFilter->Update();
>>
>> typedef itk::AddImageFilter<OutputImageType,OutputImageType,
>> OutputImageType > AddFilterType;
>> AddFilterType::Pointer addFilter = AddFilterType::New();
>> addFilter->SetInput1( itkImporter->GetOutput() ); //the image
>> addFilter->SetInput2( imageFilter->GetOutput() ); // the line
>>
>> const OutputPixelType airHounsfieldUnits  = -1000;
>> const OutputPixelType boneHounsfieldUnits =   800;
>>
>> Line->SetDefaultInsideValue(   boneHounsfieldUnits );
>> Line->SetDefaultOutsideValue( airHounsfieldUnits );
>>
>> imageFilter->SetUseObjectValue( true );
>> imageFilter->SetOutsideValue( airHounsfieldUnits );
>>
>> save addFilter->GetOutput() to file. The size and origin of the image
>> is correct but it's just white....
>>
>> Anybody knows what I'm doing wrong?
>>
>>
>> Thanks,
>> Chris
>>
>


More information about the Insight-users mailing list