[Insight-developers] Random Access into an image

Stephen R. Aylward aylward@unc.edu
Sun, 11 May 2003 15:14:35 -0400


It is sometimes necessary to access images using an index, e.g., if you 
method does a random walk thru an image.   If you know that you are 
going to access a 3D image using an index, you can create a table that 
points into the image - the table is a 2D table that is accessed using 
the z and y index coordinates - you merely need to add the x index 
coordinate to the table lookup value to access a pixel.   I think this 
is one of the fast ways to do index access into a 3D image (Luis 
promoted it while he was at UNC).    I wrote a 
3DRandomAccessImageAdaptor that uses such a table to speed the access 
into an itkImage<3, x>.  I compared its speed with that of accessing an 
image using an index via the IteratorWithIndex iterator.

Index access into an image using IteratorWithIndex (seconds)
	Single Processor: 7.4
	Dual Processor:   4.8
Index access into an image using 3DRandomAccessImageAdaptor (seconds)
	Single Processor: 6.2
	Dual Processor:   3.9

So, if you have a 3D image from which you want to access pixels using an 
index, using a table lookup on yz offers a ~17% speed increase.

Do we want such specialized adaptors in the toolkit?  I haven't checked 
it in yet.

Stephen


-- 
===============================================
Dr. Stephen R. Aylward
Assistant Professor of Radiology
Adjunct Assistant Professor of Computer Science
http://caddlab.rad.unc.edu
aylward@unc.edu
(919) 966-9695