Another "How to efficiently do this in IDL" question [message #78105] |
Fri, 21 October 2011 15:15  |
Robin Wilson
Messages: 40 Registered: August 2010
|
Member |
|
|
Hi all,
I've got a 2D integer array. For every cell in the array I want to do
the following:
1. Get the points that lie on a horizontal profile 7 cells long, with
the current cell as the central cell.
2. Find out if there are two (or more) points on both sides of the
central point that have a lower value than the central point. If so,
then mark this point in a separate array.
I can think of loads of ways to do this using very inefficient for loops
and lots of horrible code, but are there any particularly nice ways to
do this in IDL.
It looks to me like I'd have to loop over every cell in the array - it's
not something I could do all at once - but I'm willing to be corrected.
The other main question is that if I've got an array of points like the
following:
1 3 3 5 6 2 1
*
What is an efficient way to check that there are at least two points on
each side of the central point (marked with a star) that have a lower
value than it. My original thought was to loop through the cells, but I
suspect some fancy histogram command could do something to help with this...
Any advice would be most appreciated.
Cheers,
Robin
------------------
Robin Wilson
A PhD student studying complexity in remote sensing
www.rtwilson.com/academic
|
|
|
Re: Another "How to efficiently do this in IDL" question [message #78304 is a reply to message #78105] |
Thu, 03 November 2011 14:56  |
JDS
Messages: 94 Registered: March 2009
|
Member |
|
|
On Friday, October 21, 2011 6:15:09 PM UTC-4, robintw wrote:
>
> The other main question is that if I've got an array of points like the
> following:
>
> 1 3 3 5 6 2 1
> *
>
> What is an efficient way to check that there are at least two points on
> each side of the central point (marked with a star) that have a lower
> value than it. My original thought was to loop through the cells, but I
> suspect some fancy histogram command could do something to help with this...
>
You can find all the "5 point peaks" relatively efficiently:
wh=where(d gt ((m=median(d,3))) and smooth((d eq m)*(n-2),n-2) eq n-3)
n=5 in your case.
|
|
|