/** * Calculates a projection across the accumulator space. * Returns an image that has width {@link #getNumberOfSegments()} * and height of 1. Effectively sums across the distances from origin * in the space such that you end up with a representation that gives you * the strength of the angles in the image irrespective of where those * lines occur. * * @return A horizontal projection on the accumulator space as an * FImage with dimensions {@link #getNumberOfSegments()} x 1 */ public FImage calculateHorizontalProjection() { return calculateHorizontalProjection( accum ); }
/** * Calculates a projection across the accumulator space. * Returns an image that has width {@link #getNumberOfSegments()} * and height of 1. Effectively sums across the distances from origin * in the space such that you end up with a representation that gives you * the strength of the angles in the image irrespective of where those * lines occur. * * @return A horizontal projection on the accumulator space as an * FImage with dimensions {@link #getNumberOfSegments()} x 1 */ public FImage calculateHorizontalProjection() { return calculateHorizontalProjection( accum ); }
/** * Returns the most frequent angle that occurs within the given accumulator * space by calculating a horizontal projection over the accumulator * space and returning the angle with the most votes. The prevailing * angle is given in degrees. If it is less than zero, then no angle * could be extracted (there was no local maxima in the accumulator). * * @param accum The accumulator space to use * @param offset The offset into the accumulator of the 0 degree bin * @param nDegrees The number of degrees covered by the accumulator space * @return The prevailing angle (degrees) in the accumulator space; or * Double.MIN_VALUE if there is no prevailing angle */ public double calculatePrevailingAngle( FImage accum, int offset, double nDegrees ) { FValuePixel maxpix = calculateHorizontalProjection(accum).maxPixel(); if( maxpix.x == -1 && maxpix.y == -1 ) return Double.MIN_VALUE; return (maxpix.x+offset) * (nDegrees/accum.getWidth()); }
/** * Returns the most frequent angle that occurs within the given accumulator * space by calculating a horizontal projection over the accumulator * space and returning the angle with the most votes. The prevailing * angle is given in degrees. If it is less than zero, then no angle * could be extracted (there was no local maxima in the accumulator). * * @param accum The accumulator space to use * @param offset The offset into the accumulator of the 0 degree bin * @param nDegrees The number of degrees covered by the accumulator space * @return The prevailing angle (degrees) in the accumulator space; or * Double.MIN_VALUE if there is no prevailing angle */ public double calculatePrevailingAngle( FImage accum, int offset, double nDegrees ) { FValuePixel maxpix = calculateHorizontalProjection(accum).maxPixel(); if( maxpix.x == -1 && maxpix.y == -1 ) return Double.MIN_VALUE; return (maxpix.x+offset) * (nDegrees/accum.getWidth()); }