S Penzes wrote:
>
> Hi one and all,
> I am looking for a smart solution to a problem that keeps occuring
> and that I can't
> seem to find a smart solution for.
> Bear in mind that the example I am using here is much simplified from
> the image
> processing I am trying to do. The goal is to find a solution that
> minimizes compute time (ie no loops).
> Given a vector (lets say vector=[0,0,6,7,8,8,7,0,0,7,8,0,0]) and the
> fact that I have a window that is 3 wide, how do I process vector so
> that any data that is greater than 5 and stays that way for more than 3
> indexes remains and everything else is set to 0.
>
> vector -> process -> [0,0,6,7,8,8,7,0,0,0,0,0,0]
How about
vector=[0,0,6,7,8,8,7,0,0,7,8,0,0]
limit = 5
len = (size(vector))(1)
pad = [limit,limit,vector,limit,limit] gt limit
vector = vector * $
(pad(2:len+1) and $
((pad(1:len) and pad(3:len+2)) $
or(pad(1:len) and pad(0:len-1)) $
or(pad(3:len+2) and pad(4:len+3))))
This is finding the locations where the data and its two nearest
neighbors is greater than the limit, or where the data and its
two neighbors to the left are greater than the limit, or where
the data and its two neighbors to the right are greater than the
limit. Is this what you need??
--
************************************************************ ***
** Dan Bergmann dbergmann@llnl.gov **
** Atmospheric Science Division fax (510) 423-4908 **
** Lawrence Livermore National Lab human (510) 423-6765 **
************************************************************ ***
|