指定座標の濃度値取得(全チャネル一括)

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

Syntax

C#
public static int fnFIE_img_get_dens_channels(
	FHANDLE himg,
	int x,
	int y,
	double[] dens
)
Visual Basic
Public Shared Function fnFIE_img_get_dens_channels ( 
	himg As FHANDLE,
	x As Integer,
	y As Integer,
	dens As Double()
) As Integer

Parameters

himg
Type: fvalgcli..::..FHANDLE
濃度を取得する画像( type: bin, uc8, s16, us16, i32, ui32, double, float, rgbq, rgbtri)
x
Type: System..::..Int32
対象画素のX座標
y
Type: System..::..Int32
対象画素のY座標
dens
Type: array<System..::..Double>[]()[][]
濃度値配列 (himg のチャネル数分。RGBQUAD, RGBTRIPLE型の場合は3以上。)

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_IMAGEhimg に指定された画像が不正
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
    {
        /// <summary>
        /// 指定座標の濃度値取得(全チャネル一括).
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_img_get_dens_channels()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE himg = FHANDLE.Zero;
            const int channels = 3;
            const int width = 32;
            const int height = 24;
            double[] test_values = new double[] { 32, 64, 128 };

            try
            {
                // 処理画像の確保.
                himg = api.fnFIE_img_root_alloc((int)f_imgtype.F_IMG_US16, channels, width, height);

                for (int ch = 0; ch < channels; ch++)
                {
                    api.fnFIE_img_clear_ch(himg, ch, test_values[ch]);
                }

                // 濃度値取得.
                for (int ch = 0; ch < channels; ch++)
                {
                    for (int y = 0; y < height; y++)
                    {
                        for (int x = 0; x < width; x++)
                        {
                            double dens = 0;
                            status = api.fnFIE_img_get_dens(himg, ch, x, y, ref dens);

                            // check
                            Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status);
                            Assert.IsTrue(dens == test_values[ch], "期待値と一致しません.");
                        }
                    }
                }
            }
            finally
            {
                // オブジェクトの開放.
                himg.Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text

Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' 指定座標の濃度値取得(全チャネル一括).
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_img_get_dens_channels()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim himg As FHANDLE = FHANDLE.Zero
        Const  channels As Integer = 3
        Const  width As Integer = 32
        Const  height As Integer = 24
        Dim test_values As Double() = New Double() {32, 64, 128}

        Try
            ' 処理画像の確保.
            himg = api.fnFIE_img_root_alloc(CInt(f_imgtype.F_IMG_US16), channels, width, height)

            For ch As Integer = 0 To channels - 1
                api.fnFIE_img_clear_ch(himg, ch, test_values(ch))
            Next

            ' 濃度値取得.
            For ch As Integer = 0 To channels - 1
                For y As Integer = 0 To height - 1
                    For x As Integer = 0 To width - 1
                        Dim dens As Double = 0
                        status = api.fnFIE_img_get_dens(himg, ch, x, y, dens)

                        ' check
                        Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err))
                        Assert.IsTrue(dens = test_values(ch), "期待値と一致しません.")
                    Next
                Next
            Next
        Finally
            ' オブジェクトの開放.
            himg.Dispose()
        End Try
    End Sub
End Class

See Also