色彩特徴量画像の生成(HSV色空間基準)

Namespace: fvalgcli
Assembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)

Syntax

C#
public static int fnFIE_img_hsv_to_gray(
	FHANDLE hsrc,
	FHANDLE hdst,
	double hue_base,
	double hue_range,
	double sat_low,
	double sat_high
)
Visual Basic
Public Shared Function fnFIE_img_hsv_to_gray ( 
	hsrc As FHANDLE,
	hdst As FHANDLE,
	hue_base As Double,
	hue_range As Double,
	sat_low As Double,
	sat_high As Double
) As Integer

Parameters

hsrc
Type: fvalgcli..::..FHANDLE
入力画像のハンドル( channel : 3, type : uc8, s16, us16, float, double, rgbquad, rgbtriple )
hdst
Type: fvalgcli..::..FHANDLE
出力画像のハンドル( channel : 1, type : uc8, s16, us16, float, double, rgbquad, rgbtriple )
hue_base
Type: System..::..Double
色相基準( 0 ≦ hue_base < 360 )単位:度
hue_range
Type: System..::..Double
色相範囲( 0 ≦ hue_range ≦ 180 ) 単位:度
sat_low
Type: System..::..Double
彩度下限( 0 ≦ sat_low ≦ 255 )
sat_high
Type: System..::..Double
彩度上限( 0 ≦ sat_high ≦ 255 )

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
//    $Revision: 1.1 $

using System;
using System.Collections.Generic;
using System.Text;
using fvalgcli;

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

            FHANDLE hsrc = FHANDLE.Zero;    // 処理画像.
            FHANDLE hdst = FHANDLE.Zero;    // 出力画像.

            try
            {
                // 入力画像ファイルのロード.
                api.fnFIE_load_img_file(TestImageDir + "/testdata/test_color_extract.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 = 1;
                int type = api.fnFIE_img_get_type(hsrc);

                // 出力画像の生成.
                hdst = api.fnFIE_img_root_alloc(type, channels, width, height);

                // パラメータ.
                double hue_base = 50;
                double hue_range = 180;
                double sat_low = 0;
                double sat_high = 255;

                // 処理の実行.
                status = api.fnFIE_img_hsv_to_gray(hsrc, hdst, hue_base, hue_range, sat_low, sat_high);

                // エラー判定.
                Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);

                // 出力画像の保存.
                api.fnFIE_save_png(ResultDir + "/fnFIE_img_hsv_to_gray.png", hdst, -1);
            }
            finally
            {
                // オブジェクトの開放.
                hsrc.Dispose();
                hdst.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

Public Partial Class FIE
    <FvPluginExecute> _
    Public Sub fnFIE_img_hsv_to_gray()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hsrc As FHANDLE = FHANDLE.Zero
        ' 処理画像.
        Dim hdst As FHANDLE = FHANDLE.Zero
        ' 出力画像.
        Try
            ' 入力画像ファイルのロード.
            api.fnFIE_load_img_file(TestImageDir & "/testdata/test_color_extract.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 = 1
            Dim type As Integer = api.fnFIE_img_get_type(hsrc)

            ' 出力画像の生成.
            hdst = api.fnFIE_img_root_alloc(type, channels, width, height)

            ' パラメータ.
            Dim hue_base As Double = 50
            Dim hue_range As Double = 180
            Dim sat_low As Double = 0
            Dim sat_high As Double = 255

            ' 処理の実行.
            status = api.fnFIE_img_hsv_to_gray(hsrc, hdst, hue_base, hue_range, sat_low, sat_high)

            ' エラー判定.
            Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))

            ' 出力画像の保存.
            api.fnFIE_save_png(ResultDir & "/fnFIE_img_hsv_to_gray.png", hdst, -1)
        Finally
            ' オブジェクトの開放.
            hsrc.Dispose()
            hdst.Dispose()
        End Try
    End Sub
End Class

See Also