Repository navigation
feat(filtering): add hough line detection operator - #389
Merged
Merged
Conversation
Member
Automated review summaryTriage: enhancement | Recommendation: ready-for-maintainer Findings
Conventions
This PR adds a Generated by |
Add a filtering_houghlines operator that runs Canny on a grayscale copy of the input, feeds the edge map to cv2.HoughLinesP and draws the detected segments onto the original image. rho, thetaDegrees, threshold, minLineLength, maxLineGap, color and thickness are read from params with defaults and range-checked; thetaDegrees is converted to radians. Grayscale input is promoted to BGR and BGRA keeps its alpha so the output channel count does not depend on whether any lines were found. When HoughLinesP returns None the image comes back unchanged. Register the operator, add the Blockly block to the Filtering category with matching field limits, add an operatorDocs entry, and cover the backend with synthetic line images, parameter validation and an API round trip, plus a frontend test for the block definition. Closes c2siorg#51
ivantha
force-pushed
the
fix/51-hough-lines
branch
from
October 13, 2026 17:17
3578a6b to
8f27d7c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
filtering_houghlinesoperator built oncv2.HoughLinesP, following theBaseOperator.computeshape ofcanny_edge.py.imagelab-backend/app/operators/filtering/hough_lines.py: converts the input to grayscale and runs Canny (fixed 50/150, aperture 3) on a copy, runsHoughLinesPon the edge map and draws the segments onto a copy of the original image. Readsrho,thetaDegrees,threshold,minLineLength,maxLineGap,color,thicknessfromself.paramswith defaults;thetaDegreesis converted to radians;colorgoes throughhex_to_bgr. Out-of-range values raiseValueErrorwith the same message style ascontour_detection.py. Grayscale input is promoted to BGR and BGRA input keeps its alpha (lines drawn opaque), so the output channel count does not depend on whether lines were found. WhenHoughLinesPreturnsNonethe image is returned unchanged.imagelab-backend/app/operators/registry.py: registersfiltering_houghlinesnext tofiltering_cannyedge.imagelab-frontend/src/blocks/definitions/filtering.blocks.ts: new block with the seven fields, min/max limits matching the backend checks, and a tooltip noting the fixed Canny thresholds.imagelab-frontend/src/blocks/categories.ts: adds "Hough Line Detection" to the Filtering category.imagelab-frontend/src/data/operatorDocs.ts: docs entry for the operator and its parameters.Only additions; no existing block types are renamed, so saved workspaces still load. The Canny thresholds are kept fixed because the issue scopes the block to the seven Hough/drawing parameters; exposing them is a follow-up if wanted.
Fixes #51
Type of Change
How Has This Been Tested?
Backend,
imagelab-backend/tests/operators/filtering/test_hough_lines.py(31 tests): registry lookup; horizontal, vertical and 45 degree synthetic lines (3 px wide so Canny/Hough detection is deterministic) assert the drawn pixels lie within a few px of the known position and angle and span most of the line; segments are drawn on the original image, not the edge map; blank image returned unchanged; input not mutated; grayscale promoted to BGR with and without detections; BGRA keeps alpha; float input in [0,1]; thickness and colour honoured; a monkeypatchedHoughLinesPtest checks theta is passed in radians and the input is a binary edge map; 13 parameter validation cases plus invalid colour and unsupported shape; one round trip throughPOST /api/v1/pipeline/executions.Frontend,
imagelab-frontend/tests/blocks/houghLinesBlock.test.ts(5 tests): block defines the seven fields with the backend defaults, numeric fields clamp to the backend ranges, the block is listed in the Filtering category, docs cover every param, andextractPipelineon a real Blockly workspace emits the params by the names the backend reads.Both files fail without the source change. Ran
uv run ruff check .,uv run ruff format --check .,uv run pytest -q(822 passed;test_histogram_stats::test_calculate_channel_statistics_rgbfails on main as well, unrelated),npx eslint .,npx prettier --check,npx tsc -b,npx vitest run(212 passed).Manual: ran backend and frontend locally, built Read image -> Hough Line Detection on a synthetic image with four lines and a rectangle, ran the pipeline and checked the processed output (screenshots below).
Screenshots (if applicable)
Pipeline and output after running:
Operator input and output:
Checklist