且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

感兴趣区域检测技术

更新时间:2022-03-07 02:31:47

Boofcv研究:感兴趣区域检测技术

public class InterestPoint {

    public static <T extends ImageGray>
    void detect( BufferedImage image , Class<T> imageType ) {
        T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);

        InterestPointDetector<T> detector = FactoryInterestPoint.fastHessian(
                new ConfigFastHessian(10, 2, 100, 2, 9, 3, 4));

        detector.detect(input);

        displayResults(image, detector);
    }

    private static <T extends ImageGray>
    void displayResults(BufferedImage image, InterestPointDetector<T> detector)
    {
        Graphics2D g2 = image.createGraphics();
        FancyInterestPointRender render = new FancyInterestPointRender();


        for( int i = 0; i < detector.getNumberOfFeatures(); i++ ) {
            Point2D_F64 pt = detector.getLocation(i);

            if( detector.hasScale() ) {
                int radius = (int)(detector.getRadius(i));
                render.addCircle((int)pt.x,(int)pt.y,radius);
            } else {
                render.addPoint((int) pt.x, (int) pt.y);
            }
        }
        g2.setStroke(new BasicStroke(3));

        render.draw(g2);
        ShowImages.showWindow(image, "Detected Features", true);
    }

    public static void main( String args[] ) {
        BufferedImage image = UtilImageIO.loadImage(UtilIO.pathExample("D:\\JavaProject\\Boofcv\\example\\sunflowers.jpg"));
        detect(image, GrayF32.class);
    }
}

感兴趣区域检测技术