F_VN_Histogram

F_VN_Histogram 1:

Calculate the (multi-channel) histogram of an image.
Can use available TwinCAT Job Tasks for executing parallel code regions.

Syntax

Definition:

FUNCTION F_VN_Histogram : HRESULT
VAR_INPUT
    ipSrcImage      : ITcVnImage;
    ipDestHistogram : Reference To ITcVnContainer;
    hrPrev          : HRESULT;
END_VAR

F_VN_Histogram 2: Inputs

Name

Type

Description

ipSrcImage

ITcVnImage

Source image

ipDestHistogram

Reference To ITcVnContainer

Returns a container with a multi-channel histogram, where every channel is represented as a vector of UDINT (ContainerType_Vector_Vector_UDINT. Non-zero interface pointers are reused.)

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_Histogram 3: Return value

HRESULT

Weiterführende Informationen

Die Funktion F_VN_Histogram errechnet Kanal-weise das Histogramm des Eingangsbilds.

Parameter

Eingangsbild

Das Eingangsbild ipSrcImage darf jedes beliebige Format haben.

Histogramm

Das errechnete mehr-kanalige Histogramm wird als Container ipDestHistogram des Typs ContainerType_Vector_Vector_UDINT zurückgegeben. Jedes Sub-Element entspricht dem Histogramm eines Kanals. Jeder Behälter des Histogramms wird als UDINT repräsentiert, die die Anzahl der zum Behälter gehörenden Pixel angibt.

Expert-Parameter

Die Expert-Variante F_VN_HistogramExp enthält zusätzliche Parameter.

Anwendung

Das Ermitteln des am häufigsten vorkommenden Pixelwerts in einem Grauwertbild sieht z.B. so aus:

VAR
    ipHistograms        :   ITcVnContainer;
    ipSingleHistogram   :   ITcVnContainer;
    nIndex              :   ULINT;
    ipIterator          :   ITcVnBidirectionalIterator;
END_VAR

hr := F_VN_Histogram(
    ipSrcImage      :=  ipImageIn,
    ipDestHistogram :=  ipHistograms,
    hrPrev          :=  hr);

hr := F_VN_GetAt_ITcVnContainer(ipHistograms, ipSingleHistogram, 0, hr);
hr := F_VN_MaxElement(ipSingleHistogram, ipIterator, nIndex, hr);
// nIndex now contains the most frequent pixel value in ipImageIn.

Beispiele

Required License

TC3 Vision Base

System Requirements

Development environment

Target platform

PLC libraries to include

TwinCAT V3.1. 4024.44 or later

PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU

Tc3_Vision