> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/image-transformations/analysis/histogram-on-curve.md).

# Histogram On Curve

This function block analyzes pixel values along a detected curved line across a grayscale or binary image. It detects line points, fits a smooth curve, evaluates pixel values along that curve against a threshold, and returns visualizations and numeric results to help you inspect line quality and detect gaps or peaks.

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

`Input Image (Binary Image)` Grayscale or binary image to analyze. Preferred when foreground/background contrast is strong.

`Line Location (pixel)` Number of sample lines to use when detecting the curve (the block samples multiple straight lines and derives curve points).

`Line detection threshold` Pixel intensity threshold used during line pixel detection (valid range 0–255).

`Pixel Value Threshold` Pixel intensity threshold used when evaluating pixel values along the detected curve (valid range 0–255).

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

`Output Image` Annotated source image showing the sampled lines/curve and detected points.

`Plot Image` Plot visualization showing pixel profiles and gradient information used during detection.

`Curve Image` Visualization of the detected curve and pixel values along it.

`Line Angle` Estimated angle of the fitted curve (useful for geometry checks).

`Is Line Valid?` Boolean flag indicating whether the detected curve passes internal validity checks (useful to gate further processing).

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

`Relation` Dropdown to select line sampling relation (vertical vs horizontal orientation). This changes how the block samples image lines during curve detection.

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

* Detects curve points by sampling several straight lines across the image and fitting a smooth polynomial through these points.
* Produces both image annotations and plotted diagnostics to help verify detection quality.
* Validity check that flags unreliable detections so downstream blocks can handle failures.
* Adjustable thresholds and line sampling count via inputs for fine control over sensitivity.

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

1. Provide a clear grayscale or binary image to `Input Image (Binary Image)`.
2. Set `Line Location (pixel)` to the number of sampling lines (higher numbers increase robustness but are slower).
3. Tune `Line detection threshold` to reliably identify line pixels on sampled lines.
4. Tune `Pixel Value Threshold` to mark significant pixel regions along the fitted curve.
5. Inspect `Output Image`, `Plot Image`, and `Curve Image` to validate detection. Use `Is Line Valid?` to decide whether to continue processing.

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

When evaluated, the block:

* Samples multiple straight lines across the image (orientation chosen via `Relation`),
* Detects line pixels and computes curve points,
* Fits a smooth curve and computes angle and pixel statistics,
* Returns annotated images, plots, and validation flags for downstream use.

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

* Preprocess noisy images with `Blur` to reduce spurious peaks before curve detection.
* Use `Image Threshold` to create a binary image if the curve contrast is low — this often improves line detection reliability.
* Crop the area of interest with `Image ROI Select` so the block focuses on the relevant region and avoids unrelated edges.
* Send visual outputs to `Show Image` to inspect `Output Image` / `Plot Image` / `Curve Image` interactively while tuning parameters.
* If you want to save analysis results for later review, use `Image Logger` or `Image Write` with the images returned from this block.

(hint: combine preprocessing blocks such as `Blur` and `Image Threshold` upstream, then feed into this block; visualize results with `Show Image` and optionally archive them with `Image Logger` or `Image Write`.)

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

* If you get an error about invalid line detection, try increasing the number of sampled lines (`Line Location (pixel)`) or preprocess with `Blur` and `Image Threshold`.
* If no peaks appear in plots, reduce thresholds or improve contrast of the `Input Image (Binary Image)`.
* If the detected curve is shifted or noisy, crop the image with `Image ROI Select` to remove distracting regions and try again.
