6

easy question but can't figure it out.

normaly its void minMaxLoc(InputArray src, double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, InputArray mask=noArray()) But how does the mask looks like?

This is what i want: Its an one-dimensional Mat (only one row) and i want the minMax location of an interval(lower till upperBorder) of the Mat (maxRowGChnnl).

int lowerBorder,upperBorder;
lowerBorder = 30;
upperBorder = 100;
cv::minMaxLoc(maxRowGChnnl.row(0),&minValue,&maxValue,&minLoc,&maxLoc,(lowerBorder,upperBorder));

This is the maxRowGChnnl size:

maxRowGChnnl    {flags=1124024325 dims=2 rows=1 ...}    cv::Mat
flags   1124024325  int
dims    2   int
rows    1   int
cols    293 int

The code above abborts with:

OpenCV Error: Assertion failed ((cn == 1 && (mask.empty() || mask.type() == CV_8
U)) || (cn >= 1 && mask.empty() && !minIdx && !maxIdx)) in unknown function, fil
e ..\..\..\src\opencv\modules\core\src\stat.cpp, line 787

Thanks for your help.

4

2 回答 2

7

掩码应该是与 axRowGChnnl.row(0) 大小相同的 cv::Mat 并键入 CV_8UC1。启用元素的值应等于 1 禁用 0。

于 2013-11-25T14:51:43.140 回答
5

您实际上并不需要掩码,而是 maxRowGChnnl 的子矩阵。您可以通过以下方式做到这一点:

cv::minMaxLoc(maxRowGChnnl(Rect(lower,0,upper-lower,0)),&minValue,&maxValue,&minLoc,&maxLoc);
于 2013-11-25T15:14:19.450 回答