Line Detector
This function block detects and highlights straight lines in an input image. It offers simple controls to guide the detection toward a preferred orientation, tune sensitivity, and pick a single "selected" line according to different selection modes. The block also produces a histogram visualization of intensity values along the chosen line to help with further analysis.
π₯ Inputs
Image Any Image to analyze for line structures (color or grayscale).
π€ Outputs
Lined Image Image with detected lines visualized.
Histogram Image Intensity histogram image with optional overlay showing statistics for the selected line.
Number of Lines Count of detected lines after any filtering.
Selected Line A single selected line (shape) chosen according to the selected selection mode.
Lines All detected lines (shapes), returned as a list when applicable.
πΉοΈ Controls
Preferred Angle Choose the orientation (in degrees) you are most interested in (0β180). This biases detection toward lines with that orientation.
Tolerance (deg) Set how much deviation from the preferred angle is allowed. Smaller values restrict detection to lines close to the preferred orientation.
Line Selection Pick how to choose the single representative line from multiple detections. Options include First Position, Last Position, Longest, Shortest, Middle Position, and Median Length.
Hough Threshold (Votes) Adjust sensitivity for line detection. Higher values make detection stricter (fewer lines); lower values detect weaker lines.
Min. Line Length (pixels) Ignore very short segments by setting a minimum length for detected lines.
Max. Line Gap (pixels) When using segment-based detection, this controls how far apart broken segments may be to still be joined into a single line.
π Running mechanism
The input image is prepared for line analysis (converted and enhanced as needed).
Prominent edges and segments are located across the image.
Detected segments are collected and (optionally) filtered to keep those close to the
Preferred Anglewithin theTolerance (deg).One line is selected based on the
Line Selectioncontrol.The result image is rendered with all found lines shown and the selected line highlighted.
A histogram image of intensity values is produced; if a line is selected, the histogram will also show basic statistics (mean, optionally standard deviation) for pixels sampled along that line.
β¨ Features
Visual output that draws all detected lines and highlights a chosen line for easy inspection.
Flexible selection modes to choose a single line that best fits your task.
Angle-based filtering to focus on a desired orientation.
Simple histogram output tied to the chosen line for quick intensity analysis.
Adjustable parameters to trade off sensitivity vs noise tolerance.
π Usage Instructions
Connect an image-producing block to the
Image Anyinput (for example, a camera or an image loader).Set
Preferred Angleto the orientation you expect in the scene.Reduce
Tolerance (deg)to focus tightly on that orientation, or increase it to accept more varied angles.Tune
Hough Threshold (Votes),Min. Line Length, andMax. Line Gapto find a balance between missing weak lines and including noise.Use
Line Selectionto pick the single line representation that makes sense for your task.Inspect the
Lined ImageandHistogram Imageoutputs; use the line shapes for downstream processing.
π‘ Tips and Tricks
For noisy images, add a
Blurblock before this block to smooth noise and improve detection stability.If your source images are very large, use
Image Resizeto lower resolution and speed up detection while keeping meaningful structures.To focus processing on a particular region, crop first with
Image ROI SelectorGet ROIthen run this block on the cropped image.After detection, combine the
Selected LineorLinesoutputs withLine Geometryto measure angles, distances, intersections or extract coordinates.For visual debugging, feed the
Lined ImageintoShow Imageto view results in a larger viewer, or save examples usingImage LoggerorImage Write.Use
Histogram On Linewhen you need more specialized peak analysis along a single straight scan line; it complements the histogram produced here.To draw or annotate specific measurement lines interactively, combine with
Draw Lineand then analyze the drawn line with this block.
(hints above use only blocks from the provided list)
π οΈ Troubleshooting
No lines detected: Lower
Hough Threshold (Votes), decreaseMin. Line Length, or increaseTolerance (deg)so more candidates are accepted.Too many spurious lines: Increase the
Hough Threshold (Votes)or raiseMin. Line Lengthto ignore small noisy segments.Selected line is unexpected: Try different
Line Selectionmodes (e.g., Longest or Middle Position) or adjust the preferred angle and tolerance.Histogram seems unrelated to the selected line: Ensure the selected line lies fully inside the image area; crop with
Image ROI Selectif necessary.
If you need more stable results in production, preprocess images (lighting, contrast) and test parameter ranges on representative samples before deploying.
Last updated
Was this helpful?