Skip to content

Commit b19faf9

Browse files
panovrhanslovsky
authored andcommitted
Add Hough transform (#32)
* Ignore IntelliJ metadata files * Add Hough line transform Signed-off-by: Gabe Selzer <[email protected]> * HoughLineTransformTest: Optimize performance * HoughLineTransformTest: add missing javadoc * HoughLineTransform: Clone peak storage array This stage of the transform makes use of a single array to grab each peak Point and then store it in an ArrayList of long[]. However the array was not copied as it was added into the ArrayList, resulting in all entries in the ArrayList pointing to the same array. This commit fixes this bug through use of Arrays.copyOf() to copy each array and add the result to the ArrayList. * HoughLineTransform: fix rawType warning * HoughTransform: remove Benchmark import This import is not necessary for the class since the class is not a benchmark. * HoughLineTransform: Refactor into static methods. The previous implementation was based on stateful objects, which was not optimal for use of this algorithm. The algorithm was thus reworked into static methods for both votespace generation and peak picking. The process of the algorithm was kept but massaged to fit the new implementation style. * PickPeaks: Allow user input for min peak value. * PickPeaks: Translate votespace for correct output PickPeaks now returns a rho value between [-maxRho, maxRho), whereas before it returned a rho value between [0, maxRho * 2). Translating the votespace before finding the peaks allows for easier manipulation of the polar coordinates, and prevents the user from having to translate the coordinates or votespace themselves. * LineTest: Add PickPeaks regression test * HoughTransforms: Add slope/intercept converters These methods convert the polar output of PickPeaks into more useful slope and intercept values for lines. In the case of an undefined slope getSlope() returns Double.POSITIVE_INFINITY or DOUBLE.NEGATIVE_INFINITY * Cleanup / format * Improve line transform documentation Javadoc adapted from previous commit c1952b1, HoughTransforms.java, line 50 * computeLength: allow larger return values * defaultRho: simplify instructions to one-liner * pickPeaks: loosen typing of parameters * voteLines: Restrict voteSpace to only IntegerType Since the values in the votespace are only ever incremented by one in this particular transform we restrict the votespace to RandomAccessibleIntervals of types extending IntegerType only * pickPeaks: add alternative (convenient) option * voteLines: Relax typing of input RAI * fixup! pickPeaks: add alternative (convenient) option * voteLines: Remove unnecessary variables * HoughLineTest: use small delta for slope and yint * HoughTransforms: Loosen helper method parameters The getVotespaceSize() and defaultRho() method parameter was loosened from being a RandomAccessibleInterval to being a Dimensions object to allow a wider range of acceptible input types * HoughLine: Remove unnecessary array * PickPeaks: Fix translation bug * PickPeaks: Rename to PickLinePeaks Since we are translating the vote space before picking peaks (something that future Hough Transforms might not do), we will change the name to something more specific to the line transform. * VoteLines: Refactor parameter order This allows a theta-only (i.e. to allow a theta but not a rho to be passed through) signature to make sense and to keep the same parameter order * VoteLines: Move check outside for-loop * HoughTransforms: Remove unused import * HoughLineTest: Refactor to better input image * getVotespaceSize: Allow for non-default thetas * HoughTransforms: Formatting * VoteLines: Translate image for zeroed min * VoteLines: Refactor LUTs this commit removes the unused rho[] LUT and refactors the theta[] LUT into two different LUTs for sin(theta) and cos(theta). This refactor speeds up later calculations * VoteLines: fix predicate bug This commit changes the Predicate deciding whether to allow votespace population from being a strictly greater-than to a greater-than-or-equal-to comparison. This fix was made to prevent a bug in which no threshold is provided to the algorithm and at the same time the max value of the image is at the first index of the image. If the comparison is not <= then all pixels will fail the Predicate, since no pixel is greater than the max. This means that passing a value to the algorithm is still preferable but allows more scenarios where no value is given. * VoteLines: Refactor fRho/r declaration * VoteLines: Remove cursor positions from for loop * VoteLines: remove unnecessary float cast. * HoughLineTest: use ArrayImgs to make votespace * HoughLineTest: Formatting * VoteLines: Fix javadoc
1 parent 47cd6ed commit b19faf9

File tree

5 files changed

+631
-0
lines changed

5 files changed

+631
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
/.project
33
/.settings/
44
/target/
5+
6+
# IntelliJ
7+
/.idea/
8+
*.iml

0 commit comments

Comments
 (0)