リージョン内の画像ヒストグラム作成

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

Syntax

C#
public static int fnFIE_img_histogram(
	FHANDLE hImg,
	FHANDLE hreg,
	int iChaNo,
	ref UINT_PTR unppHist,
	ref int ipHistLen
)
Visual Basic
Public Shared Function fnFIE_img_histogram ( 
	hImg As FHANDLE,
	hreg As FHANDLE,
	iChaNo As Integer,
	ByRef unppHist As UINT_PTR,
	ByRef ipHistLen As Integer
) As Integer

Parameters

hImg
Type: fvalgcli..::..FHANDLE
入力画像のハンドル (type: uc8, s16, us16)
hreg
Type: fvalgcli..::..FHANDLE
リージョンのハンドル
iChaNo
Type: System..::..Int32
処理したいチャネルの番号
unppHist
Type: fvalgcli..::..UINT_PTR%
ヒストグラムのメモリ (外部で確保したメモリのアドレス、または IntPtr.Zero を指定します。)
ipHistLen
Type: System..::..Int32%
  • メモリ確保した場合はそのメモリの量を入力(UINT数単位)
  • メモリ確保しなかった場合は関数内部確保のメモリの量を出力(UINT数単位)

Return Value

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

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

Remarks

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_histogram()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hsrc = FHANDLE.Zero;    // 処理画像.
            FHANDLE hreg = FHANDLE.Zero;    // リージョン.
            int iChaNo = 0;
            UINT_PTR unHist = UINT_PTR.Zero;
            int iHistLen = 0;

            try
            {
                // 入力画像ファイルのロード.
                api.fnFIE_load_img_file(TestImageDir + "/testdata/colorg.bmp", ref hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8);

                // リージョン.
                hreg = api.fnFIE_create_region_rect(97, 56, 330, 343);

                // 処理の実行.
                status = api.fnFIE_img_histogram(hsrc, hreg, iChaNo, ref unHist, ref iHistLen);

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

                // 確認.
                Console.WriteLine("fnFIE_img_histogram");
                for (int i = 0; i < iHistLen; i++)
                {
                    Console.Write("{0},", unHist[i]);
                    if (((i + 1) % 16) == 0)
                        Console.WriteLine("");
                }
                Console.WriteLine("");
                Console.WriteLine("iHistLen={0}", iHistLen);
            }
            finally
            {
                // オブジェクトの開放.
                hsrc.Dispose();
                hreg.Dispose();
                unHist.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_histogram()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hsrc As FHANDLE = FHANDLE.Zero
        ' 処理画像.
        Dim hreg As FHANDLE = FHANDLE.Zero
        ' リージョン.
        Dim iChaNo As Integer = 0
        Dim unHist As UINT_PTR = UINT_PTR.Zero
        Dim iHistLen As Integer = 0

        Try
            ' 入力画像ファイルのロード.
            api.fnFIE_load_img_file(TestImageDir & "/testdata/colorg.bmp", hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8)

            ' リージョン.
            hreg = api.fnFIE_create_region_rect(97, 56, 330, 343)

            ' 処理の実行.
            status = api.fnFIE_img_histogram(hsrc, hreg, iChaNo, unHist, iHistLen)

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

            ' 確認.
            Console.WriteLine("fnFIE_img_histogram")
            For i As Integer = 0 To iHistLen - 1
                Console.Write("{0},", unHist(i))
                If ((i + 1) Mod 16) = 0 Then
                    Console.WriteLine("")
                End If
            Next
            Console.WriteLine("")
            Console.WriteLine("iHistLen={0}", iHistLen)
        Finally
            ' オブジェクトの開放.
            hsrc.Dispose()
            hreg.Dispose()
            unHist.Dispose()
        End Try
    End Sub
End Class

See Also