ランク画像作成

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

Syntax

C#
public static int fnFIE_stats_img_rank(
	FHANDLE[] himgs,
	int num_imgs,
	ref FHANDLE himg_rank,
	int rank
)
Visual Basic
Public Shared Function fnFIE_stats_img_rank ( 
	himgs As FHANDLE(),
	num_imgs As Integer,
	ByRef himg_rank As FHANDLE,
	rank As Integer
) As Integer

Parameters

himgs
Type: array<fvalgcli..::..FHANDLE>[]()[][]
複数の画像オブジェクト格納配列 (type: uc8, s16, us16, double)
himgs に格納される画像はすべて、サイズ及び画像型が等しく、さらにチャネル数が1でなければなりません。
num_imgs
Type: System..::..Int32
himg に格納された画像オブジェクトの数 (1≦ num_imgs ≦65535)
himg_rank
Type: fvalgcli..::..FHANDLE%
生成した結果画像オブジェクト。 himg_rank は必ず IntPtr.Zero で初期化しなければなりません。
rank
Type: System..::..Int32
ランク (1≦ rank ≦ num_imgs)

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 fvalgcli;

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

            FHANDLE[] hsrcs = null;

            try
            {
                string[] src_filenames = new string[]
                {
                    "stats_001.bmp",
                    "stats_002.bmp",
                    "stats_003.bmp",
                    "stats_004.bmp",
                    "stats_005.bmp",
                };

                hsrcs = new FHANDLE[src_filenames.Length];

                // 入力画像: (ファイル読み込み)
                for (int i = 0; i < hsrcs.Length; i++)
                {
                    string src_filename = string.Format("{0}/testdata/{1}", TestImageDir, src_filenames[i]);

                    FHANDLE hsrc = FHANDLE.Zero;
                    api.fnFIE_load_img_file(src_filename, ref hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8);

                    hsrcs[i] = hsrc;

                    // 入力画像の情報取得.
                    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 = api.fnFIE_img_get_type(hsrc);

                    Console.WriteLine("src{0}: width={1}, height={2}, channels={3}, type={4}"
                        , i, width, height, channels, type);
                }

                // 処理の実行.
                for (int i = 0; i < hsrcs.Length; i++)
                {
                    FHANDLE hdst = FHANDLE.Zero;

                    try
                    {
                        int rank = i + 1;

                        status = api.fnFIE_stats_img_rank(hsrcs, hsrcs.Length, ref hdst, rank);
                        if (status != 0)
                            throw new FvException(status);

                        // 出力画像の保存.
                        string dst_filename = string.Format("{0}/fnFIE_stats_img_rank-{1}.png", ResultDir, i);
                        api.fnFIE_save_png(dst_filename, hdst, -1);

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

                        Console.WriteLine("dst{0}: width={1}, height={2}, channels={3}, type={4}"
                            , i, width, height, channels, type);
                    }
                    finally
                    {
                        hdst.Dispose();
                    }
                }
            }
            finally
            {
                if (hsrcs != null)
                {
                    foreach (var hsrc in hsrcs)
                        hsrc.Dispose();
                }
            }
        }
    }
}


Visual Basic Copy imageCopy
Imports System.Collections.Generic
Imports System.Text
Imports fvalgcli

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

        Dim hsrcs As FHANDLE() = Nothing

        Try
            Dim src_filenames As String() = New String() { _
                "stats_001.bmp", _
                "stats_002.bmp", _
                "stats_003.bmp", _
                "stats_004.bmp", _
                "stats_005.bmp" _
            }

            hsrcs = New FHANDLE(src_filenames.Length - 1) {}

            ' 入力画像: (ファイル読み込み)
            For i As Integer = 0 To hsrcs.Length - 1
                Dim src_filename As String = String.Format("{0}/testdata/{1}", TestImageDir, src_filenames(i))

                Dim hsrc As FHANDLE = FHANDLE.Zero
                api.fnFIE_load_img_file(src_filename, hsrc, f_color_img_type.F_COLOR_IMG_TYPE_UC8)

                hsrcs(i) = hsrc

                ' 入力画像の情報取得.
                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 = api.fnFIE_img_get_type(hsrc)

                Console.WriteLine("src{0}: width={1}, height={2}, channels={3}, type={4}" _
                                  , i, width, height, channels, type)
            Next

            ' 処理の実行.
            For i As Integer = 0 To hsrcs.Length - 1
                Dim hdst As FHANDLE = FHANDLE.Zero

                Try
                    Dim rank As Integer = i + 1

                    status = api.fnFIE_stats_img_rank(hsrcs, hsrcs.Length, hdst, rank)
                    If status <> 0 Then
                        Throw New FvException(status)
                    End If

                    ' 出力画像の保存.
                    Dim dst_filename As String = String.Format("{0}/fnFIE_stats_img_rank-{1}.png", ResultDir, i)
                    api.fnFIE_save_png(dst_filename, hdst, -1)

                    ' 入力画像の情報取得.
                    Dim width As Integer = api.fnFIE_img_get_width(hdst)
                    Dim height As Integer = api.fnFIE_img_get_height(hdst)
                    Dim channels As Integer = api.fnFIE_img_get_channels(hdst)
                    Dim type As Integer = api.fnFIE_img_get_type(hdst)

                    Console.WriteLine("dst{0}: width={1}, height={2}, channels={3}, type={4}" _
                                      , i, width, height, channels, type)
                Finally
                    hdst.Dispose()
                End Try
            Next
        Finally
            If hsrcs IsNot Nothing Then
                For Each hsrc As FHANDLE In hsrcs
                    hsrc.Dispose()
                Next
            End If
        End Try
    End Sub
End Class

See Also