色票間のノルム計算
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_colorchart_calc_norm( F_COLOR_CHART_PTR right, F_COLOR_CHART_PTR target, ref double norm, f_colorcheck_norm_type norm_type, DOUBLE_PTR weight ) |
Visual Basic |
---|
Public Shared Function fnFIE_colorchart_calc_norm ( right As F_COLOR_CHART_PTR, target As F_COLOR_CHART_PTR, ByRef norm As Double, norm_type As f_colorcheck_norm_type, weight As DOUBLE_PTR ) As Integer |
Parameters
- right
- Type: fvalgcli..::..F_COLOR_CHART_PTR
基準色票
- target
- Type: fvalgcli..::..F_COLOR_CHART_PTR
対象色票
- norm
- Type: System..::..Double%
ノルム
- norm_type
- Type: fvalgcli..::..f_colorcheck_norm_type
ノルムタイプ- F_CC_EUCLIDEAN(ユークリッドノルム)
- F_CC_WEIGHTED_EUCLIDEAN(重み付きユークリッドノルム)
- F_CC_MAHALANOBIS(マハラノビスノルム)
- F_CC_MANHATTAN(マンハッタンノルム)
- F_CC_CHEBYSHEV(チェビシェフノルム)
- weight
- Type: fvalgcli..::..DOUBLE_PTR
重み付きユークリッドノルムの重み係数
Return Value
Type: Int32以下のエラーコードを返します。
エラーコード:
f_err | 内容 |
---|---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 画像オブジェクトの異常 |
F_ERR_INVALID_OBJECT | 不正なオブジェクトが渡された |
F_ERR_INVALID_PARAM | パラメータ異常 |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Remarks
Examples
C# | Copy |
---|---|
// $Revision: 1.1 $ using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace TC { public partial class FIE { /// <summary> /// 色票間のノルム計算. /// </summary> [FvPluginExecute] public void fnFIE_colorchart_calc_norm() { int status = (int)f_err.F_ERR_NONE; string filepath = TestImageDir + "fie_colorcheck1.png"; FHANDLE hSrc = FHANDLE.Zero; FHANDLE hChild = FHANDLE.Zero; F_COLOR_CHART_PTR charts = IntPtr.Zero; DOUBLE_PTR weight = IntPtr.Zero; try { // 入力画像. api.fnFIE_load_png(filepath, ref hSrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8); // 色票を作成. charts = F_COLOR_CHART_PTR.alloc(2); // --- 基準色票. hChild = api.fnFIE_img_child_alloc(hSrc, 165, 350, 25, 25); api.fnFIE_colorchart_calc_image(hChild, IntPtr.Zero, charts.at(0)); hChild.Dispose(); // --- 対象色票. hChild = api.fnFIE_img_child_alloc(hSrc, 320, 215, 25, 25); api.fnFIE_colorchart_calc_image(hChild, IntPtr.Zero, charts.at(1)); hChild.Dispose(); // 実行. Console.WriteLine("fnFIE_colorchart_calc_norm"); // --- 重み付きユークリッドノルムの計算. { weight = DOUBLE_PTR.alloc(3); weight[0] = 0.5; weight[1] = 1.0; weight[2] = 1.5; double norm = 0; status = api.fnFIE_colorchart_calc_norm( charts.at(0), // 基準色票. charts.at(1), // 対象色票. ref norm, f_colorcheck_norm_type.F_CC_WEIGHTED_EUCLIDEAN, weight); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_colorchart_calc_norm: エラーが発生しました。({0})", (f_err)status); Console.WriteLine("norm={0}", norm); } // --- マハラノビスノルムの計算.(weightは必要ない) { double norm = 0; status = api.fnFIE_colorchart_calc_norm( charts.at(0), // 基準色票. charts.at(1), // 対象色票. ref norm, f_colorcheck_norm_type.F_CC_MAHALANOBIS, IntPtr.Zero); Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "fnFIE_colorchart_calc_norm: エラーが発生しました。({0})", (f_err)status); Console.WriteLine("norm={0}", norm); } } finally { hSrc.Dispose(); hChild.Dispose(); charts.Dispose(); weight.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.1 $ Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE ''' <summary> ''' 色票間のノルム計算. ''' </summary> <FvPluginExecute> _ Public Sub fnFIE_colorchart_calc_norm() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim filepath As String = TestImageDir & "fie_colorcheck1.png" Dim hSrc As FHANDLE = FHANDLE.Zero Dim hChild As FHANDLE = FHANDLE.Zero Dim charts As F_COLOR_CHART_PTR = IntPtr.Zero Dim weight As DOUBLE_PTR = IntPtr.Zero Try ' 入力画像. api.fnFIE_load_png(filepath, hSrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8) ' 色票を作成. charts = F_COLOR_CHART_PTR.alloc(2) ' --- 基準色票. hChild = api.fnFIE_img_child_alloc(hSrc, 165, 350, 25, 25) api.fnFIE_colorchart_calc_image(hChild, IntPtr.Zero, charts.at(0)) hChild.Dispose() ' --- 対象色票. hChild = api.fnFIE_img_child_alloc(hSrc, 320, 215, 25, 25) api.fnFIE_colorchart_calc_image(hChild, IntPtr.Zero, charts.at(1)) hChild.Dispose() ' 実行. Console.WriteLine("fnFIE_colorchart_calc_norm") ' --- 重み付きユークリッドノルムの計算. If True Then weight = DOUBLE_PTR.alloc(3) weight(0) = 0.5 weight(1) = 1.0 weight(2) = 1.5 Dim norm As Double = 0 ' 基準色票. ' 対象色票. status = api.fnFIE_colorchart_calc_norm(charts.at(0), charts.at(1), norm, f_colorcheck_norm_type.F_CC_WEIGHTED_EUCLIDEAN, weight) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_colorchart_calc_norm: エラーが発生しました。({0})", CType(status, f_err)) Console.WriteLine("norm={0}", norm) End If ' --- マハラノビスノルムの計算.(weightは必要ない) If True Then Dim norm As Double = 0 ' 基準色票. ' 対象色票. status = api.fnFIE_colorchart_calc_norm(charts.at(0), charts.at(1), norm, f_colorcheck_norm_type.F_CC_MAHALANOBIS, IntPtr.Zero) Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "fnFIE_colorchart_calc_norm: エラーが発生しました。({0})", CType(status, f_err)) Console.WriteLine("norm={0}", norm) End If Finally hSrc.Dispose() hChild.Dispose() charts.Dispose() weight.Dispose() End Try End Sub End Class |