aha, found the bug that's causing all this segfault grief. SimpleImg wasn't memset when allocated. so, when we allocate the 'ori' image, the border is a bunch of random numbers. we use 'ori=0 to 17' as part of index computation. when ori(i) is a random large number, we fall off the end of our arrays