画像と行列の乗算
Namespace: fvalgcliAssembly: fvalgcli (in fvalgcli.dll) Version: 3.1.0.0 (3.1.0.11)
Syntax
C# |
---|
public static int fnFIE_img_mul_matrix( FHANDLE hsrc, FHANDLE hdst, FMATRIX_PTR mat ) |
Visual Basic |
---|
Public Shared Function fnFIE_img_mul_matrix ( hsrc As FHANDLE, hdst As FHANDLE, mat As FMATRIX_PTR ) As Integer |
Parameters
- hsrc
- Type: fvalgcli..::..FHANDLE
入力画像のハンドル( type : uc8, s16, us16, double )
- hdst
- Type: fvalgcli..::..FHANDLE
出力画像のハンドル( type : uc8, s16, us16, double )
- mat
- Type: fvalgcli..::..FMATRIX_PTR
変換行列
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 |
---|---|
using System; using System.Collections.Generic; using System.Text; using fvalgcli; namespace TC { public partial class FIE { [FvPluginExecute] public void fnFIE_img_mul_matrix() { int status = (int)f_err.F_ERR_NONE; FHANDLE hsrc = FHANDLE.Zero; // 入力画像. FHANDLE hdst = FHANDLE.Zero; // 出力画像. FMATRIX_PTR matrix = IntPtr.Zero; try { // 入力画像ファイルのロード. api.fnFIE_load_img_file(TestImageDir + "/testdata/tiff_pc260001.tif", 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); int type = api.fnFIE_img_get_type(hsrc); // 出力画像の生成. hdst = api.fnFIE_img_root_alloc(type, channels, width, height); // 行列の生成.(monochrome/sepia) { // monochrome const double coefR = 0.299; const double coefG = 0.587; const double coefB = 0.114; // sepia const double R = 1.0; const double G = 0.9; const double B = 0.7; matrix = api.fnFIE_mat_aalloc(3, 3); matrix[0, 0] = coefR * R; matrix[0, 1] = coefG * R; matrix[0, 2] = coefB * R; matrix[1, 0] = coefR * G; matrix[1, 1] = coefG * G; matrix[1, 2] = coefB * G; matrix[2, 0] = coefR * B; matrix[2, 1] = coefG * B; matrix[2, 2] = coefB * B; } // 処理の実行. status = api.fnFIE_img_mul_matrix(hsrc, hdst, matrix); // エラー判定. Assert.IsTrue(status == (int)f_err.F_ERR_NONE, "エラーが発生しました。({0})", (f_err)status); // 出力画像の保存. api.fnFIE_save_png(ResultDir + "/fnFIE_img_mul_matrix.png", hdst, -1); } finally { // オブジェクトの開放. hsrc.Dispose(); hdst.Dispose(); matrix.Dispose(); } } } } |
Visual Basic | Copy |
---|---|
Imports System.Collections.Generic Imports System.Text Imports fvalgcli Public Partial Class FIE <FvPluginExecute> _ Public Sub fnFIE_img_mul_matrix() Dim status As Integer = CInt(f_err.F_ERR_NONE) Dim hsrc As FHANDLE = FHANDLE.Zero ' 入力画像. Dim hdst As FHANDLE = FHANDLE.Zero ' 出力画像. Dim matrix As FMATRIX_PTR = IntPtr.Zero Try ' 入力画像ファイルのロード. api.fnFIE_load_img_file(TestImageDir & "/testdata/tiff_pc260001.tif", 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) Dim type As Integer = api.fnFIE_img_get_type(hsrc) ' 出力画像の生成. hdst = api.fnFIE_img_root_alloc(type, channels, width, height) ' 行列の生成.(monochrome/sepia) If True Then ' monochrome Const coefR As Double = 0.299 Const coefG As Double = 0.587 Const coefB As Double = 0.114 ' sepia Const R As Double = 1.0 Const G As Double = 0.9 Const B As Double = 0.7 matrix = api.fnFIE_mat_aalloc(3, 3) matrix(0, 0) = coefR * R matrix(0, 1) = coefG * R matrix(0, 2) = coefB * R matrix(1, 0) = coefR * G matrix(1, 1) = coefG * G matrix(1, 2) = coefB * G matrix(2, 0) = coefR * B matrix(2, 1) = coefG * B matrix(2, 2) = coefB * B End If ' 処理の実行. status = api.fnFIE_img_mul_matrix(hsrc, hdst, matrix) ' エラー判定. Assert.IsTrue(status = CInt(f_err.F_ERR_NONE), "エラーが発生しました。({0})", CType(status, f_err)) ' 出力画像の保存. api.fnFIE_save_png(ResultDir & "/fnFIE_img_mul_matrix.png", hdst, -1) Finally ' オブジェクトの開放. hsrc.Dispose() hdst.Dispose() matrix.Dispose() End Try End Sub End Class |