/** * Searches the pyramid layers up and down to see if the found 2D features are also scale space * maximums. */ protected void findLocalScaleSpaceMax(GaussianScaleSpace<T, D> ss, int layerID) { int index0 = spaceIndex; int index1 = (spaceIndex + 1) % 3; int index2 = (spaceIndex + 2) % 3; List<Point2D_I16> candidates = maximums[index1]; T image0 = localSpace[index0]; T image1 = localSpace[index1]; T image2 = localSpace[index2]; float scale0 = (float) ss.getScale(layerID - 1); float scale1 = (float) ss.getScale(layerID); float scale2 = (float) ss.getScale(layerID + 1); // For laplacian its t^(2*gamma) where gamma = 3/4 float ss0 = (float) Math.pow(scale0, 2.0 * 0.75); float ss1 = (float) Math.pow(scale1, 2.0 * 0.75); float ss2 = (float) Math.pow(scale2, 2.0 * 0.75); for (Point2D_I16 c : candidates) { sparseLaplace.setImage(image1); float val = ss1 * (float) Math.abs(sparseLaplace.compute(c.x, c.y)); if (checkMax(image0, ss0, val, c.x, c.y) && checkMax(image2, ss2, val, c.x, c.y)) { // put features into the scale of the upper image foundPoints.add(new ScalePoint(c.x, c.y, scale1)); } } }
private boolean checkMax(T image, float scoreAdjust, float bestScore, int c_x, int c_y) { sparseLaplace.setImage(image); boolean isMax = true; beginLoop: for (int i = c_y - 1; i <= c_y + 1; i++) { for (int j = c_x - 1; j <= c_x + 1; j++) { if (scoreAdjust * Math.abs(sparseLaplace.compute(j, i)) >= bestScore) { isMax = false; break beginLoop; } } } return isMax; }