On Feb 6, 2013, at 7:34 PM, Mike Jarvis <notifications@github.com> wrote:

> In src/SBInterpolatedImage.cpp:
> 
> >          int xStart = -((image.getXMax()-image.getXMin()+1)/2);
> >          int y = -((image.getYMax()-image.getYMin()+1)/2);
> >          dbg<<"xStart = "<<xStart<<", yStart = "<<y<<std::endl;
> > +        // fill padded region with noise
> > +        if (pad_image.get()) {
> > +            dbg<<"Adding noise from supplied image"<<std::endl;
> > +            // make sure images are same size (but don't worry if bounds are not same)
> > +            if ((1+pad_image->getXMax()-pad_image->getXMin() == _pimpl->Nk) &&
> > +                (1+pad_image->getYMax()-pad_image->getYMin() == _pimpl->Nk)) {
> > +                int N=_pimpl->Nk/2;
> > +                for(int ix = -N; ix < N; ++ix) {
> > +                    for(int iy = -N; iy < N; ++iy) {
> > +                        // Only set the image value and accumulate flux if outside of the part that
> > +                        // will be populated by the real image.  Otherwise it's hard to keep track
> > +                        // of the flux, and the total flux will not be properly accumulated
> > +                        if ((ix < xStart) || (ix > xStart + image.getXMax() - image.getXMin()) ||
> Do we really care about accumulating the correct flux and centroid from the padded region? It would be a lot more efficient to just copy the entire pad_image and then overwrite the portion where the original image goes.
> 
Well, if I understand you properly, I think there are two questions here:

1) If our flux and centroid algorithms are going to use the entire image (original plus the padding) then why didn't I simply copy the pad_image and overwrite the portion where the original image goes, so I just have to do one loop over the image?

2) Why use the padding region at all when accumulating the flux and estimating the centroid?

The answer to (1) is that I have no idea why I didn't do it that way.
The answer to (2) is that with the current setup there is no reason not to change it so these calculations just use the original image region, it would just require some more (admittedly fairly simple) bookkeeping.

I can make these changes, unless you're antsy to keep working on this (I have some lectures to prepare so I couldn't do it until tomorrow night or Fri).