49 if ((width < 1) || (height < 1)) {
82 typedef afwMath::Kernel::Pixel Pixel;
105 LOGL_DEBUG(
"TRACE1.ip.diffim.BasisLists.makeAlardLuptonBasisList",
106 "Gaussian %d : sigma %.2f degree %d",
i,
sig,
deg);
112 for (
int j = 0, n = 0;
j <=
deg;
j++) {
113 for (
int k = 0; k <= (
deg -
j); k++, n++) {
126 for (
int y = 0, v = -
halfWidth;
y < image.getHeight();
y++, v++) {
128 for (
auto ptr = image.row_begin(
y),
end = image.row_end(
y); ptr !=
end; ++ptr, ++u) {
179 std::string regularizationType =
ps.getAsString(
"regularizationType");
180 int width =
ps.getAsInt(
"kernelSize");
181 int height =
ps.getAsInt(
"kernelSize");
183 bool fitForBackground =
ps.getAsBool(
"fitForBackground");
185 Eigen::MatrixXd
bMat;
186 if (regularizationType ==
"centralDifference") {
187 int stencil =
ps.getAsInt(
"centralRegularizationStencil");
190 else if (regularizationType ==
"forwardDifference") {
198 Eigen::MatrixXd hMat =
bMat.transpose() *
bMat;
210 bool fitForBackground
256 coeffs[0][0] = 1. / 6.;
257 coeffs[0][1] = 4. / 6.;
258 coeffs[0][2] = 1. / 6.;
259 coeffs[1][0] = 4. / 6.;
260 coeffs[1][1] = -20. / 6.;
261 coeffs[1][2] = 4. / 6.;
262 coeffs[2][0] = 1. / 6.;
263 coeffs[2][1] = 4. / 6.;
264 coeffs[2][2] = 1. / 6.;
270 int nBgTerms = fitForBackground ? 1 : 0;
271 Eigen::MatrixXd
bMat = Eigen::MatrixXd::Zero(width * height +
nBgTerms, width * height +
nBgTerms);
273 for (
int i = 0;
i < width*height;
i++) {
274 int const x0 =
i % width;
275 int const y0 =
i / width;
276 int const distX = width - x0 - 1;
277 int const distY = height - y0 - 1;
279 if ( (x0 > 0) && (y0 > 0) && (
distX > 0) && (
distY > 0) ) {
280 for (
int dx = -1;
dx < 2;
dx += 1) {
281 for (
int dy = -1;
dy < 2;
dy += 1) {
291 if (fitForBackground) {
293 if (
bMat.col(width*height).sum() != 0.) {
296 if (
bMat.row(width*height).sum() != 0.) {
312 bool fitForBackground
355 int nBgTerms = fitForBackground ? 1 : 0;
356 Eigen::MatrixXd
bTot = Eigen::MatrixXd::Zero(width * height +
nBgTerms, width * height +
nBgTerms);
358 std::vector<int>::const_iterator
order;
363 Eigen::MatrixXd
bMatX = Eigen::MatrixXd::Zero(width * height +
nBgTerms,
365 Eigen::MatrixXd
bMatY = Eigen::MatrixXd::Zero(width * height +
nBgTerms,
368 for (
int i = 0;
i < width*height;
i++) {
369 int const x0 =
i % width;
370 int const y0 =
i / width;
372 int distX = width - x0 - 1;
378 int distY = height - y0 - 1;
388 if (fitForBackground) {
390 if (
bTot.col(width*height).sum() != 0.) {
393 if (
bTot.row(width*height).sum() != 0.) {
413 typedef afwMath::Kernel::Pixel Pixel;
464 for (
int y = 0;
y < image.getHeight();
y++) {
465 for (
auto ptr = image.row_begin(
y),
end = image.row_end(
y); ptr !=
end; ++ptr) {
483 for (
int y = 0;
y < image.getHeight();
y++) {
484 for (
auto ptr = image.row_begin(
y),
end = image.row_end(
y); ptr !=
end; ++ptr) {
569 coeffs[0][0][0] = -2;
575 coeffs[1][0][0] = -2;
577 coeffs[1][0][2] = -1;
581 coeffs[1][2][0] = -1;
586 coeffs[2][0][0] = -2;
588 coeffs[2][0][2] = -3;
594 coeffs[2][2][0] = -3;
614 coeffs[0][0][1] = -1;
617 coeffs[0][1][0] = -1;
638 coeffs[1][1][1] = -4;
655 coeffs[2][0][2] = -1;
665 coeffs[2][2][0] = -1;
668 coeffs[2][2][3] = -2;
673 coeffs[2][3][2] = -2;
687 Eigen::MatrixXd
bMat = Eigen::MatrixXd::Zero(width*height+1, width*height+1);
690 for (
unsigned int i = 0;
i < width*height;
i++) {
692 unsigned int const x0 =
i % width;
693 unsigned int const y0 =
i / width;
695 unsigned int x_edge_distance = (x0 > (width - x0 - 1)) ? width - x0 - 1 : x0;
696 unsigned int y_edge_distance = (y0 > (height - y0 - 1)) ? height - y0 - 1 : y0;
715 if (
y > height - 1 ||
x > width - 1) {
722 x = (width + x0 +
dx -
x_cen) % width;
723 y = (height + y0 +
dy -
y_cen) % height;
739 y = (height + y0 +
dy -
y_cen1) % height;
745 y = (height + y0 +
dy -
y_cen2) % height;
750 x = (width + x0 +
dx -
x_cen) % width;
751 y = (height + y0 +
dy -
y_cen) % height;
769 Eigen::MatrixXd hMat =
bMat.transpose() *
bMat;
Subroutines associated with generating, normalising, and regularising Basis functions.
#define LSST_EXCEPT(type,...)
#define LOGL_DEBUG(logger, message...)
double computeImage(lsst::afw::image::Image< Pixel > &image, bool doNormalize, double x=0.0, double y=0.0) const
Asseses the quality of a candidate given a spatial kernel and background model.
lsst::afw::math::KernelList makeDeltaFunctionBasisList(int width, int height)
Build a set of Delta Function basis kernels.
lsst::afw::math::KernelList renormalizeKernelList(lsst::afw::math::KernelList const &kernelListIn)
Renormalize a list of basis kernels.
Eigen::MatrixXd makeFiniteDifferenceRegularizationDeprecated(unsigned int width, unsigned int height, unsigned int order, unsigned int boundary_style, unsigned int difference_style, bool printB)
Generate regularization matrix for delta function kernels.
Eigen::MatrixXd makeRegularizationMatrix(lsst::daf::base::PropertySet const &ps)
Build a regularization matrix for Delta function kernels.
Eigen::MatrixXd makeCentralDifferenceMatrix(int width, int height, int stencil, float borderPenalty, bool fitForBackground)
Build a central difference Laplacian regularization matrix for Delta function kernels.
Eigen::MatrixXd makeForwardDifferenceMatrix(int width, int height, std::vector< int > const &orders, float borderPenalty, bool fitForBackground)
Build a forward difference regularization matrix for Delta function kernels.
lsst::afw::math::KernelList makeAlardLuptonBasisList(int halfWidth, int nGauss, std::vector< double > const &sigGauss, std::vector< int > const °Gauss)
Build a set of Alard/Lupton basis kernels.