Search in sources :

Example 1 with HoughTransformLinePolar

use of boofcv.alg.feature.detect.line.HoughTransformLinePolar in project BoofCV by lessthanoptimal.

the class DetectLineHoughPolar method detect.

@Override
public List<LineParametric2D_F32> detect(I input) {
    // see if the input image shape has changed.
    if (derivX.width != input.width || derivY.height != input.height) {
        double r = Math.sqrt(input.width * input.width + input.height * input.height);
        int numBinsRange = (int) Math.ceil(r / resolutionRange);
        int numBinsAngle = (int) Math.ceil(Math.PI / resolutionAngle);
        alg = new HoughTransformLinePolar(extractor, numBinsRange, numBinsAngle);
        derivX.reshape(input.width, input.height);
        derivY.reshape(input.width, input.height);
        intensity.reshape(input.width, input.height);
        binary.reshape(input.width, input.height);
        // angle.reshape(input.width, input.height);
        // direction.reshape(input.width, input.height);
        suppressed.reshape(input.width, input.height);
    }
    gradient.process(input, derivX, derivY);
    GGradientToEdgeFeatures.intensityAbs(derivX, derivY, intensity);
    // non-max suppression reduces the number of line pixels, reducing the number of false positives
    // When too many pixels are flagged, then more curves randomly cross over in transform space causing
    // false positives
    // GGradientToEdgeFeatures.direction(derivX, derivY, angle);
    // GradientToEdgeFeatures.discretizeDirection4(angle, direction);
    // GradientToEdgeFeatures.nonMaxSuppression4(intensity,direction, suppressed);
    GGradientToEdgeFeatures.nonMaxSuppressionCrude4(intensity, derivX, derivY, suppressed);
    ThresholdImageOps.threshold(suppressed, binary, thresholdEdge, false);
    alg.transform(binary);
    FastQueue<LineParametric2D_F32> lines = alg.extractLines();
    List<LineParametric2D_F32> ret = new ArrayList<>();
    for (int i = 0; i < lines.size; i++) ret.add(lines.get(i));
    ret = pruneLines(input, ret);
    return ret;
}
Also used : ArrayList(java.util.ArrayList) HoughTransformLinePolar(boofcv.alg.feature.detect.line.HoughTransformLinePolar) LineParametric2D_F32(georegression.struct.line.LineParametric2D_F32)

Aggregations

HoughTransformLinePolar (boofcv.alg.feature.detect.line.HoughTransformLinePolar)1 LineParametric2D_F32 (georegression.struct.line.LineParametric2D_F32)1 ArrayList (java.util.ArrayList)1