use of boofcv.abst.feature.detect.extract.NonMaxSuppression in project BoofCV by lessthanoptimal.
the class FactoryDetectDescribe method sift.
/**
* Creates a new SIFT feature detector and describer.
*
* @see CompleteSift
*
* @param config Configuration for the SIFT detector and descriptor.
* @return SIFT
*/
public static <T extends ImageGray<T>> DetectDescribePoint<T, BrightFeature> sift(@Nullable ConfigCompleteSift config) {
if (config == null)
config = new ConfigCompleteSift();
ConfigSiftScaleSpace configSS = config.scaleSpace;
ConfigSiftDetector configDetector = config.detector;
ConfigSiftOrientation configOri = config.orientation;
ConfigSiftDescribe configDesc = config.describe;
SiftScaleSpace scaleSpace = new SiftScaleSpace(configSS.firstOctave, configSS.lastOctave, configSS.numScales, configSS.sigma0);
OrientationHistogramSift<GrayF32> orientation = new OrientationHistogramSift<>(configOri.histogramSize, configOri.sigmaEnlarge, GrayF32.class);
DescribePointSift<GrayF32> describe = new DescribePointSift<>(configDesc.widthSubregion, configDesc.widthGrid, configDesc.numHistogramBins, configDesc.sigmaToPixels, configDesc.weightingSigmaFraction, configDesc.maxDescriptorElementValue, GrayF32.class);
NonMaxSuppression nns = FactoryFeatureExtractor.nonmax(configDetector.extract);
NonMaxLimiter nonMax = new NonMaxLimiter(nns, configDetector.maxFeaturesPerScale);
CompleteSift dds = new CompleteSift(scaleSpace, configDetector.edgeR, nonMax, orientation, describe);
return new DetectDescribe_CompleteSift<>(dds);
}
use of boofcv.abst.feature.detect.extract.NonMaxSuppression in project BoofCV by lessthanoptimal.
the class FactoryInterestPointAlgs method hessianLaplace.
/**
* Creates a {@link boofcv.alg.feature.detect.interest.FeatureLaplacePyramid} which is uses a hessian blob detector.
*
* @param extractRadius Size of the feature used to detect the corners.
* @param detectThreshold Minimum corner intensity required
* @param maxFeatures Max number of features that can be found.
* @param imageType Type of input image.
* @param derivType Image derivative type.
* @return CornerLaplaceScaleSpace
*/
public static <T extends ImageGray<T>, D extends ImageGray<D>> FeatureLaplacePyramid<T, D> hessianLaplace(int extractRadius, float detectThreshold, int maxFeatures, Class<T> imageType, Class<D> derivType) {
GeneralFeatureIntensity<T, D> intensity = new WrapperHessianBlobIntensity<>(HessianBlobIntensity.Type.DETERMINANT, derivType);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(extractRadius, detectThreshold, extractRadius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensity, extractor);
detector.setMaxFeatures(maxFeatures);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
ImageFunctionSparse<T> sparseLaplace = FactoryDerivativeSparse.createLaplacian(imageType, null);
return new FeatureLaplacePyramid<>(detector, sparseLaplace, deriv, 2);
}
use of boofcv.abst.feature.detect.extract.NonMaxSuppression in project BoofCV by lessthanoptimal.
the class FactoryInterestPointAlgs method harrisPyramid.
/**
* Creates a {@link FeaturePyramid} which is uses the Harris corner detector.
*
* @param extractRadius Size of the feature used to detect the corners.
* @param detectThreshold Minimum corner intensity required
* @param maxFeatures Max number of features that can be found.
* @param imageType Type of input image.
* @param derivType Image derivative type.
* @return CornerLaplaceScaleSpace
*/
public static <T extends ImageGray<T>, D extends ImageGray<D>> FeaturePyramid<T, D> harrisPyramid(int extractRadius, float detectThreshold, int maxFeatures, Class<T> imageType, Class<D> derivType) {
GradientCornerIntensity<D> harris = FactoryIntensityPointAlg.harris(extractRadius, 0.04f, false, derivType);
GeneralFeatureIntensity<T, D> intensity = new WrapperGradientCornerIntensity<>(harris);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(extractRadius, detectThreshold, extractRadius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensity, extractor);
detector.setMaxFeatures(maxFeatures);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
return new FeaturePyramid<>(detector, deriv, 2);
}
use of boofcv.abst.feature.detect.extract.NonMaxSuppression in project BoofCV by lessthanoptimal.
the class FactoryInterestPointAlgs method hessianPyramid.
/**
* Creates a {@link FeaturePyramid} which is uses a hessian blob detector.
*
* @param extractRadius Size of the feature used to detect the corners.
* @param detectThreshold Minimum corner intensity required
* @param maxFeatures Max number of features that can be found.
* @param imageType Type of input image.
* @param derivType Image derivative type.
* @return CornerLaplaceScaleSpace
*/
public static <T extends ImageGray<T>, D extends ImageGray<D>> FeaturePyramid<T, D> hessianPyramid(int extractRadius, float detectThreshold, int maxFeatures, Class<T> imageType, Class<D> derivType) {
GeneralFeatureIntensity<T, D> intensity = new WrapperHessianBlobIntensity<>(HessianBlobIntensity.Type.DETERMINANT, derivType);
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(extractRadius, detectThreshold, extractRadius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensity, extractor);
detector.setMaxFeatures(maxFeatures);
AnyImageDerivative<T, D> deriv = GImageDerivativeOps.derivativeForScaleSpace(imageType, derivType);
return new FeaturePyramid<>(detector, deriv, 2);
}
use of boofcv.abst.feature.detect.extract.NonMaxSuppression in project BoofCV by lessthanoptimal.
the class CompareFeatureExtractorApp method doProcess.
private synchronized void doProcess() {
// System.out.println("radius "+radius+" min separation "+minSeparation+" thresholdFraction "+thresholdFraction+" numFeatures "+numFeatures);
deriv.setInput(grayImage);
D derivX = deriv.getDerivative(true);
D derivY = deriv.getDerivative(false);
D derivXX = deriv.getDerivative(true, true);
D derivYY = deriv.getDerivative(false, false);
D derivXY = deriv.getDerivative(true, false);
// todo modifying buffered images which might be actively being displayed, could mess up swing
intensityAlg.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
GrayF32 intensity = intensityAlg.getIntensity();
intensityImage = VisualizeImageData.colorizeSign(intensityAlg.getIntensity(), null, ImageStatistics.maxAbs(intensity));
float max = ImageStatistics.maxAbs(intensity);
float threshold = max * thresholdFraction;
NonMaxSuppression extractor = FactoryFeatureExtractor.nonmax(new ConfigExtract(minSeparation, threshold, radius, true));
GeneralFeatureDetector<T, D> detector = new GeneralFeatureDetector<>(intensityAlg, extractor);
detector.setMaxFeatures(numFeatures);
detector.process(grayImage, derivX, derivY, derivXX, derivYY, derivXY);
QueueCorner foundCorners = detector.getMaximums();
render.reset();
for (int i = 0; i < foundCorners.size(); i++) {
Point2D_I16 p = foundCorners.get(i);
render.addPoint(p.x, p.y, 3, Color.RED);
}
Graphics2D g2 = workImage.createGraphics();
g2.drawImage(input, 0, 0, grayImage.width, grayImage.height, null);
render.draw(g2);
drawImage();
}
Aggregations