照度差ステレオ光源ベクトルの情報補助関数(空間座標)

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

Syntax

C#
public static int fnFIE_ps_woodham_calc_light_from_pos(
	DPNT3_T[] source,
	DPNT3_T[] target,
	DOUBLE_PTR slant,
	DOUBLE_PTR tilt,
	int n
)
Visual Basic
Public Shared Function fnFIE_ps_woodham_calc_light_from_pos ( 
	source As DPNT3_T(),
	target As DPNT3_T(),
	slant As DOUBLE_PTR,
	tilt As DOUBLE_PTR,
	n As Integer
) As Integer

Parameters

source
Type: array<fvalgcli..::..DPNT3_T>[]()[][]
光源の始点の座標 (要素数 n)
target
Type: array<fvalgcli..::..DPNT3_T>[]()[][]
光源の終点の座標 (要素数 n)
slant
Type: fvalgcli..::..DOUBLE_PTR
出力光源ベクトルの情報である slant の配列 (要素数 n)
tilt
Type: fvalgcli..::..DOUBLE_PTR
出力光源ベクトルの情報である tilt の配列 (要素数 n)
n
Type: System..::..Int32
n 光源の数(1以上の整数)

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
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_ps_woodham_calc_light_from_pos()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hsrc = FHANDLE.Zero;
            FHANDLE hdst_normal = FHANDLE.Zero;
            FHANDLE hdst_albedo = FHANDLE.Zero;
            DOUBLE_PTR slant = IntPtr.Zero;
            DOUBLE_PTR tilt = IntPtr.Zero;

            try
            {
                // 入力画像: (ファイル読み込み)
                api.fnFIE_load_img_file(TestImageDir + "/TC/PS/fie_ps_sample-uc8.png", 
                    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 = api.fnFIE_img_get_channels(hsrc);

                // 出力画像の生成.
                hdst_normal = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 3, width, height);
                hdst_albedo = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height);

                // 光源ベクトル の情報.
                slant = DOUBLE_PTR.alloc(channels);
                tilt = DOUBLE_PTR.alloc(channels);

                DPNT3_T[] source_points = new DPNT3_T[]
                {
                    DPNT3_T.init(2.1, 1.1, 1.0),
                    DPNT3_T.init(0.2, 0.2, 1.0),
                    DPNT3_T.init(-1.1, -2.1, 1.0),
                };
                DPNT3_T[] target_points = new DPNT3_T[]
                {
                    DPNT3_T.init(1.2, 1.4, 0.0),
                    DPNT3_T.init(0.1, 0.1, 0.0),
                    DPNT3_T.init(-1.5, -1.3, 0.0),
                };

                // 光源ベクトルの情報補助関数.
                status = api.fnFIE_ps_woodham_calc_light_from_pos(source_points, target_points, slant, tilt, channels);
                if (status != 0)
                    throw new FvException(status);

                // 処理の実行.
                status = api.fnFIE_ps_woodham(hsrc, slant, tilt, hdst_normal, hdst_albedo);
                if (status != 0)
                    throw new FvException(status);

                // 出力画像の保存.
                api.fnFIE_save_tiff(ResultDir + "/fnFIE_ps_woodham_calc_light_from_pos-normal.tiff", 
                    hdst_normal, f_tiff_compression.F_TIFF_COMPRESSION_DEFLATE, -1);
                api.fnFIE_save_tiff(ResultDir + "/fnFIE_ps_woodham_calc_light_from_pos-albedo.tiff", 
                    hdst_albedo, f_tiff_compression.F_TIFF_COMPRESSION_DEFLATE, -1);

                // 光源ベクトルの情報: (slant)
                Console.Write("slant = ");
                for (int i = 0; i < channels; i++)
                {
                    Console.Write("{0} ", slant[i]);
                }
                Console.WriteLine("");

                // 光源ベクトルの情報: (tilt)
                Console.Write("tilt = ");
                for (int i = 0; i < channels; i++)
                {
                    Console.Write("{0} ", tilt[i]);
                }
                Console.WriteLine("");
            }
            finally
            {
                hsrc.Dispose();
                hdst_normal.Dispose();
                hdst_albedo.Dispose();
                slant.Dispose();
                tilt.Dispose();
            }
        }
    }
}
※注)この例の source_points と target_points は、数値の内容自体には、あまり意味はありません。
fnFIE_ps_woodham_calc_light_from_pos 関数の呼び出し確認のみを目的としており、出力データ (slant, tilt) の整合性は考慮していません。


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

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

        Dim hsrc As FHANDLE = FHANDLE.Zero
        Dim hdst_normal As FHANDLE = FHANDLE.Zero
        Dim hdst_albedo As FHANDLE = FHANDLE.Zero
        Dim slant As DOUBLE_PTR = IntPtr.Zero
        Dim tilt As DOUBLE_PTR = IntPtr.Zero

        Try
            ' 入力画像: (ファイル読み込み)
            api.fnFIE_load_img_file(TestImageDir & "/TC/PS/fie_ps_sample-uc8.png", _
                                    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 = api.fnFIE_img_get_channels(hsrc)

            ' 出力画像の生成.
            hdst_normal = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 3, width, height)
            hdst_albedo = api.fnFIE_img_root_alloc(f_imgtype.F_IMG_DOUBLE, 1, width, height)

            ' 光源ベクトル の情報.
            slant = DOUBLE_PTR.alloc(channels)
            tilt = DOUBLE_PTR.alloc(channels)

            Dim source_points As DPNT3_T() = New DPNT3_T() { _
                DPNT3_T.init(2.1, 1.1, 1.0), _
                DPNT3_T.init(0.2, 0.2, 1.0), _
                DPNT3_T.init(-1.1, -2.1, 1.0) _
            }
            Dim target_points As DPNT3_T() = New DPNT3_T() { _
                DPNT3_T.init(1.2, 1.4, 0.0), _
                DPNT3_T.init(0.1, 0.1, 0.0), _
                DPNT3_T.init(-1.5, -1.3, 0.0) _
            }

            ' 光源ベクトルの情報補助関数.
            status = api.fnFIE_ps_woodham_calc_light_from_pos(source_points, target_points, slant, tilt, channels)
            If status <> 0 Then
                Throw New FvException(status)
            End If

            ' 処理の実行.
            status = api.fnFIE_ps_woodham(hsrc, slant, tilt, hdst_normal, hdst_albedo)
            If status <> 0 Then
                Throw New FvException(status)
            End If

            ' 出力画像の保存.
            api.fnFIE_save_tiff(ResultDir & "/fnFIE_ps_woodham_calc_light_from_pos-normal.tiff", _
                                hdst_normal, f_tiff_compression.F_TIFF_COMPRESSION_DEFLATE, -1)
            api.fnFIE_save_tiff(ResultDir & "/fnFIE_ps_woodham_calc_light_from_pos-albedo.tiff", _
                                hdst_albedo, f_tiff_compression.F_TIFF_COMPRESSION_DEFLATE, -1)

            ' 光源ベクトルの情報: (slant)
            Console.Write("slant = ")
            For i As Integer = 0 To channels - 1
                Console.Write("{0} ", slant(i))
            Next
            Console.WriteLine("")

            ' 光源ベクトルの情報: (tilt)
            Console.Write("tilt = ")
            For i As Integer = 0 To channels - 1
                Console.Write("{0} ", tilt(i))
            Next
            Console.WriteLine("")
        Finally
            hsrc.Dispose()
            hdst_normal.Dispose()
            hdst_albedo.Dispose()
            slant.Dispose()
            tilt.Dispose()
        End Try
    End Sub
End Class
※注)この例の source_points と target_points は、数値の内容自体には、あまり意味はありません。
fnFIE_ps_woodham_calc_light_from_pos 関数の呼び出し確認のみを目的としており、出力データ (slant, tilt) の整合性は考慮していません。

See Also