Re: Array indices and lookup tables [message #39791 is a reply to message #39756] |
Fri, 11 June 2004 04:34   |
Haje Korth
Messages: 651 Registered: May 1997
|
Senior Member |
|
|
Thanks everyone for your input, which helped me solve my problem. Here a
bried summary: Chris Lee's code works great and was an option. The execution
time for the [3,1440,720] array was 0.8 seconds on my machine. But I also
tried a modified version of David Fanning's solution and noticed that it is
slightly faster (0.5 seconds on my machine). The version I am now using is
(just for the record):
function permute_rgb, rgb_image, perm
sz=size(rgb_image,/structure)
x=reform(perm[0,*,*])
y=reform(perm[1,*,*])
idx=y*sz.dimensions[1]+x
new_rgb_image=bytarr(3,sz.dimensions[1],sz.dimensions[2])
new_rgb_image[0,*,*]=(rgb_image[0,*,*])[idx]
new_rgb_image[1,*,*]=(rgb_image[1,*,*])[idx]
new_rgb_image[2,*,*]=(rgb_image[2,*,*])[idx]
return,new_rgb_image
end
"Haje Korth" <haje.korth@jhuapl.edu> wrote in message
news:ca72v6$qlb$1@aplcore.jhuapl.edu...
> Good morning all,
> I am working on a coordinate transformation for a map and I have a simple
> problem. My mind is alreay blocked early in the morning and I could use
some
> input: I have an rgb image of dimensions [3,1440, 720]. I need to
rearranged
> the pixel in the image according to a lookup table of dimension
> [2,1440,360], which contains the column and row of the new pixel assigned
to
> a location. Is there a magic way to do this without looping through each
> pixel in IDL?
>
> Thanks for helping,
> Haje
>
>
|
|
|