[Insight-users] Format Image in ITK

Andreas Schuh andreas.schuh.84 at googlemail.com
Fri Jul 3 21:11:35 EDT 2009


Hi Elena,

you might be interested in reading the basics of filters and data  
representation in ITK in the itkSoftwareGuide.

Image filters take input images and produce output images (well,  
sources have no inputs and mappers/sinks no outputs). Images are the  
data structures. An image can either be created manually, filled with  
proper values and then passed to a filter as input or it is an output  
of another filter and then set as input of a consecutive filter. Thus,  
SetInput() and GetOutput() are methods of filters but clearly not of  
images.

To connect two filters, do something like

filter2->SetInput( filter1->GetOutput() );

or to set a manually created image as input of a filter

filter->SetInput( image );

To get the output image, just call

image = filter->GetOutput();


As it seems that you have your image data in a continuous C array, you  
should consider using the itk::ImportImageFilter. This filter gives  
you as output the appropriate itk::Image, where no copying of the  
pixel data is necessary.

Then set the output of this filter as input of the  
itk::ConnectedThresholdImageFilter.

To get the output image use just the following code

OutputImage = filter->GetOutput();

--
regards
Andreas

On Jul 3, 2009, at 8:18 PM, Elena Molina <elenam85 at gmail.com> wrote:

> Hi,
>  I´m trying to apply the algorithm "connected threshold" in my image 
> . I have this error:
>
> RegionGrowing.cc(75) : error C2039: 'GetOutput' : is not a member of  
> 'Image<float,3>'
> RegionGrowing.cc(76) : error C2039: 'SetInput' : is not a member of  
> 'Image<float,3>'
>
> My code is:
>
>
>
>     int x = volSize[0];
>     int y = volSize[1];
>     int z = volSize[2];
>
>     vector<float> res = volSize.mm;
>
>     float dx = res[0];
>     float dy = res[0];
>     float dz = res[0];
>
>     typedef itk::Image<float,3>  ImageType;
>     ImageType::Pointer InputImage = ImageType::New();
>     ImageType::Pointer OutputImage = ImageType::New();
>
>     ImageType::SizeType size;
>     size[0] = x;
>     size[1] = y;
>     size[2] = z;
>
>     ImageType::IndexType start;
>     start[0] = 0;
>     start[1] = 0;
>     start[2] = 0;
>
>     ImageType::RegionType region;
>     region.SetSize( size );
>     region.SetIndex( start );
>
>     InputImage->SetRegions( region);
>     InputImage->Allocate();
>
>     float spacing[3];
>     spacing[0] = res[0];
>     spacing[1] = res[1];
>     spacing[2] = res[2];
>
>     InputImage->SetSpacing(
> spacing);
>
>     typedef itk::ImageRegionIterator<ImageType> IteratorType;
>     IteratorType it(InputImage, region);
>
>     const float *data=subdata;
>     it.GoToBegin();
>     while(!it.IsAtEnd())
>     {
>         it.Set (*data);
>         ++it;
>         ++data;
>     }
>
>
>     typedef itk::ConnectedThresholdImageFilter<ImageType,ImageType>  
> FilterType;
>     FilterType::Pointer filter = FilterType::New();
>
>     filter->SetInput(InputImage->GetOutput());
>     OutputImage->SetInput(filter->GetOutput());
>
>
>    How can I resolve it?
>
> Regards,
> Elena
>
>
> 2009/7/3 Elena Molina <elenam85 at gmail.com>
> Hi,
> First of all, I´m working with DICOM images in an already programmed 
>  (C++) application. Now I want to introduce
> new features in this application and I´ll use ITK libraries.
> So... my problem now is how can I convert my image (actually I have  
> my image in memory (3D) and I have the
> pointer to the first position of this image) in a compliant format  
> for using it with ITK functions.
> I was reading in the getting started V how can I integrating ITK in  
> my application and tried to do the same example but It
> didn´t work.
> How can I do it? Which parameters I need? Pointer in the first  
> position, size... any more?
>
> Thankssssss
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090703/69b2db99/attachment.htm>


More information about the Insight-users mailing list