# Region Filter

Region filters can be set upon before processing so it can affect the result of processing. Therefore, whether a captured region in a view is marked as a defect region or not is decided by the region filter once it is set upon. To activate a region filter, you should re-process the tool after you set a region filter phrase.

The variables below can be used to directly affect the processing outcome. For more information about how to use filters, see Filter Grammar.

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 will be calculated based on views, not regions. By contrast, if it is set to Regions or Untrained Regions, the confusion matrix will be calculated based on regions, not views. See Confusion Matrix for the details.

Region filters can be applied to the result of the confusion matrix. Set a region filter phrase, re-process the tool, and you will see the region filer applies to the confusion matrix.

Note: Region filter can also be applied with "filtered()" expression.
e.g> "filtered(region!/score) < T1"
e.g> "filtered(score[labeled]) in [T1, T2]"

### Confusion Matrix - Views/Untrained Views

Region filters affect producing the processing result. The role of a region filter is that it decides the marking region. For example, in Views/Untrained Views if "area>150" is set in the region filter and the tool is re-processed, only the views that have marking regions of more than 150 pixels can be marked as "Bad" or "Inter," otherwise good.

### Confusion Matrix - Regions/Untrained Regions

Region filters affect producing the processing result. The role of a region filter is that it decides the marking region. For example, in Regions/Untrained Regions if "area>150" is set in the region filter and the tool is re-processed, the views whose marking regions area is under 150 pixels will lose those marking regions in the processed result.

For a view, if all marking regions overlapped with the pixel-wise labeled defect regions were lost by the region filter, this view will not populate the "Bad"(actual) - "Bad" predicted pair.