REGION間OR演算

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

Syntax

C#
public static int fnFIE_region_or(
	FHANDLE hsrc1,
	FHANDLE hsrc2,
	ref FHANDLE hdst
)
Visual Basic
Public Shared Function fnFIE_region_or ( 
	hsrc1 As FHANDLE,
	hsrc2 As FHANDLE,
	ByRef hdst As FHANDLE
) As Integer

Parameters

hsrc1
Type: fvalgcli..::..FHANDLE
入力REGIONハンドル
hsrc2
Type: fvalgcli..::..FHANDLE
入力REGIONハンドル
hdst
Type: fvalgcli..::..FHANDLE%
出力REGIONハンドルのアドレス

Return Value

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

エラーコード:
f_err内容
F_ERR_NONE正常終了
F_ERR_NOMEMORYメモリ不足エラー
F_ERR_INVALID_OBJECT 不正なハンドル
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
    {
        [FvPluginExecute]
        public void fnFIE_region_or()
        {
            FHANDLE himage1 = FHANDLE.Zero;
            FHANDLE himage2 = FHANDLE.Zero;
            FHANDLE himaged = FHANDLE.Zero;         
            FHANDLE hregion1 = FHANDLE.Zero;
            FHANDLE hregion2 = FHANDLE.Zero;
            FHANDLE hregiond = FHANDLE.Zero;
            FHANDLE htemp = FHANDLE.Zero;

            try
            {
                // 2つの2値画像を読み込む.
                api.fnFIE_load_img_file(TestImageDir + "/TC/SampleCode/blob_BIN.png", ref himage1, f_color_img_type.F_COLOR_IMG_TYPE_UC8);
                api.fnFIE_load_img_file(TestImageDir + "/TC/SampleCode/blob_BIN_2.png", ref himage2, f_color_img_type.F_COLOR_IMG_TYPE_UC8);

                Assert.IsTrue(himage1 != FHANDLE.Zero, "himage1 が異常です.");
                Assert.IsTrue(himage2 != FHANDLE.Zero, "himage2 が異常です.");

                int width = api.fnFIE_img_get_width(himage1);
                int height = api.fnFIE_img_get_height(himage1);
                int type = api.fnFIE_img_get_type(himage1);
                int channels = api.fnFIE_img_get_channels(himage1);
                himaged = api.fnFIE_img_root_alloc(type, channels, width, height);

                // --- 2値画像の演算.
                api.fnFIE_img_or(himage1, himage2, himaged);

                // 画像からリージョンを作成する.
                // --- オフセット.
                PNT_T offset = new PNT_T();
                offset.x = 0;
                offset.y = 0;
                // --- 作成.
                hregion1 = api.fnFIE_region_encode(himage1, offset);
                hregion2 = api.fnFIE_region_encode(himage2, offset);

                // --- リージョンの演算.
                api.fnFIE_region_or(hregion1, hregion2, ref hregiond);

                // 画像演算とリージョン演算の結果を比較する為のテンポラリ.
                htemp = api.fnFIE_img_root_alloc(type, channels, width, height);
                // --- クリア.
                api.fnFIE_img_clear(htemp, 0.0);
                // --- リージョンを画像に変換.
                api.fnFIE_region_decode(hregiond, htemp, offset, 1.0);
                // --- 比較.
                bool result = false;
                int status = api.fnFIE_img_compare(himaged, htemp, ref result);
                Console.WriteLine("status={0}, fnFIE_img_compare={1}", status, result);

                // ファイルに保存する.
                api.fnFIE_save_png(ResultDir + "/fnFIE_region_or.himaged.png", himaged, -1);
                api.fnFIE_save_png(ResultDir + "/fnFIE_region_or.htemp.png", htemp, -1);
            }
            finally
            {
                himage1.Dispose();
                himage2.Dispose();
                himaged.Dispose();
                hregion1.Dispose();
                hregion2.Dispose();
                hregiond.Dispose();
                htemp.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_region_or()
        Dim himage1 As FHANDLE = FHANDLE.Zero
        Dim himage2 As FHANDLE = FHANDLE.Zero
        Dim himaged As FHANDLE = FHANDLE.Zero
        Dim hregion1 As FHANDLE = FHANDLE.Zero
        Dim hregion2 As FHANDLE = FHANDLE.Zero
        Dim hregiond As FHANDLE = FHANDLE.Zero
        Dim htemp As FHANDLE = FHANDLE.Zero

        Try
            ' 2つの2値画像を読み込む.
            api.fnFIE_load_img_file(TestImageDir & "/TC/SampleCode/blob_BIN.png", himage1, f_color_img_type.F_COLOR_IMG_TYPE_UC8)
            api.fnFIE_load_img_file(TestImageDir & "/TC/SampleCode/blob_BIN_2.png", himage2, f_color_img_type.F_COLOR_IMG_TYPE_UC8)

            Assert.IsTrue(himage1 <> FHANDLE.Zero, "himage1 が異常です.")
            Assert.IsTrue(himage2 <> FHANDLE.Zero, "himage2 が異常です.")

            Dim width As Integer = api.fnFIE_img_get_width(himage1)
            Dim height As Integer = api.fnFIE_img_get_height(himage1)
            Dim type As Integer = api.fnFIE_img_get_type(himage1)
            Dim channels As Integer = api.fnFIE_img_get_channels(himage1)
            himaged = api.fnFIE_img_root_alloc(type, channels, width, height)

            ' --- 2値画像の演算.
            api.fnFIE_img_or(himage1, himage2, himaged)

            ' 画像からリージョンを作成する.
            ' --- オフセット.
            Dim offset As New PNT_T()
            offset.x = 0
            offset.y = 0
            ' --- 作成.
            hregion1 = api.fnFIE_region_encode(himage1, offset)
            hregion2 = api.fnFIE_region_encode(himage2, offset)

            ' --- リージョンの演算.
            api.fnFIE_region_or(hregion1, hregion2, hregiond)

            ' 画像演算とリージョン演算の結果を比較する為のテンポラリ.
            htemp = api.fnFIE_img_root_alloc(type, channels, width, height)
            ' --- クリア.
            api.fnFIE_img_clear(htemp, 0.0)
            ' --- リージョンを画像に変換.
            api.fnFIE_region_decode(hregiond, htemp, offset, 1.0)
            ' --- 比較.
            Dim result As Boolean = False
            Dim status As Integer = api.fnFIE_img_compare(himaged, htemp, result)
            Console.WriteLine("status={0}, fnFIE_img_compare={1}", status, result)

            ' ファイルに保存する.
            api.fnFIE_save_png(ResultDir & "/fnFIE_region_or.himaged.png", himaged, -1)
            api.fnFIE_save_png(ResultDir & "/fnFIE_region_or.htemp.png", htemp, -1)
        Finally
            himage1.Dispose()
            himage2.Dispose()
            himaged.Dispose()
            hregion1.Dispose()
            hregion2.Dispose()
            hregiond.Dispose()
            htemp.Dispose()
        End Try
    End Sub
End Class

See Also