Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: ListCorrelate[] ??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30215] Re: [mg30182] Re: ListCorrelate[] ??
  • From: "Mariusz Jankowski" <mjkcc at usm.maine.edu>
  • Date: Thu, 2 Aug 2001 03:16:08 -0400 (EDT)
  • References: <9jtkeq$894$1@smc.vnet.net> <200108010619.CAA03979@smc.vnet.net> <3B68324F.B2189A94@nature.berkeley.edu>
  • Sender: owner-wri-mathgroup at wolfram.com

Brent, forget my comment about the ListCorrelate parameter. The two forms
{n,-n} and {n,n} are equivalent whenever n=(Length[ker]+1)/2, so my earlier
statement was inaccurate. The two forms both refer to the same element in
list ker, namely the middle one for odd length lists ker.


----- Original Message -----
From: "Brent Pedersen" <bpederse at nature.berkeley.edu>
To: mathgroup at smc.vnet.net
Subject: [mg30215] Re: [mg30182] Re: ListCorrelate[] ??


>
> thanks,
> i had not tried Tr[Flatten[...]] for quick summation.
> but, now i am confused about the 3rd argument in ListCorrelate[]...
> first to answer your question. yes, this is similar to edge enhancement
> for DIP but, i am using it to simulate dispersal of populations where
> each entry of the matrix is a population density and ListCorrelate[]
simulates
> dispersal.
>   i assume (to avoid a loss of individuals at the edge of the lattice)
> periodic boundaries such that the surface essentially becomes a torus
> (or a donut as noted by Daniel Licthblau).
> so, i have been using   ListCorrelate[kern,matrix, {n,-n}]
> where n is the maximum dispersal radius +1
> because this allows the kernel to "hang" over the edge of the population
> lattice by n on all sides. then, for the case where i wish
> to have "absorbing boundaries" where individuals can move off
> the matrix i use:
> ListCorrelate[kern,matrix, {n,-n},0]
> assuming that the automatic  padding is at least n zeros on all sides.
> is this correct for my purposes?

Yes, the constant parameter 0 will cause padding of data with zeros to the
extent defined by value n.



> and another question, how would one create "reflecting boundaries" where
> individuals that would normally leave the edge of the matrix, instead
> remain on the edge?
>


If you mean a boundary extension that replicates the first/last element (or
n elements) of each row or column, the solution is not so simple, meaning it
cannot be accomplished inside of ListCorrelate. For the simplest case of
padding a 1-D list with one element on both ends the solution is:

In[68]:=
data = Range[5]

Out[68]=
{1, 2, 3, 4, 5}

In[69]:=
PadLeft[PadRight[data, Length[data] + 1, data[[-1]]],
  Length[data] + 2, data[[1]]]

Out[69]=
{1, 1, 2, 3, 4, 5, 5}

For matrices, a simple minded but effective approach is to repeat the above
for all rows and columns. So define

fixedPad[data_List] :=  PadLeft[PadRight[data, Length[data] + 1,
data[[-1]]],
  Length[data] + 2, data[[1]]];

and

Transpose[fixedPad /@ Transpose[fixedPad/@data]],

finally, since you padded the data use the following form of ListCorrelate
(of course, will only work correctly for 3x3 kernel):


ListCorrelate[ker, paddeddata]



A multidimensional FixedPad function is in my Digital Image Processing
package :).



Hope this helps,


Mariusz


======================================================
Mariusz Jankowski
University of Southern Maine
mjkcc at usm.maine.edu



  • Prev by Date: Re: Re: Two factors of (10^71-1)/9 = R71
  • Next by Date: Re: Re: ListCorrelate[] ??
  • Previous by thread: Re: ListCorrelate[] ??
  • Next by thread: Re: Re: ListCorrelate[] ??