# Region Filter

You can set region filters to affect the result of processing. Whether the tool marks a captured region in a view as a defect region is decided by the region filter once it is set.

To activate a region filter, reprocess the tool after you setting the region filter phrase.

The variables below can be used to directly affect the result of processing. For more information about filters, see .

Red Analyze Tool - Region Axis Variables |  |
score | Floating Point | Returns the highest defect probability among those probabilities of pixels in the region.
deviation | Returns the same results as score.
holes |
area | Returns the number of pixels in the defect region. Example: "area>= 150"
perimeter |
compactness | Returns the equivalent of: 4 * π * area / perimeter^2.
coverage | Returns the overlapping ratio between labeled area and marked area. Example: "coverage>= 0.5"
x | Returns the x-axis position of the center of the defect region. Example: "x>150"
y | Returns the y-axis position of the center of the defect region. Example: "y>50"
name | String |

## Region Filter and Confusion Matrix

If the Count is set to Views or Untrained Views, the confusion matrix is calculated based on views, not regions. By contrast, if it is set to Regions or Untrained Regions, the confusion matrix is calculated based on regions, not views.

You can apply region filters to the result of the Confusion Matrix. To apply a region filter, set a region filter phrase, then reprocess the tool.

You can also apply the region filter with the "filtered()" expression. See the following examples:

- e.g> "filtered(region!/score) < T1"

- e.g> "filtered(score[labeled]) in [T1, T2]"

### Views/Untrained Views

Region filters affect the processing result. The region filter determines the marking region. For example, in Views/Untrained Views if "area>150" is set in the region filter and the tool is reprocessed, only the views that have marking regions of more than 150 pixels can be marked as "Bad" or "Inter". Otherwise, they are marked as "Good".

### Regions/Untrained Regions

Region filters affect the processing result. The region filter determines the marking region. For example, in Regions/Untrained Regions if "area>150" is set in the region filter and the tool is reprocessed, the views where the marking region is under 150 pixels lose the marking regions in the processed result.

A view does not count into the "Bad"(actual) - "Bad"(predicted) pair if all marking regions overlapped with the pixel-wise labeled defect regions are lost by the region filter.