[Insight-users] Two Basic Image Accessing Questions

Luis Ibanez luis.ibanez at kitware.com
Thu, 19 Feb 2004 00:07:55 -0500


Hi Sah,

1) If this image is the output of an ITK filter,
    it is safe to use GetBufferPointer() for READING
    but is is NOT SAFE to use it for WRITTING.

    If this is an image that you allocated by yourself,
    then you could use the buffer pointer for reading
    and writing.  Note that this is not the best way
    to access image data in ITK. You should rather use
    ImageIterators.

    Iterators are managing the complexity of N-Dimensional
    images for you.  They give you information about the
    index position of every visited pixel. They can take
    care of visiting the image in particular orders.

    Please use Iterators, unless you really, really,
    know what you are doing.


2) LargestPossibleRegion is NOT necessarily available
    after you call Update(). You should only use the
    BufferedRegion().  If you need the largest possible
    region to be available you call the method...

          UpdateLargestPossibleRegion()


3) When you call Allocate() yourself, Yes, the
    LargestPossibleRegion becomes available.


An easy way to verify what regions are available
is for you to invoke the Print() method of the image


    image->Print( std::cout );


It will show you all the member variables of the
image, including the three regions:

   -LargestPossible
   -Buffered
   -Requested

as well as data such as spacing and origin.


The only reason for using pointers to the buffer is
when you are interfacing ITK with other packages that
are not ITK-fied.



Regards,



    Luis



------------------
Sah Rayman wrote:

> hello, I have some questions (again).
> 
> 1. Is it safe to use itk::Image::GetBufferPointer()
> 
> then use that pointer to read/write image data?
> 
> If yes, then what's the benifit of using iterator?  
> Make coding easier and more readable? Directly using
> pointer would be the most efficient and easy, right?
> 
> 2. Is LargestPossibleRegion available when Update() is
> just called?
> 
> I want to visit every pixel after some itk image
> filter is just updated. Is LargestPossibleRegion
> automatically available? If not, how can I make
> everything in buffer?
> 
> 3. Is LargestPossibleRegion available when allocate()
> is just called? 
> I am creating my own image. The size, spacing and
> origin are set. Then I call allocate(). Is every pixel
> in LargestPossibleRegion available to write at this
> time? If not, how can I make everything in buffer?
> 
> 
> Many thanks.
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance: Get your refund fast by filing online.
> http://taxes.yahoo.com/filing.html
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>