next up previous print clean
Next: Weighting and reconstructing Up: Nonstationarity: patching Previous: Nonstationarity: patching

PATCHING TECHNOLOGY

A plane of information, either data or an image,

say wall(n1,n2), will be divided up into an array of overlapping windows each of size (w1,w2). To choose the number of windows you specify (k1,k2). The fraction (w1*k1)/n1 measures overlap on the 1-axis.

To traverse all the windows, we can use subroutine patch2() to grab them from the wall, to put them back. To run this traverse, we need only looping variables (j1,j2) to run from (1,1) to (k1,k2).

The intricate indexing statements in patch2() assure that patches cover all edges and corners of the given data plane even when n1/w1 and n2/w2 are not integers. When there are noninteger ratios, the spacing of patches is slightly uneven, but it is easy to reassemble seamlessly the full plane from the patches so the unevenness does not matter.

 

# patch2 -- copy the (j1,j2)-th of (k1,k2) subplanes from a plane.
#
subroutine patch2( adj, add, j1,j2, k1,k2, wall, n1,n2,  wind, w1,w2)
integer            adj, add, j1,j2, k1,k2,       n1,n2,        w1,w2
integer i1,i2, s1,s2, a1,a2
real                                       wall( n1,n2), wind( w1,w2)
call  adjnull(     adj, add,               wall, n1*n2,  wind, w1*w2)

if( k2 != 1) { s2 = 1.5 + (n2 - w2) * (j2-1.)/(k2-1.)} else { s2= 1} if( k1 != 1) { s1 = 1.5 + (n1 - w1) * (j1-1.)/(k1-1.)} else { s1= 1}

do i2= 1, w2 { a2= i2 + s2 - 1 do i1= 1, w1 { a1= i1 + s1 - 1 if( adj == 0 ) wind( i1,i2) = wind( i1,i2) + wall( a1,a2) else wall( a1,a2) = wall( a1,a2) + wind( i1,i2) }} return; end

The start (s1,s2) of the first window on the wall of data is at (1,1), and the last start is at the end of the wall (n1,n2) less the window width plus one. An exceptional case arises when the user specifies k1=1, which means the 1-axis contains only one window. Then unless w1==n1, the window cannot fit both the beginning and the end of the wall, so it is arbitrarily fit only at the beginning. As in any code mixing integers with floats, to guard against having a floating-point number, say 99.9999, rounding down to 99 instead of up to 100, the rule is to always add .5 to a floating point number the moment before converting it to an integer.

We should always use subroutine patch2() for patching and avoid copying any of its messy internals into our application code. Thus when a better method of patching comes along, we have it all in one place and can change it all at once. Figure 2 shows an example.

 
parcel
Figure 2
A plane of identical values after patches have been cut and then added. Results are shown for n1=100 w1=17 k1=5 n2=30 w2=6 k2=11 . For these parameters, there is gapping on the horizontal axis and overlap on the depth axis.

parcel
view burn build edit restore



 
next up previous print clean
Next: Weighting and reconstructing Up: Nonstationarity: patching Previous: Nonstationarity: patching
Stanford Exploration Project
2/27/1998