キトラー(kittler)法による画像2値化
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_kittler_threshold(
FHANDLE hSrc,
FHANDLE hDst,
INT_PTR ipThresh
) |
Visual Basic |
---|
Public Shared Function fnFIE_kittler_threshold (
hSrc As FHANDLE,
hDst As FHANDLE,
ipThresh As INT_PTR
) As Integer |
Return Value
Type:
Int32
以下のエラーコードを返します。
エラーコード:f_err | 内容 |
---|
F_ERR_NONE | 正常終了 |
F_ERR_NOMEMORY | メモリ不足エラー |
F_ERR_INVALID_IMAGE | 画像オブジェクトの異常 |
F_ERR_INVALID_PARAM | パラメータ異常 |
F_ERR_CALC_IMPOSSIBLE | 計算が出来ない |
F_ERR_NO_LICENCE | ライセンスエラー |
Remarks
Examples
C# | Copy |
---|
using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;
namespace TC
{
public partial class FIE
{
[FvPluginExecute]
public void fnFIE_kittler_threshold()
{
int status = (int)f_err.F_ERR_NONE;
FHANDLE hsrc = FHANDLE.Zero;
FHANDLE hdst = FHANDLE.Zero;
INT_PTR thresholds = INT_PTR.Zero;
try
{
api.fnFIE_load_img_file(TestImageDir + "/testdata/gray_04.bmp", ref hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
int width = api.fnFIE_img_get_width(hsrc);
int height = api.fnFIE_img_get_height(hsrc);
int channels = api.fnFIE_img_get_channels(hsrc);
int type = (int)f_imgtype.F_IMG_BIN;
hdst = api.fnFIE_img_root_alloc(type, channels, width, height);
thresholds = INT_PTR.alloc(channels);
status = api.fnFIE_kittler_threshold(hsrc, hdst, thresholds);
Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);
api.fnFIE_save_png(ResultDir + "/fnFIE_kittler_threshold.png", hdst, -1);
for (int i = 0; i < channels; i++)
Console.WriteLine("fnFIE_kittler_threshold: thresholds[{0}]={1}", i, thresholds[i]);
}
finally
{
hsrc.Dispose();
hdst.Dispose();
thresholds.Dispose();
}
}
}
} |
Visual Basic | Copy |
---|
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli
Public Partial Class FIE
<FvPluginExecute> _
Public Sub fnFIE_kittler_threshold()
Dim status As Integer = CInt(f_err.F_ERR_NONE)
Dim hsrc As FHANDLE = FHANDLE.Zero
Dim hdst As FHANDLE = FHANDLE.Zero
Dim thresholds As INT_PTR = INT_PTR.Zero
Try
api.fnFIE_load_img_file(TestImageDir & "/testdata/gray_04.bmp", hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8)
Dim width As Integer = api.fnFIE_img_get_width(hsrc)
Dim height As Integer = api.fnFIE_img_get_height(hsrc)
Dim channels As Integer = api.fnFIE_img_get_channels(hsrc)
Dim type As Integer = CInt(f_imgtype.F_IMG_BIN)
hdst = api.fnFIE_img_root_alloc(type, channels, width, height)
thresholds = INT_PTR.alloc(channels)
status = api.fnFIE_kittler_threshold(hsrc, hdst, thresholds)
Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))
api.fnFIE_save_png(ResultDir & "/fnFIE_kittler_threshold.png", hdst, -1)
For i As Integer = 0 To channels - 1
Console.WriteLine("fnFIE_kittler_threshold: thresholds[{0}]={1}", i, thresholds(i))
Next
Finally
hsrc.Dispose()
hdst.Dispose()
thresholds.Dispose()
End Try
End Sub
End Class |
See Also