サイズ情報の取得 (WIL 用)
Namespace: FVIL.IplAssembly: FVILbasic (in FVILbasic.dll) Version: 3.1.0.0 (3.1.0.17)
Syntax
C# |
---|
public static ImageSize ToImageSize( IplImageSize size ) |
Visual Basic |
---|
Public Shared Function ToImageSize ( size As IplImageSize ) As ImageSize |
Parameters
- size
- Type: FVIL.Ipl..::..IplImageSize
IplImage のサイズ情報
Return Value
Type: ImageSizeCFviImage を確保する際に使用するサイズ情報を返します。
Remarks
引数に指定された IplImage のサイズ情報と互換性がある画像オブジェクトのサイズ情報に変換します。
引数 size の width,height,channels が許容範囲内の場合は ImageSize にそのまま格納されます。
depth は下表のように変換されます。
size.depth | 画像種別 (ImageType) |
---|---|
IPL_DEPTH_8U | UC8 |
IPL_DEPTH_16S | US16 |
IPL_DEPTH_16U | S16 |
IPL_DEPTH_32S | I32 |
IPL_DEPTH_32F | FLOAT |
IPL_DEPTH_64F | DOUBLE |
処理に失敗した場合は例外が発行されます。 例外の原因と発生位置を特定するには、発行された例外クラスの ErrorCode メンバと Function メンバを参照してください。
エラーコード:
値 | ErrorCode メンバ | 内容 |
---|---|---|
16 | FVIL.ErrorCode.INVALID_IMAGETYPE | 対応する画像種別がありません。 |
17 | FVIL.ErrorCode.INVALID_IMAGESIZE | 幅、高さが許容範囲外です。 |
18 | FVIL.ErrorCode.INVALID_CHANNEL | チャネル数が許容範囲外です。 |
Examples
出力結果:
ソースコード:
Copy | |
---|---|
HorzSize : 93 VertSize : 47 ImageType : UC8 Channel : 3 Depth : 8 ImageInfo : RGB |
ソースコード:
C# | Copy |
---|---|
// $Revision: 1.3 $ using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Drawing; using System.Reflection; namespace SampleCode.Ipl { partial class Converter { public static void ToImageSize1() { Console.WriteLine(MethodBase.GetCurrentMethod().Name); // 1) IplImageSize 構造体を初期化する. FVIL.Ipl.IplImageSize ipl_size; ipl_size.width = 93; ipl_size.height = 47; ipl_size.depth = (int)IPL_DEPTH.IPL_DEPTH_8U; ipl_size.channels = 3; // 2) 画像サイズ情報の取得. FVIL.ImageSize image_size = FVIL.Ipl.IplImageConverter.ToImageSize(ipl_size); // -) 確認.(任意) Console.WriteLine("{0,-20}: {1}", "HorzSize", image_size.HorzSize); Console.WriteLine("{0,-20}: {1}", "VertSize", image_size.VertSize); Console.WriteLine("{0,-20}: {1}", "ImageType", image_size.ImageType); Console.WriteLine("{0,-20}: {1}", "Channel", image_size.Channel); Console.WriteLine("{0,-20}: {1}", "Depth", image_size.Depth); Console.WriteLine("{0,-20}: {1}", "ImageInfo", image_size.ImageInfo); } } } |
Visual Basic | Copy |
---|---|
' $Revision: 1.2 $ Imports System.Collections.Generic Imports System.Text Imports System.Runtime.InteropServices Imports System.Drawing Imports System.Reflection Namespace Ipl Partial Class Converter Public Shared Sub ToImageSize1() Console.WriteLine(MethodBase.GetCurrentMethod().Name) ' 1) IplImageSize 構造体を初期化する. Dim ipl_size As FVIL.Ipl.IplImageSize ipl_size.width = 93 ipl_size.height = 47 ipl_size.depth = CInt(IPL_DEPTH.IPL_DEPTH_8U) ipl_size.channels = 3 ' 2) 画像サイズ情報の取得. Dim image_size As FVIL.ImageSize = FVIL.Ipl.IplImageConverter.ToImageSize(ipl_size) ' -) 確認.(任意) Console.WriteLine("{0,-20}: {1}", "HorzSize", image_size.HorzSize) Console.WriteLine("{0,-20}: {1}", "VertSize", image_size.VertSize) Console.WriteLine("{0,-20}: {1}", "ImageType", image_size.ImageType) Console.WriteLine("{0,-20}: {1}", "Channel", image_size.Channel) Console.WriteLine("{0,-20}: {1}", "Depth", image_size.Depth) Console.WriteLine("{0,-20}: {1}", "ImageInfo", image_size.ImageInfo) End Sub End Class End Namespace |
Exceptions
Exception | Condition |
---|---|
FVIL..::..CFviException | この例外の原因については、上記のエラーコード表をご参照ください。 |