Skip to content

Commit

Permalink
Force (0, 0) for center of warped PSF images.
Browse files Browse the repository at this point in the history
Previous logic forced the image size to be odd, but picked the center
of the kernel image bbox based on center of the transformed kernel
image bbox.  But the output kernel image center is an input: (0, 0).

This manifested as even-sizes images later in CoaddPsf; the union of
two odd-sized boxes with the same dimensions but offset center is
an even-sized box.
  • Loading branch information
TallJimbo committed Jun 6, 2022
1 parent 914a78e commit fa6216e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/WarpedPsf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ geom::Box2I computeBBoxFromTransform(geom::Box2I const bbox, geom::AffineTransfo
}

// We want to guarantee that the output bbox has odd dimensions, so instead
// of using the Box2I converting constructor directly, we round the center
// point of the floating point box and dilate by its half-dimensions.
// of using the Box2I converting constructor directly, we start with (0, 0)
// and dilate by the floating-point box's half-dimensions.
geom::Extent2I out_half_dims = geom::floor(0.5*out_box_fp.getDimensions());
geom::Box2I out_box;
geom::Point2I out_center(out_box_fp.getCenter());
geom::Point2I out_center(0, 0);
out_box.include(out_center);
return out_box.dilatedBy(out_half_dims);
}
Expand Down Expand Up @@ -124,6 +124,8 @@ std::shared_ptr<afw::detection::Psf::Image> warpAffine(afw::detection::Psf::Imag

// allocate output image
geom::Box2I bbox = computeBBoxFromTransform(im.getBBox(), srcToDest);
std::cerr << "bbox prior to warp: " << bbox << std::endl;

auto ret = std::make_shared<afw::detection::Psf::Image>(bbox);

// zero-pad input image
Expand Down

0 comments on commit fa6216e

Please sign in to comment.