|
Re: solutions for the nearest neighbour problem in IDL [message #15801 is a reply to message #15737] |
Fri, 11 June 1999 00:00  |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
Uwe Nolte wrote:
>
> Hi,
> does anyone know if, there are solutions for the
> nearest neighbour problem in IDL?
>
> Many thanks in advance.
>
> with kind regards,
>
> Uwe Nolte
Uwe -
The easiest way to use nearest-neighbor sampling is to compute and/or
transform your coordinates first, and then use them to index your
original data, using the ROUND() function to give you the "nearest
neighbors". An example of this is the following:
slice[*] = volume[0 > round(vol_ind[*,0]) < (xdim-1), $
0 > round(vol_ind[*,1]) < (ydim-1), $
0 > round(vol_ind[*,2]) < (zdim-1)]
where SLICE is a 2D array which is "extracted" from VOLUME using
transformed coordinates already computed and stored in VOL_IND.
I've written a C routine that does a special-case nearest-neighbor
sampling in which zero-valued voxels are "ignored", avoiding
aliasing effects at the interface between zero-valued and non-zero-
valued voxels. Email me if you're interested in it.
Dave Foster
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|