Inf(無限大)を数値に置き換える
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_replace_inf(
FHANDLE hsrc,
FHANDLE hdst,
double pval,
double mval
) |
Visual Basic |
---|
Public Shared Function fnFIE_replace_inf (
hsrc As FHANDLE,
hdst As FHANDLE,
pval As Double,
mval As Double
) As Integer |
Parameters
- hsrc
- Type: fvalgcli..::..FHANDLE
入力画像ハンドル( type: double, float)
- hdst
- Type: fvalgcli..::..FHANDLE
出力画像ハンドル( type: double, float)
- pval
- Type: System..::..Double
+Inf を置き換える数値
DOUBLE 型で入力されます。
対象画像のタイプが F_IMG_FLOAT の場合は単純キャストされます。
pval ≧ mval でなければなりません。
- mval
- Type: System..::..Double
-Inf を置き換える数値
DOUBLE 型で入力されます。
対象画像のタイプが F_IMG_FLOAT の場合は単純キャストされます。
pval ≧ mval でなければなりません。
Return Value
Type:
Int32
以下のエラーコードを返します。
エラーコード:f_err | 内容 |
---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 不正な画像ハンドルが渡されたため、異常終了 |
F_ERR_INVALID_PARAM | パラメータエラー |
F_ERR_NO_LICENCE | ライセンスエラー、または未初期化エラー |
Examples
C# | Copy |
---|
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using fvalgcli;
namespace TC
{
public partial class FIE
{
[FvPluginExecute]
public void fnFIE_replace_inf()
{
int status = (int)f_err.F_ERR_NONE;
FHANDLE hsrc = FHANDLE.Zero;
FHANDLE hdst = FHANDLE.Zero;
try
{
const int width = 3;
const int height = 2;
hsrc = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height);
hdst = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height);
{
DOUBLE_PTR psrc = api.fnFIE_img_get_adrs(hsrc);
var src_step = api.fnFIE_img_get_step(hsrc);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (y % 2 == 0)
psrc[x] = Double.PositiveInfinity;
else
psrc[x] = Double.NegativeInfinity;
}
psrc += src_step;
}
}
status = api.fnFIE_replace_inf(hsrc, hdst, +1, -1);
{
int errors = 0;
DOUBLE_PTR pdst = api.fnFIE_img_get_adrs(hdst);
var dst_step = api.fnFIE_img_get_step(hdst);
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
if (y % 2 == 0)
{
if (pdst[x] != +1) errors++;
}
else
{
if (pdst[x] != -1) errors++;
}
Console.WriteLine("{0},{1}: {2,5:F1}", y, x, pdst[x]);
}
pdst += dst_step;
}
if (errors > 0)
{
Console.WriteLine("処理結果に誤りがあります。erros={0}", errors);
}
}
}
finally
{
hsrc.Dispose();
hdst.Dispose();
}
}
}
} |
Visual Basic | Copy |
---|
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli
Partial Public Class FIE
<FvPluginExecute> _
Public Sub fnFIE_replace_inf()
Dim status As Integer = CInt(f_err.F_ERR_NONE)
Dim hsrc As FHANDLE = FHANDLE.Zero
Dim hdst As FHANDLE = FHANDLE.Zero
Try
Const width As Integer = 3
Const height As Integer = 2
hsrc = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height)
hdst = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height)
If True Then
Dim psrc As DOUBLE_PTR = api.fnFIE_img_get_adrs(hsrc)
Dim src_step As SIZE_T = api.fnFIE_img_get_step(hsrc)
For y As Integer = 0 To height - 1
For x As Integer = 0 To width - 1
If y Mod 2 = 0 Then
psrc(x) = [Double].PositiveInfinity
Else
psrc(x) = [Double].NegativeInfinity
End If
Next
psrc += src_step
Next
End If
status = api.fnFIE_replace_inf(hsrc, hdst, +1, -1)
If True Then
Dim errors As Integer = 0
Dim pdst As DOUBLE_PTR = api.fnFIE_img_get_adrs(hdst)
Dim dst_step As SIZE_T = api.fnFIE_img_get_step(hdst)
For y As Integer = 0 To height - 1
For x As Integer = 0 To width - 1
If y Mod 2 = 0 Then
If pdst(x) <> +1 Then
errors += 1
End If
Else
If pdst(x) <> -1 Then
errors += 1
End If
End If
Console.WriteLine("{0},{1}: {2,5:F1}", y, x, pdst(x))
Next
pdst += dst_step
Next
If errors > 0 Then
Console.WriteLine("処理結果に誤りがあります。erros={0}", errors)
End If
End If
Finally
hsrc.Dispose()
hdst.Dispose()
End Try
End Sub
End Class |
See Also