# Histogram On Line

This function block analyzes pixel values along a single defined line in a grayscale or binary image. It detects segments where pixel values exceed a threshold and visualizes the line and found segments on an output image.

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

`Input Image (Binary Image)` A binary or grayscale image used for line analysis.

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

`Output Image` The source image annotated with the drawn line and markers for detected peak segments.

`Peak Count` Number of detected threshold segments along the line.

`Peak Start Locations` List of start coordinates for each detected segment.

`Peak End Locations` List of end coordinates for each detected segment.

`Peak Mean Locations` List of mean (center) coordinates for each detected segment.

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

`Relation` Dropdown to choose line orientation (vertical or horizontal).

`Line Location` Slider / input to pick the pixel position of the line (in pixels). Accepts single value; validated against image size.

`Pixel Threshold` Slider / input for the pixel value threshold (0–255) used to determine active segments.

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

* Visual feedback with a red line and colored markers showing segment start, end, and mean positions.
* Accepts vertical or horizontal lines and validates line location against image dimensions.
* Ignores segments that touch image edges (configurable by internal behavior) to avoid edge artifacts.
* Returns both visual and structured outputs for downstream processing.

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

1. Provide a grayscale or binary image to the `Input Image (Binary Image)` input.
2. Choose the line orientation using `Relation`.
3. Set the `Line Location` (pixel index) within image bounds.
4. Set `Pixel Threshold` between 0 and 255 to control sensitivity.
5. Run the block to get an annotated image and lists of detected segment coordinates.

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

On execution, the block samples pixel values along the chosen line, finds contiguous segments where values meet or exceed the threshold, marks them on the output image, and returns the count and coordinate lists.

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

* Preprocess noisy inputs with `Blur` to reduce spurious detections and with `Image Threshold` to create a clean binary image before analyzing a line.
* Use `Image ROI Select` or `Image ROI` to crop the region of interest so line coordinates are simpler and more meaningful.
* Combine with `Draw Line` when you want interactive line placement on the displayed image, then copy the pixel position into `Line Location`.
* Use `HSV Filter` to isolate color channels or features before converting to grayscale for more reliable peak detection.
* Inspect results visually by connecting the output image to `Show Image` so you can open a larger viewer and verify detected segments.
* If your flow may produce empty images, consider `Is None` to guard downstream logic against missing results.

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

* If you get no peaks, try lowering `Pixel Threshold` or preprocess with `Image Threshold` / `Blur`.
* If line position causes errors, ensure `Line Location` is within image width (for vertical) or height (for horizontal). The block will report and clamp out-of-range values.
* If many tiny segments appear, increase the threshold or smooth the image first with `Blur`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/image-transformations/analysis/histogram-on-line.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
