# Line Detector

This function block is for detecting lines in images using different line detection techniques. It provides options to select the detection method and to configure parameters that affect line detection.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Image Any` The input image in which lines will be detected.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Lined Image` The output image with detected lines drawn on it.

`Number of Lines` The total count of lines that were detected in the input image.

`Lines` Provides the coordinates of the detected lines, which can be used for further processing.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Line Detection Type` A dropdown menu to select the detection method: either "Deterministic" or "Probabilistic".

`Confidence` A slider to set the sensitivity threshold for the line detection process.

`Min. Line Gap` A slider to set the minimum distance between detected line segments (applicable for the Probabilistic method).

`Max. Line Gap` A slider to define the maximum distance between segments to treat them as a single line (applicable for the Probabilistic method).

## 🎨 Features <a href="#features" id="features"></a>

`Two Line Detection Methods` Users can choose between two line detection methods, allowing flexibility based on the image content.

`Dynamic Parameter Adjustment` Adjustability of parameters like confidence and gaps provides control over the line detection process to cater for various types of images.

`Visual Output` Lines detected are visually represented on the output image, making it easy to analyze results.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. **Input an Image**: Connect any image to the `Image Any` input.
2. **Select Detection Method**: Choose between "Deterministic" or "Probabilistic" from the `Line Detection Type` dropdown.
3. **Adjust Parameters**: Use the sliders to set confidence, minimum line gap, and maximum line gap according to your requirements.
4. **Run the Block**: Evaluate the block to detect lines in the image.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

Upon evaluation, the function block processes the input image for line detection based on the specified parameters, returning the modified image, line count, and detected line coordinates.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

<details>

<summary>Using Gaussian Blur</summary>

Applying a Gaussian blur on the input image prior to line detection can help reduce noise, improving detection results.

</details>

<details>

<summary>Experiment with Threshold</summary>

Adjust the `Confidence` slider to find the best threshold value for line detection. A lower value could detect more lines while a higher value may filter out noise.

</details>

<details>

<summary>Using Proper Image Formats</summary>

Ensure that the input image is properly formatted; if it is colored, the block will automatically convert it to grayscale.

</details>

<details>

<summary>Testing on Various Images</summary>

For best results, test the line detector on images with distinct and clear lines. Complex backgrounds can affect detection accuracy.

</details>

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

<details>

<summary>No Lines Detected</summary>

If no lines are detected, try adjusting the threshold (`Confidence`) slider as well as using images that have clear lines.

</details>

<details>

<summary>Excessive Noise in Output</summary>

If excessive or irrelevant lines are detected, consider adding preprocessing steps like blurring or thresholding the image before line detection.

</details>
