F_VN_FindRois
Extracts rectangular regions of interest (ROIs) from an image by partitioning it into tiles using the selected method and parameters.
Syntax
Definition:
FUNCTION F_VN_FindRois : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipRois : Reference To ITcVnContainer;
eFindRoisMethod : ETcVnFindRoisMethod;
END_VAR
VAR_IN_OUT
stParams : TcVnParamsFindRois;
END_VAR
VAR_INPUT
hrPrev : HRESULT;
END_VARInputs
|
Name |
Type |
Description |
|---|---|---|
|
ipSrcImage |
Source image (1 channel, non-negative values). | |
|
ipRois |
Reference To ITcVnContainer |
Returns the ROIs (ContainerType_Vector_TcVnRectangle_DINT; Non-zero interface pointers are reused.) |
|
eFindRoisMethod |
Method to create ROIs | |
|
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_FindRois extracts regions of interest (ROIs) from an input image in which high and concentrated intensity values mark relevant image areas (e.g., a binary image or a saliency map). The purpose of this function is to crop large images down to these key areas. The result is a container made up of rectangles that serve as specific search windows for additional vision functions. As a result, computationally intensive functions no longer need to be applied to the entire image, which saves computing time and, by masking out irrelevant image areas, can also improve the accuracy of subsequent analyses.
A proven combination is F_VN_SalientFeatures followed by F_VN_FindRois to identify relevant rectangular image regions from the computed saliency map. To more clearly distinguish between relevant information and background information, it is often helpful to apply filtering beforehand (e.g., using F_VN_Threshold).
Parameter
Input image
The input image ipSrcImage must be single-channel and may contain only non-negative values. Suitable inputs include, for example, binary or saliency images with relevant structures in bright areas.
Regions found
The ipRois parameter returns the detected ROIs as a container of type ContainerType_Vector_TcVnRectangle_DINT.
Method for ROI extraction
The parameter eFindRoisMethod, of type ETcVnFindRoisMethod, specifies the method used to extract the ROIs. The choice of method depends on the type of input image and the nature of the regions being sought:
TCVN_FRM_GRID: The input image is overlaid with a regular grid measuringstRoiSize. For each tile, the local density is evaluated, and only tiles with sufficient density (>fMinDensity) are returned as ROIs. Tiles near the edge of the image may be smaller. This method is particularly suitable when a uniform window layout is desired.TCVN_FRM_CONNECTEDCOMPONENTS: The input image is divided between the background value (0) and all other pixel values. All adjacent active regions are combined into connected regions using the connected components algorithm. The bounding rectangles of these regions are returned as ROIs. This method is particularly suitable when the input image is already cleanly segmented or is available as a binary image, and the structures of interest appear as contiguous bright regions.
ROI extraction parameters
The parameter stParams, of type TcVnParamsFindRois, configures the behavior of the selected extraction method. The fields have the following meaning:
stRoiSize(Default: 416 x 416 pixels): Desired ROI size in pixels.- In the case of
TCVN_FRM_GRID, this is directly the tile size of the resulting grid. The resulting ROI may be cropped at the edges. - For
TCVN_FRM_CONNECTEDCOMPONENTS, this is not a strict requirement but a target size that guides the expansion and splitting of the components. Depending on their location and the method used, the resulting ROIs may be smaller, larger, or cropped at the edges. fMinDensity(Default: 0.2): Relative density threshold for filtering ROIs. An ROI is retained only if its local density divided by the global density of the input image is greater than or equal tofMinDensity. Higher values filter more strictly; lower values are more sensitive to less relevant areas. AtfMinDensity = 0, density filtering is disabled.fDetectionScaleFactor(Default: 0.25): Used to reduce the resolution. Lower values speed up the density calculation but may reduce accuracy for small or fine structures. Valid values range from 0.1 to 1.0.fMaxOversizeFraction(Default: 1.0): The fraction by which a detected ROI may exceed the dimensions defined instRoiSize. A value of 1.0 permits for a maximum angular magnification by a factor of 2. This parameter is evaluated only when using theTCVN_FRM_CONNECTEDCOMPONENTSmethod.
Required License
TC3 Vision Base
System Requirements
Development environment | Target platform | PLC libraries to include |
|---|---|---|
TwinCAT V3.1.4024.59 or later | PC or CX (x64) with min. PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |