[Insight-users] pointer to image data

Julien Lamy lamy at unistra.fr
Tue Jul 19 01:55:24 EDT 2011


Le 19/07/11 01:43, barbababa a écrit :
> Hi!
>
> Thanks for the reply!
>
> But  is there no other way than pixel by pixel? Is there a way to cast
> float* to itk::image<float,2>?
>
> error C2440: 'type cast' : cannot convert from 'float *' to 'class
> itk::Image<float,2>'
>
> It could be i am missing the basics here.
> But would it be possible to just to define a itk image pointer (raw or
> smart) to the already allocated data and not to allocate new data for itk
> image for input to some filter?

Hi,
The triple "for" loop in the example is just to fill the buffer with 
something meaningful. Once you have your float *img_data, just use it as 
input to itk::ImportImageFilter, update it, and its output will be an 
ITK image containing img_data as its pixels. Using a cast will not be 
possible, since no constructor of itk::Image is public.

HTH,
-- 
Julien


More information about the Insight-users mailing list