예제 #1
0
  /**
   * Detects lines inside the image using different types of Hough detectors
   *
   * @param image Input image.
   * @param imageType Type of image processed by line detector.
   * @param derivType Type of image derivative.
   */
  public static <T extends ImageSingleBand, D extends ImageSingleBand> void detectLines(
      BufferedImage image, Class<T> imageType, Class<D> derivType) {
    // convert the line into a single band image
    T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);

    // Comment/uncomment to try a different type of line detector
    DetectLineHoughPolar<T, D> detector =
        FactoryDetectLineAlgs.houghPolar(
            new ConfigHoughPolar(3, 30, 2, Math.PI / 180, edgeThreshold, maxLines),
            imageType,
            derivType);
    //		DetectLineHoughFoot<T,D> detector = FactoryDetectLineAlgs.houghFoot(
    //				new ConfigHoughFoot(3, 8, 5, edgeThreshold,maxLines), imageType, derivType);
    //		DetectLineHoughFootSubimage<T,D> detector = FactoryDetectLineAlgs.houghFootSub(
    //				new ConfigHoughFootSubimage(3, 8, 5, edgeThreshold,maxLines, 2, 2), imageType, derivType);

    List<LineParametric2D_F32> found = detector.detect(input);

    // display the results
    ImageLinePanel gui = new ImageLinePanel();
    gui.setBackground(image);
    gui.setLines(found);
    gui.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));

    listPanel.addItem(gui, "Found Lines");
  }
예제 #2
0
  /**
   * Detects segments inside the image
   *
   * @param image Input image.
   * @param imageType Type of image processed by line detector.
   * @param derivType Type of image derivative.
   */
  public static <T extends ImageSingleBand, D extends ImageSingleBand> void detectLineSegments(
      BufferedImage image, Class<T> imageType, Class<D> derivType) {
    // convert the line into a single band image
    T input = ConvertBufferedImage.convertFromSingle(image, null, imageType);

    // Comment/uncomment to try a different type of line detector
    DetectLineSegmentsGridRansac<T, D> detector =
        FactoryDetectLineAlgs.lineRansac(40, 30, 2.36, true, imageType, derivType);

    List<LineSegment2D_F32> found = detector.detect(input);

    // display the results
    ImageLinePanel gui = new ImageLinePanel();
    gui.setBackground(image);
    gui.setLineSegments(found);
    gui.setPreferredSize(new Dimension(image.getWidth(), image.getHeight()));

    listPanel.addItem(gui, "Found Line Segments");
  }