OpenCV 5.0.0
Open Source Computer Vision
読み込み中...
検索中...
見つかりません
🤖 AIによる機械翻訳(非公式) — これは OpenCV 5.0.0 公式リファレンス(英語)を AI (Claude) で自動翻訳したものです。訳に誤りを含む場合があります。正確な情報は 公式英語版(原文) を参照してください。
cv::NAryMatIterator クラス

n項多次元配列イテレータ。 詳細...

#include <opencv2/core/mat.hpp>

Collaboration diagram for cv::NAryMatIterator:

公開メンバ関数

 NAryMatIterator ()
 デフォルトコンストラクタ
 
 NAryMatIterator (const Mat **arrays, Mat *planes, int narrays=-1)
 任意個数のn次元行列を受け取る完全コンストラクタ
 
 NAryMatIterator (const Mat **arrays, uchar **ptrs, int narrays=-1)
 任意個数のn次元行列を受け取る完全コンストラクタ
 
void init (const Mat **arrays, Mat *planes, uchar **ptrs, int narrays=-1)
 個別のイテレータ初期化メソッド
 
NAryMatIteratoroperator++ ()
 反復対象のすべての行列の次のプレーンへ進む
 
NAryMatIterator operator++ (int)
 反復対象のすべての行列の次のプレーンへ進む(後置インクリメント演算子)
 

公開変数類

const Mat ** arrays
 反復対象の配列
 
int narrays
 配列の数
 
size_t nplanes
 イテレータがステップする超平面の数
 
Matplanes
 現在のプレーン
 
uchar ** ptrs
 データポインタ
 
size_t size
 各セグメントのサイズ(要素単位)
 

限定公開変数類

size_t idx
 
int iterdepth
 

詳細説明

n項多次元配列イテレータ。

このクラスは、多次元配列に対する単項・二項、および一般的なn項の要素ごとの演算を実装するために使う。n項関数の引数の一部は連続配列である場合もあれば、そうでない場合もある。各配列に対して通常の MatIterator を使うことも可能だが、小さな演算のたびにすべてのイテレータをインクリメントするとオーバーヘッドが大きくなる場合がある。このような場合、同じ形状(次元数とすべての次元サイズが同じ)を持つ複数の行列を同時に反復するために NAryMatIterator の使用を検討するとよい。各反復において it.planes[0]it.planes[1]、... は対応する行列のスライスとなる。

以下の例は、正規化およびしきい値処理した3Dカラーヒストグラムを計算する方法を示している:

void computeNormalizedColorHist(const Mat& image, Mat& hist, int N, double minProb)
{
const int histSize[] = {N, N, N};
// make sure that the histogram has a proper size and type
hist.create(3, histSize, CV_32F);
// and clear it
hist = Scalar(0);
// the loop below assumes that the image
// is a 8-bit 3-channel. check it.
CV_Assert(image.type() == CV_8UC3);
it_end = image.end<Vec3b>();
for( ; it != it_end; ++it )
{
const Vec3b& pix = *it;
hist.at<float>(pix[0]*N/256, pix[1]*N/256, pix[2]*N/256) += 1.f;
}
minProb *= image.rows*image.cols;
// initialize iterator (the style is different from STL).
// after initialization the iterator will contain
// the number of slices or planes the iterator will go through.
// it simultaneously increments iterators for several matrices
// supplied as a null terminated list of pointers
const Mat* arrays[] = {&hist, 0};
Mat planes[1];
double s = 0;
// iterate through the matrix. on each iteration
// itNAry.planes[i] (of type Mat) will be set to the current plane
// of the i-th n-dim matrix passed to the iterator constructor.
for(int p = 0; p < itNAry.nplanes; p++, ++itNAry)
{
threshold(itNAry.planes[0], itNAry.planes[0], minProb, 0, THRESH_TOZERO);
s += sum(itNAry.planes[0])[0];
}
s = 1./s;
itNAry = NAryMatIterator(arrays, planes, 1);
for(int p = 0; p < itNAry.nplanes; p++, ++itNAry)
itNAry.planes[0] *= s;
}
Matrix read-only iterator.
Definition mat.hpp:3513
Comma-separated Matrix Initializer.
Definition mat.hpp:964
MatIterator_< _Tp > end()
Returns the matrix iterator and sets it to the after-last matrix element.
void create(int rows, int cols, int type)
Allocates new array data if needed.
MatIterator_< _Tp > begin()
Returns the matrix iterator and sets it to the first matrix element.
_Tp & at(int i0=0)
Returns a reference to the specified array element.
int cols
Definition mat.hpp:2488
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions
Definition mat.hpp:2488
int type() const
Returns the type of a matrix element.
const Mat ** arrays
the iterated arrays
Definition mat.hpp:3842
Mat * planes
the current planes
Definition mat.hpp:3844
NAryMatIterator()
the default constructor
Template class for short numerical vectors, a partial case of Matx.
Definition matx.hpp:379
Scalar sum(InputArray src)
Calculates the sum of array elements.
Scalar_< double > Scalar
Definition types.hpp:712
#define CV_32F
Definition interface.h:59
#define CV_8UC3
Definition interface.h:79
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails.
Definition exception.hpp:198
double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type)
Applies a fixed-level threshold to each array element.
@ THRESH_TOZERO
Definition imgproc.hpp:311

構築子と解体子の詳解

◆ NAryMatIterator() [1/3]

cv::NAryMatIterator::NAryMatIterator ( )

デフォルトコンストラクタ

◆ NAryMatIterator() [2/3]

cv::NAryMatIterator::NAryMatIterator ( const Mat ** arrays,
uchar ** ptrs,
int narrays = -1 )

任意個数のn次元行列を受け取る完全コンストラクタ

◆ NAryMatIterator() [3/3]

cv::NAryMatIterator::NAryMatIterator ( const Mat ** arrays,
Mat * planes,
int narrays = -1 )

任意個数のn次元行列を受け取る完全コンストラクタ

メンバ関数詳解

◆ init()

void cv::NAryMatIterator::init ( const Mat ** arrays,
Mat * planes,
uchar ** ptrs,
int narrays = -1 )

個別のイテレータ初期化メソッド

◆ operator++() [1/2]

NAryMatIterator & cv::NAryMatIterator::operator++ ( )

反復対象のすべての行列の次のプレーンへ進む

◆ operator++() [2/2]

NAryMatIterator cv::NAryMatIterator::operator++ ( int )

反復対象のすべての行列の次のプレーンへ進む(後置インクリメント演算子)

メンバ変数詳解

◆ arrays

const Mat** cv::NAryMatIterator::arrays

反復対象の配列

◆ idx

size_t cv::NAryMatIterator::idx
protected

◆ iterdepth

int cv::NAryMatIterator::iterdepth
protected

◆ narrays

int cv::NAryMatIterator::narrays

配列の数

◆ nplanes

size_t cv::NAryMatIterator::nplanes

イテレータがステップする超平面の数

◆ planes

Mat* cv::NAryMatIterator::planes

現在のプレーン

◆ ptrs

uchar** cv::NAryMatIterator::ptrs

データポインタ

◆ size

size_t cv::NAryMatIterator::size

各セグメントのサイズ(要素単位)


このクラス詳解は次のファイルから抽出されました: