[Insight-users] some questions in Getting Started V: Integrating
ITK in your Application
Luis Ibanez
luis.ibanez at kitware.com
Tue Aug 29 13:06:34 EDT 2006
Hi Yixun,
1) When receiving ImageType as arguments it is fine to just have
raw pointers, since we assume that the original images are
pointed to by a SmartPointer in the caller code and therefore
there is no fear of this image disappearing while the function
is working.
However, as you pointed out, it will be even safer to pass
a SmartPointer as argument. Note that what you want to pass
is not
const ImageType::Pointer p
but
const ImageType::ConstPointer & p
2) There is a speed penalty in using Iterators. Most of the
time it is negligeable compared to the rest of operations
performed in a typical application.
If you are going to recur to a raw pointer copying then,
you better go for the full replacement and use memcpy().
That will give you the fastest performance.
BTW: Did you actually measure the difference in computation
time between the two methods ?
How much was it ? (let us know the image size too)
Regards,
Luis
------------------
Yixun Liu wrote:
> Hi,
>
> I have two questions in Getting Started V: Integrating ITK in your
> Application.
>
> 1. about the parameter type of data transfer function void(const
> ImageType * image, ...).
> Why not using const ImageType::Pointer? In my opinion, using ImageType*
> as parameter cannot correctly reference count. Return type can be
> ImageType * or ImageType::Pointer becaues it is assigned to a
> ImgaeType::Pointer, it can be correctly reference count.
>
> 2. about Iterator
> I think copying c++ buffer to itk::Image or inverse using iterator is
> with low efficiency.
>
> ...
> IteratorTypeit( image, region);
> it.GoToBegin();
> const char * data= buffer;
> while( ! it.IsAtEnd() )
> {
> *data= it.Get();
> ++it;
> ++data;
> }
> ...
>
> If chage the above codes to the followed, program can run fast.
>
> ...
> char* dataSource = image->GetBufferPointer()
> const char * data= buffer;
> for(i = 0; i < totalNum; i++)
> {
> data[i] = dataSource[i]
>
> }
> ...
>
> Cheers,
>
> Yixun Liu
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list