| 1 | /**
|
|---|
| 2 | * (C) 2008 Schima
|
|---|
| 3 | * This code is licenced under the LGPL.
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | #pragma once
|
|---|
| 7 |
|
|---|
| 8 | #include "IplImage.h"
|
|---|
| 9 | #include "CvMatND.h"
|
|---|
| 10 | #include "CvSparseMat.h"
|
|---|
| 11 | #include "HistogramFormat.h"
|
|---|
| 12 |
|
|---|
| 13 | typedef struct CvHistogram __CvHistogram;
|
|---|
| 14 |
|
|---|
| 15 | using namespace System;
|
|---|
| 16 | using namespace System::Runtime::InteropServices;
|
|---|
| 17 | namespace N = KwsmLab::OpenCvSharp;
|
|---|
| 18 |
|
|---|
| 19 | namespace KwsmLab {
|
|---|
| 20 | namespace OpenCvSharp
|
|---|
| 21 | {
|
|---|
| 22 | /// <summary>
|
|---|
| 23 | /// 多次元ヒストグラムの構造体
|
|---|
| 24 | /// </summary>
|
|---|
| 25 | public ref class CvHistogram : public DisposableObject, public ICvObject
|
|---|
| 26 | {
|
|---|
| 27 | private:
|
|---|
| 28 | __CvHistogram* ptr;
|
|---|
| 29 | HistogramFormat type;
|
|---|
| 30 |
|
|---|
| 31 | protected:
|
|---|
| 32 | virtual void Release( void ) override;
|
|---|
| 33 |
|
|---|
| 34 | internal:
|
|---|
| 35 | /// <summary>
|
|---|
| 36 | /// メモリストレージへのポインタ [ __CvHistogram* ]
|
|---|
| 37 | /// </summary>
|
|---|
| 38 | property __CvHistogram* Ptr{
|
|---|
| 39 | __CvHistogram* get(void){ return (__CvHistogram*)this->ptr; }
|
|---|
| 40 | }
|
|---|
| 41 | CvHistogram( __CvHistogram* ptr );
|
|---|
| 42 |
|
|---|
| 43 | public:
|
|---|
| 44 | CvHistogram( array<Int32>^ dims, HistogramFormat type );
|
|---|
| 45 | CvHistogram( array<Int32>^ dims, HistogramFormat type, array<array<Single>^>^ ranges );
|
|---|
| 46 | CvHistogram( array<Int32>^ dims, HistogramFormat type, array<array<Single>^>^ ranges, Boolean uniform );
|
|---|
| 47 | static N::CvHistogram^ FromPtr( IntPtr ptr );
|
|---|
| 48 |
|
|---|
| 49 | #pragma region プロパティ}
|
|---|
| 50 | /// <summary>
|
|---|
| 51 | /// OpenCVのネイティブデータポインタを取得する
|
|---|
| 52 | /// </summary>
|
|---|
| 53 | virtual property IntPtr CvPtr{
|
|---|
| 54 | IntPtr get(void){ return (IntPtr)ptr; }
|
|---|
| 55 | }
|
|---|
| 56 | /// <summary>
|
|---|
| 57 | /// 元データポインタのバイトサイズ、
|
|---|
| 58 | /// すなわち sizeof(CvHistogram) を取得する.
|
|---|
| 59 | /// </summary>
|
|---|
| 60 | virtual property Int32 SizeOf{
|
|---|
| 61 | Int32 get(void){ return sizeof(*ptr); }
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | /// <summary>
|
|---|
| 65 | /// ヒストグラム表現フォーマットを取得する.
|
|---|
| 66 | /// </summary>
|
|---|
| 67 | property HistogramFormat Type{
|
|---|
| 68 | HistogramFormat get(void){ return type; }
|
|---|
| 69 | }
|
|---|
| 70 | /// <summary>
|
|---|
| 71 | /// ヒストグラムのビン(値域)を取得する.
|
|---|
| 72 | /// TypeがArrayならCvMatND, SparseならCvSparseMatが返される.
|
|---|
| 73 | /// </summary>
|
|---|
| 74 | property N::CvArr^ Bins{
|
|---|
| 75 | N::CvArr^ get(void){
|
|---|
| 76 | switch(Type){
|
|---|
| 77 | case HistogramFormat::Array:
|
|---|
| 78 | return gcnew N::CvMatND((::CvMatND*)ptr->bins, false);
|
|---|
| 79 | case HistogramFormat::Sparse:
|
|---|
| 80 | return gcnew N::CvSparseMat((::CvSparseMat*)ptr->bins, false);
|
|---|
| 81 | default:
|
|---|
| 82 | throw gcnew Exception("improbable" + Type.ToString());
|
|---|
| 83 | }
|
|---|
| 84 | }
|
|---|
| 85 | }
|
|---|
| 86 | #pragma endregion
|
|---|
| 87 |
|
|---|
| 88 | #pragma region メソッド
|
|---|
| 89 | void CalcArr( N::CvArr^ arr );
|
|---|
| 90 | void CalcArr( N::CvArr^ arr, Int32 accumulate );
|
|---|
| 91 | void CalcArr( N::CvArr^ arr, Int32 accumulate, N::CvArr^ mask );
|
|---|
| 92 | void CalcArr( array<N::CvArr^>^ arr );
|
|---|
| 93 | void CalcArr( array<N::CvArr^>^ arr, Int32 accumulate );
|
|---|
| 94 | void CalcArr( array<N::CvArr^>^ arr, Int32 accumulate, N::CvArr^ mask );
|
|---|
| 95 | void Calc( N::IplImage^ image );
|
|---|
| 96 | void Calc( N::IplImage^ image, Int32 accumulate );
|
|---|
| 97 | void Calc( N::IplImage^ image, Int32 accumulate, N::CvArr^ mask );
|
|---|
| 98 | void Calc( array<N::IplImage^>^ image );
|
|---|
| 99 | void Calc( array<N::IplImage^>^ image, Int32 accumulate );
|
|---|
| 100 | void Calc( array<N::IplImage^>^ image, Int32 accumulate, N::CvArr^ mask );
|
|---|
| 101 | void Clear( void );
|
|---|
| 102 | Double Compare( N::CvHistogram^ hist, HistogramComparison method );
|
|---|
| 103 | Single* GetValue1D( Int32 idx0 );
|
|---|
| 104 | Single* GetValue2D( Int32 idx0, Int32 idx1 );
|
|---|
| 105 | Single* GetValue3D( Int32 idx0, Int32 idx1, Int32 idx2 );
|
|---|
| 106 | Single* GetValueND( ... array<Int32>^ idx );
|
|---|
| 107 | void GetMinMaxValue( [Out] Single% min_value, [Out] Single% max_value );
|
|---|
| 108 | void GetMinMaxValue( [Out] Single% min_value, [Out] Single% max_value, [Out] Int32% min_idx, [Out] Int32% max_idx );
|
|---|
| 109 | void Normalize( Double factor );
|
|---|
| 110 | Double QueryValue1D( Int32 idx0 );
|
|---|
| 111 | Double QueryValue2D( Int32 idx0, Int32 idx1 );
|
|---|
| 112 | Double QueryValue3D( Int32 idx0, Int32 idx1, Int32 idx2 );
|
|---|
| 113 | Double QueryValueND( ... array<Int32>^ idx );
|
|---|
| 114 | void SetBinRanges( array<array<Single>^>^ ranges );
|
|---|
| 115 | void SetBinRanges( array<array<Single>^>^ ranges, Boolean uniform );
|
|---|
| 116 | void Thresh( Double threshold );
|
|---|
| 117 | #pragma endregion
|
|---|
| 118 | };
|
|---|
| 119 |
|
|---|
| 120 | }
|
|---|
| 121 | } |
|---|