# Tile Width Measurement

### Measuring Tile Width <a href="#measuring-tile-width" id="measuring-tile-width"></a>

Measurements can be challenging based on the context of the project. AugeLab Studio's ready to use function blocks allows easy and fast measurements on a such challenging subject.

This example will show you how to measure the width (effectively distance) of a wooden tile.

First. Use [Load Image](/function-blocks/input-output/image-inputs/load-image.md) function block and load **wood.jpg** from example images folder provided by AugeLab Studio.

<figure><img src="/files/Ww6LZCeDX1ODwgKSXtbU" alt=""><figcaption></figcaption></figure>

Our aim is to measure each tiles width and print them out. Next, we'll need to pre-process this image to lower noise that can be introduced by the camera or environment. For such cases, [Blur](/function-blocks/image-transformations/color-filters/blur.md) function block is a very good match with **Median Blur** option. Go ahead and create the logic below:

<figure><img src="/files/dEOPgNSYViz48eMP8ag9" alt=""><figcaption></figcaption></figure>

We are keeping *Kernel Size* at 3 to keep pre-processing to minimum, since any kind of pre-processing can affect the final outcome during measurements. Next, we'll be using [Histogram on Line](/function-blocks/image-transformations/analysis/histogram-on-line.md) function block.

**Histogram on Line** function block automatically detects sharp edges, stores their locations as points by the given threshold and position values. By creating the logic below:

<figure><img src="/files/zEBQZs4sHiAHP3Q2Bpej" alt=""><figcaption></figcaption></figure>

We are telling **Histogram on Line** block to calculate edges at 100th horizontal pixel position, and look for edges that exceed values over 100 (which can be between 0-255).

The horizontal location of detection line (second socket) is most important, since other factors can easily cause false detections. Lets provide 350 and see what happens in such scenario:

<figure><img src="/files/jfbkzj0IGYPV5gJ293Dh" alt=""><figcaption></figcaption></figure>

Choosing a horizontal line with more disturbances has caused false detections. Therefore, it is always recommended to choose a line that is minimally affected by noise and environment.

Since we have successfully calculated the edge locations of each tile, we can calculate the width of first tile by introducing several blocks.

First, we'll be using *Peak Mean Locations* output by the **Histogram on Line** block. This output consist of a [list](/function-blocks/sockets.md#purple-position)[ of positions](/function-blocks/sockets.md#purple-position):

<figure><img src="/files/ZapLYPCtyXmwEZbeh9vh" alt=""><figcaption></figcaption></figure>

Each position contains horizontal and vertical positions (x, y) of peak locations. We can calculate the distance between each point by either using [Demux](/function-blocks/data-logic/logic/demux.md) block, or using [Measure Position Distance](/function-blocks/image-transformations/analysis/measure-position-distance.md) function block.

Use [List Operations](/function-blocks/data-logic/data-operations/list-operations.md) block and choose **get** from the drop-down menu. Follow the logic below:

<figure><img src="/files/6Mfky8EFH4czZHYaQY9R" alt=""><figcaption></figcaption></figure>

The logic above selects the first element by providing zero (0) and the second element by providing one (1). Using [Measure Position Distance](/function-blocks/image-transformations/analysis/measure-position-distance.md); x-y, and Euclidean distances are calculated and presented.

You may have noticed that y distance is zero, due to all points being at the same horizontal line.

That's it! You successfully calculated the width of the first tile.

### Calculating all tile widths <a href="#calculating-all-tile-widths" id="calculating-all-tile-widths"></a>

Now, let's calculate the other widths by using list and batch operations.

By using the same **List Operations** function block, we'll use the *pop* option from the dropbox. Pop option removes the item at given index from a list. Let's create the logic below again:

<figure><img src="/files/CluTLBx0O8UAxIaB3Qzf" alt=""><figcaption></figcaption></figure>

**List Operations** block first copies the provided list and then calculates the desired outcome. We created a list of peak locations without the first element, and then created another list by only removing the last one.

Using them with [Batch Processing](/function-blocks/data-logic/flow-control/batch-processing.md) with [Data Type Converter](/function-blocks/data-logic/data-operations/data-type-converter.md), we can calculate positional difference between each peak points:

<figure><img src="/files/VEkAZ3hLUdvvzwxiV8Y5" alt=""><figcaption></figcaption></figure>

It's important to use [Data Type Converter](/function-blocks/data-logic/data-operations/data-type-converter.md) when dealing with Batch Processing. If a function block receives a batch, it runs in batch mode. Use *Batch2List* option from its menu to revert to normal operation mode.

That's all! You've calculated the width of all tiles!


---

# 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/example-projects/tile-width-measurement.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.
