[Insight-users] Random acess pixels using iterators

Fucang Jia jiafucang@hotmail.com
Sun, 20 Apr 2003 23:34:19 +0800


Hi Luis,

I am working on 3D medical image, and want to process a port of image 
region, not a pixel data. For example I want to process the fourth slice 
image, I want to setup image iterator to begin with { size[0],size[1],3 }. 
So I want to use

unsigned long offset=size[0]*size[1]*3;
ImageIteratorType it(image,image->GetRequestedRegion());
it+=offset;
or
it.SetPosition(offset);

I can use
it.GoToBegin();
for(unsigned long i=0;i<offset;i++)++it;

But I think this is not very effective.

I can use itkExtractImage, but it need more memory.
So I think there need a member function to implement
SetPosition(offset). Is that right?

Thanks!

Fucang

>From: Luis Ibanez <luis.ibanez@kitware.com>
>To: Fucang Jia <jiafucang@hotmail.com>
>CC: insight-users@public.kitware.com
>Subject: Re: [Insight-users] Random acess pixels using iterators
>Date: Sun, 20 Apr 2003 10:28:35 -0400
>
>
>Hi Fucang,
>
>ImageIterators are designed as a fast way of
>getting access to image data. Their speed derives
>from the knowledge of a particular strategy for
>visiting all the pixels.
>
>If you need to access isolated pixels in the
>image, all the advantages of iterators are lost.
>In that case you can simply use the itk::Image
>methods
>
>       -  SetPixel()
>       -  GetPixel()
>
>Note however that this two methods are *very*
>slow. So you may not want to use them for a
>massive access to pixel data.
>
>Could you give us more details on the type of
>access you need to perform ?
>
>There may be already an ITK iterator for the
>process you want to perform...
>
>
>Thanks
>
>
>   Luis
>
>
>--------------
>
>Fucang Jia wrote:
>>Hi Luis, hi everyone,
>>
>>I want to access pixel data from an offset with itkImageRegionIterator 
>>iterator, not from begin. But I have not find the member function 
>>implement operator+=Offset, operator-=Offset, or 
>>operator.SetPosition(OffsetIndex). The software guide does describe the 
>>function. Are these function purposely not implemented, or I am wrong at 
>>the point?
>>
>>Thank you!
>>
>>Fucang
>>
>>
>>
>


_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail