ルックアップテーブルによる濃度変換フィルタ(チャンネル別)

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

Syntax

C#
public static int fnFIE_lut_convert_ch(
	FHANDLE hSrc,
	FHANDLE hDst,
	INT_PTR[] ppiConvertTable,
	uint uiTableSize
)
Visual Basic
Public Shared Function fnFIE_lut_convert_ch ( 
	hSrc As FHANDLE,
	hDst As FHANDLE,
	ppiConvertTable As INT_PTR(),
	uiTableSize As UInteger
) As Integer

Parameters

hSrc
Type: fvalgcli..::..FHANDLE
被処理画像ハンドル(type: uc8, us16, s16, rgbq)
hDst
Type: fvalgcli..::..FHANDLE
処理後画像ハンドル(type: uc8, us16, s16, rgbq)
ppiConvertTable
Type: array<fvalgcli..::..INT_PTR>[]()[][]
濃度テーブル
uiTableSize
Type: System..::..UInt32
濃度テーブルサイズ

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_INVALID_IMAGE不正な画像が渡された
F_ERR_INVALID_PARAM不正なパラメータが渡された
F_ERR_NOMEMOY メモリ不足エラー
F_ERR_NO_LICENCEライセンスエラー、または未初期化エラー

Examples

C# Copy imageCopy
//    $Revision: 1.1 $

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

namespace TC
{
    public partial class FIE
    {
        /// <summary>
        /// ルックアップテーブルによる濃度変換フィルタ(チャンネル別).
        /// </summary>
        [FvPluginExecute]
        public void fnFIE_lut_convert_ch()
        {
            int status = (int)f_err.F_ERR_NONE;

            FHANDLE hsrc1 = FHANDLE.Zero;    // 入力画像.
            FHANDLE hdst = FHANDLE.Zero;    // 出力画像.
            INT_PTR itable = IntPtr.Zero;    // 濃度テーブル.
            INT_PTR[] tables = null;

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

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

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

                // 濃度テーブルの確保.
                tables = new INT_PTR[channels];

                int table_size = 0;
                switch ((f_imgtype)type)
                {
                    default:
                    case f_imgtype.F_IMG_UC8:
                    case f_imgtype.F_IMG_RGBQUAD:
                        table_size = defs.UC8_MAX + 1;
                        break;
                    case f_imgtype.F_IMG_US16:
                    case f_imgtype.F_IMG_S16:
                        table_size = defs.US16_MAX + 1;
                        break;
                }

                for (int ch = 0; ch < channels; ch++)
                {
                    tables[ch] = INT_PTR.alloc(table_size);
                    for (int i = 0; i < table_size; ++i)
                        tables[ch][i] = table_size - i;
                }

                // 処理の実行.
                status = api.fnFIE_lut_convert_ch(hsrc1, hdst, tables, (uint)table_size);

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

                // 出力画像の保存.
                api.fnFIE_save_png(ResultDir + "/fnFIE_lut_convert_ch.png", hdst, -1);
            }
            finally
            {
                // オブジェクトの開放.
                hsrc1.Dispose();
                hdst.Dispose();
                for (int ch = 0; ch < tables.Length; ch++)
                    tables[ch].Dispose();
            }
        }
    }
}


Visual Basic Copy imageCopy
'    $Revision: 1.1 $

Imports System.Collections.Generic
Imports System.Text
Imports System.Runtime.InteropServices
Imports fvalgcli

Public Partial Class FIE
    ''' <summary>
    ''' ルックアップテーブルによる濃度変換フィルタ(チャンネル別).
    ''' </summary>
    <FvPluginExecute> _
    Public Sub fnFIE_lut_convert_ch()
        Dim status As Integer = CInt(f_err.F_ERR_NONE)

        Dim hsrc1 As FHANDLE = FHANDLE.Zero
        ' 入力画像.
        Dim hdst As FHANDLE = FHANDLE.Zero
        ' 出力画像.
        Dim itable As INT_PTR = IntPtr.Zero
        ' 濃度テーブル.
        Dim tables As INT_PTR() = Nothing

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

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

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

            ' 濃度テーブルの確保.
            tables = New INT_PTR(channels - 1) {}

            Dim table_size As Integer = 0
            Select Case CType(type, f_imgtype)
                Case f_imgtype.F_IMG_UC8
                    table_size = defs.UC8_MAX + 1
                    Exit Select
                Case f_imgtype.F_IMG_RGBQUAD
                    table_size = defs.UC8_MAX + 1
                    Exit Select
                Case f_imgtype.F_IMG_US16
                    table_size = defs.US16_MAX + 1
                    Exit Select
                Case f_imgtype.F_IMG_S16
                    table_size = defs.US16_MAX + 1
                    Exit Select
            End Select

            For ch As Integer = 0 To channels - 1
                tables(ch) = INT_PTR.alloc(table_size)
                For i As Integer = 0 To table_size - 1
                    tables(ch)(i) = table_size - i
                Next
            Next

            ' 処理の実行.
            status = api.fnFIE_lut_convert_ch(hsrc1, hdst, tables, CUInt(table_size))

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

            ' 出力画像の保存.
            api.fnFIE_save_png(ResultDir & "/fnFIE_lut_convert_ch.png", hdst, -1)
        Finally
            ' オブジェクトの開放.
            hsrc1.Dispose()
            hdst.Dispose()
            For ch As Integer = 0 To tables.Length - 1
                tables(ch).Dispose()
            Next
        End Try
    End Sub
End Class

See Also