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 Angle within the Tolerance (deg).

  • One line is selected based on the Line Selection control.

  • 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

  1. Connect an image-producing block to the Image Any input (for example, a camera or an image loader).

  2. Set Preferred Angle to the orientation you expect in the scene.

  3. Reduce Tolerance (deg) to focus tightly on that orientation, or increase it to accept more varied angles.

  4. Tune Hough Threshold (Votes), Min. Line Length, and Max. Line Gap to find a balance between missing weak lines and including noise.

  5. Use Line Selection to pick the single line representation that makes sense for your task.

  6. Inspect the Lined Image and Histogram Image outputs; use the line shapes for downstream processing.

πŸ’‘ Tips and Tricks

  • For noisy images, add a Blur block before this block to smooth noise and improve detection stability.

  • If your source images are very large, use Image Resize to lower resolution and speed up detection while keeping meaningful structures.

  • To focus processing on a particular region, crop first with Image ROI Select or Get ROI then run this block on the cropped image.

  • After detection, combine the Selected Line or Lines outputs with Line Geometry to measure angles, distances, intersections or extract coordinates.

  • For visual debugging, feed the Lined Image into Show Image to view results in a larger viewer, or save examples using Image Logger or Image Write.

  • Use Histogram On Line when 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 Line and 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), decrease Min. Line Length, or increase Tolerance (deg) so more candidates are accepted.

  • Too many spurious lines: Increase the Hough Threshold (Votes) or raise Min. Line Length to ignore small noisy segments.

  • Selected line is unexpected: Try different Line Selection modes (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 Select if 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?