Re: Best way to move a window [message #29643 is a reply to message #29532] |
Fri, 01 March 2002 04:49  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
"Ned Horning" <nedh@lightlink.com> wrote in message
news:uvis7ug8kfc4qtlnllpqj3223m19bo3pd3@4ax.com...
> Thanks Marc, this is pretty slick and it helps a lot. Unfortunately I
> just realized that I didn't post the second half of the window
> routine. After doing the "abs(tile_data - 180) lt 0.0001)" test I
> continue with:
>
> s= 45
> t=45
> IF (((ABS(tile_data[x+1,y+1] - 45) le s) AND (ABS(tile_data[x-1,y-1] -
> tile_data(x+1,y+1) -180) le t)) OR $
> ((ABS(tile_data[x+1,y] - 90) le s) AND (ABS(tile_data[x-1,y] -
> tile_data(x+1,y) -180) le t)) OR $
> ((ABS(tile_data[x+1,y+1] - 135) le s) AND (ABS(tile_data[x-1,y+1] -
> tile_data(x+1,y-1) -180) le t)) OR $
> ((ABS(tile_data[x,y-1] - 180) le s) AND (ABS(ABS(tile_data[x,y+1] -
> tile_data(x,y-1)) -180) le t))) THEN $
> out_tile[y*num_tile_samples+x] = 1 ELSE $
> out_tile[y*num_tile_samples+x] = 0
>
> What this does is compares opposing pixels (top and bottom, left and
> right, upper left lowerright, upper right and lower left) and I'm
> trying to see how to use the where/convolution logic for this and not
> having much luck.
Well, two options spring to mind:
- use the SHIFT() function, e.g. for left-right:
shiftleft = SHIFT(tile_data, -1, 0) & shiftright = SHIFT(tile_data, 1, 0)
expression:
( ABS(shiftleft - 90) LE s ) AND ( ABS(shiftright - shiftleft - 180) LE
t )
- use CONVOL() with kernels like [-1,0,1] for left-right, [[-1],[0],[1]]
for top-bottom, and 3x3 arrays for the diagonals. For left-right:
expression:
( ABS(shiftleft - 90) LE s ) AND $
( ABS( CONVOL(tile_data, [-1,0,1]) - 180) LE t )
Then it should be possible to OR the above expressions directly together
and AND them into out_tile. If most of the elements get selected already
in the first half (180. being in their neigbourhood), then a loop over the
remaining elements might be a faster solution for this second half.
Getting totally confused about what this routine is actually doing,
Jaco
|
|
|