ガボール フィルタ

Namespace: fvalgcli
Assembly: fvalgcli_fga (in fvalgcli_fga.dll) Version: 3.1.0.0 (3.1.0.3)

Syntax

C#
public static int fnFGA_gabor(
	FHANDLE hSrc,
	FHANDLE hDst,
	double sigma,
	double wavelen,
	double orient,
	int filter_mode,
	f_border_mode border_mode,
	double border_value
)
Visual Basic
Public Shared Function fnFGA_gabor ( 
	hSrc As FHANDLE,
	hDst As FHANDLE,
	sigma As Double,
	wavelen As Double,
	orient As Double,
	filter_mode As Integer,
	border_mode As f_border_mode,
	border_value As Double
) As Integer

Parameters

hSrc
Type: fvalgcli..::..FHANDLE
入力画像 ( type: uc8, s16, us16, float, double )
hDst
Type: fvalgcli..::..FHANDLE
出力画像 ( type: uc8, s16, us16, float, double )
sigma
Type: System..::..Double
ガボールフィルタの標準偏差 (単位 : pixel, 0.4≦sigma)
wavelen
Type: System..::..Double
ガボールフィルタの波長 (単位 : pixel, 0<wavelen)
orient
Type: System..::..Double
ガボールフィルタの方位 (単位 : radian )
filter_mode
Type: System..::..Int32
フィルターモード. [範囲:0=実部、1=虚部、2=実部と虚部の自乗和の平方根]
border_mode
Type: fvalgcli..::..f_border_mode
ボーダー処理モード.
  • F_BORDER_NONE ボーダー拡張しない
  • F_BORDER_ZERO 0埋めモード
  • F_BORDER_VALUE 一定値モード
  • F_BORDER_CONTINUOUS 端延長モード
  • F_BORDER_REPEAT 繰り返しモード
  • F_BORDER_MIRROR1 反転モード1
  • F_BORDER_MIRROR2 反転モード2
border_value
Type: System..::..Double
ボーダー濃度値。border_mode が F_BORDER_VALUE の場合のみ使用されます。その他のモードの場合は、この値は無視されます。

Return Value

Type: Int32
以下のエラーコードを返します。

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足エラー
F_ERR_INVALID_IMAGE画像オブジェクトの異常
F_ERR_INVALID_PARAMパラメータ異常
F_ERR_NO_LICENCEライセンスエラー

Examples

C# Copy imageCopy
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using fvalgcli;

namespace TC
{
    public partial class FIE
    {
        [FvPluginExecute]
        public void fnFGA_gabor()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hfie_src = FHANDLE.Zero;    // 処理画像.
            FHANDLE hfie_dst = FHANDLE.Zero;    // 出力画像.
            FHANDLE hfga_src = FHANDLE.Zero;    // 入力画像.(FGA用)
            FHANDLE hfga_dst = FHANDLE.Zero;    // 出力画像.(FGA用)

            try
            {
                // 入力画像ファイルのロード.
                status = api.fnFIE_load_img_file(Defs.TestImageDir + "/testdata/gray_04.bmp", ref hfie_src, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 入力画像の情報取得.
                int width = api.fnFIE_img_get_width(hfie_src);
                int height = api.fnFIE_img_get_height(hfie_src);
                int channels = api.fnFIE_img_get_channels(hfie_src);
                int type = api.fnFIE_img_get_type(hfie_src);

                // 入力画像の生成.(FGA用)
                hfga_src = fga.fnFGA_img_root_alloc(type, channels, width, height);
                if (hfga_src == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // FIE 画像オブジェクトから FGA 画像オブジェクトへコピー.
                status = fga.fnFGA_img_copy(hfie_src, hfga_src);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 出力画像の生成.(FGA用)
                hfga_dst = fga.fnFGA_img_root_alloc(type, channels, width, height);
                if (hfga_dst == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // パラメータ.
                double sigma = 0.8;        // ガボールフィルタの標準偏差 (単位 : pixel, 0.4≦sigma)
                double wavelen = 1.0;    // ガボールフィルタの波長 (単位 : pixel, 0<wavelen)
                double orient = 0;        // ガボールフィルタの方位 (単位 : radian )
                int filter_mode = 2;    // フィルターモード.(0:実部, 1:虚部, 2:実部と虚部の自乗和の平方根)

                // 処理の実行.
                status = fga.fnFGA_gabor(hfga_src, hfga_dst, sigma, wavelen, orient, filter_mode, f_border_mode.F_BORDER_NONE, 0);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status, "エラーが発生しました。");

                // 出力画像の生成.
                hfie_dst = api.fnFIE_img_root_alloc(type, channels, width, height);
                if (hfie_dst == IntPtr.Zero)
                    throw new FvException(f_err.F_ERR_NOMEMORY);

                // FGA 画像オブジェクトから FIE 画像オブジェクトへコピー.
                status = fga.fnFGA_img_copy(hfga_dst, hfie_dst);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);

                // 出力画像の保存.
                status = api.fnFIE_save_png(Defs.ResultDir + "/fnFGA_gabor.png", hfie_dst, -1);
                if (status != (int)f_err.F_ERR_NONE)
                    throw new FvException(status);
            }
            finally
            {
                // オブジェクトの開放.
                hfga_src.Dispose();
                hfga_dst.Dispose();
                hfie_src.Dispose();
                hfie_dst.Dispose();
            }
        }
    }
}

See Also