> 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/transformation-filters/auto-alignment.md).

# Auto Alignment

This function block aligns an input image to a provided reference image so that objects in both images match position and scale. Use it when you need the input image to share the same framing or registration as a reference for comparison, measurement, or further processing.

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

`Input Image` The image that will be transformed to match the reference.

`Reference Image` The target image that defines the desired alignment (position, scale and perspective) for the input.

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

`Aligned Image` The resulting image after alignment. If alignment cannot be performed, this output will be empty or unchanged and an error message will be reported.

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

`No Controls` This block has no additional widgets. Alignment is driven only by the provided inputs.

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

* Quiet, single-purpose alignment: feed two images and get an aligned result without extra configuration.
* Automatic failure reporting: the block provides clear messages when alignment fails (for example when the reference cannot be matched).
* Light-weight and easy to insert into any image processing chain where registration is required.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

* When both `Input Image` and `Reference Image` are provided, the block attempts to match the input to the reference and produces `Aligned Image`.
* If alignment succeeds, the output contains the transformed image that matches the reference framing.
* If alignment cannot be established, the block reports an error and does not produce a valid aligned image.

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

1. Provide a clear, well-lit `Reference Image` that contains the same scene or object you expect in the `Input Image`.
2. Connect the image you want to align to `Input Image`.
3. Run the scenario. The block will output `Aligned Image` when successful.
4. If alignment fails, refine inputs (see troubleshooting) and try again.

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

* If your input and reference images contain extra background clutter or irrelevant regions, crop them first with `Image ROI Select` or `Image ROI` to focus alignment on the area of interest.
* If image sizes differ greatly, use `Image Resizer` or `Image Resize` to bring images to comparable dimensions before alignment.
* For low-detail or noisy images, improve contrast using `Contrast Optimization` or `Auto Contrast` and reduce noise using `Denoising` to increase alignment reliability.
* Visualize results with `Show Image` to confirm alignment interactively. Use `Image Logger` or `Image Write` to save aligned outputs for later review.
* When alignment is part of a pipeline (e.g., measurements or detection), run alignment before detectors like `Find Object` or `Template Match` to ensure consistent coordinates.
* When measuring between multiple regions, consider cropping aligned results with `Get ROI` and then using measurement or analysis blocks.

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

* Alignment fails or produces a distorted result:
  * Ensure both images contain the same visible features and sufficient overlap.
  * Improve image contrast using `Contrast Optimization` or remove noise with `Denoising`.
  * Crop to remove distracting background with `Image ROI Select` and retry.
* No output produced:
  * Confirm both `Input Image` and `Reference Image` are connected and valid image types.
  * Inspect error messages in the block UI and use `Show Image` to view inputs before alignment.

Use the above suggestions to combine this block effectively with other function blocks in your workflow for robust, repeatable image registration.
