NaN( 非数 )を数値に置き換える
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_replace_nan(
FHANDLE hsrc,
FHANDLE hdst,
double val
) |
Visual Basic |
---|
Public Shared Function fnFIE_replace_nan (
hsrc As FHANDLE,
hdst As FHANDLE,
val As Double
) As Integer |
Parameters
- hsrc
- Type: fvalgcli..::..FHANDLE
入力画像ハンドル( type: double, float )
- hdst
- Type: fvalgcli..::..FHANDLE
出力画像ハンドル( type: double, float )
- val
- Type: System..::..Double
NaN を置き換える数値
DOUBLE 型で入力されます。
対象画像のタイプが F_IMG_FLOAT の場合は単純キャストされます。
Return Value
Type:
Int32
以下のエラーコードを返します。
エラーコード:f_err | 内容 |
---|
F_ERR_NONE | 正常終了 |
F_ERR_INVALID_IMAGE | 不正な画像ハンドルが渡されたため、異常終了 |
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_nan()
{
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 (x % 2 == 0)
psrc[x] = Double.NaN;
else
psrc[x] = 0;
}
psrc += src_step;
}
}
status = api.fnFIE_replace_nan(hsrc, hdst, 99.9);
{
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 (x % 2 == 0)
{
if (pdst[x] != 99.9) errors++;
}
else
{
if (pdst[x] != 0.0) errors++;
}
Console.WriteLine("{0},{1}: {2,5:F2}", 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_nan()
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 x Mod 2 = 0 Then
psrc(x) = [Double].NaN
Else
psrc(x) = 0
End If
Next
psrc += src_step
Next
End If
status = api.fnFIE_replace_nan(hsrc, hdst, 99.9)
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 x Mod 2 = 0 Then
If pdst(x) <> 99.9 Then
errors += 1
End If
Else
If pdst(x) <> 0.0 Then
errors += 1
End If
End If
Console.WriteLine("{0},{1}: {2,5:F2}", 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