private void fillTemplate( Gray8Image templateimg, double outerdiamX, double innerdiamX, double aspect) { double centerX = templateimg.getWidth() / 2; double centerY = templateimg.getHeight() / 2; double outerrad = outerdiamX / 2; double innerrad = innerdiamX / 2; for (int wCount = 0; wCount < templateimg.getWidth(); wCount++) { for (int hCount = 0; hCount < templateimg.getHeight(); hCount++) { double dist = Math.sqrt( (wCount - centerX) * (wCount - centerX) + (hCount - centerY) / aspect * (hCount - centerY) / aspect); if (dist <= outerrad && dist > innerrad) { templateimg.putBlack(wCount, hCount); } else { templateimg.putWhite(wCount, hCount); } } } }