comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Can this be done using array operations instead?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Can this be done using array operations instead? [message #66114 is a reply to message #65921] Thu, 02 April 2009 10:16 Go to previous messageGo to previous message
Allan Whiteford is currently offline  Allan Whiteford
Messages: 117
Registered: June 2006
Senior Member
Robin,

robintw wrote:
> Hi,
>
> I'm quite new to IDL and I've written a function to calculate some
> statistics for an image file in ENVI. The function has to be
> calculated for the 3x3 square around every pixel in the image. At the
> moment I'm using a couple of nested for loops to do that - is there a
> way to do it using array operations instead?
>

Probably :).

> What I suppose I'm asking for is a way to call a particular function
> for every element of an array - is that possible. I know it's possible
> to do NewArray = OldArray * 2, which is calling the + function on
> every element of the array, but is there a way to call my user-defined
> function on each element?
>

I think you want to do something slightly more complicated, you want to
call your user defined function on groups of array elements rather than
invididual array elements.

> I can post code if that would help.
>

If you post stand-alone code which does what you want using loops then
chances are someone can point you in the right direction of code which
does it using array operations.

Particularly useful is the ability to do stuff like this:

NewArray = (OldArray[0:n_elements(OldArray)-1] + OldArray[1:*])/2

which will give you the mean between adjacent elements in oldarray
(oldarray assumed to be 1D). Note that you need to worry about what
happens at the edges as soon as you start doing stuff like this. Note
also that the above example is just to illustrate the type of array
techniques you could use.

> Cheers,
>
> Robin

Thanks,

Allan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: simultaneous use of multiple font on a postscript file
Next Topic: Re: highlight text in text widget

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:37:18 PDT 2025

Total time taken to generate the page: 0.00417 seconds