gocv icon indicating copy to clipboard operation
gocv copied to clipboard

MinMaxIdx function does not return the correct index.

Open chronicom opened this issue 4 months ago • 0 comments

The problem seems to me a typo in the code.

func MinMaxIdx(input Mat) (minVal, maxVal float32, minIdx, maxIdx int) {
	var cMinVal C.double
	var cMaxVal C.double
	var cMinIdx C.int
	var cMaxIdx C.int

	C.Mat_MinMaxIdx(input.p, &cMinVal, &cMaxVal, &cMinIdx, &cMaxIdx)

	return float32(cMinVal), float32(cMaxVal), int(minIdx), int(maxIdx)
}

In stead of returning

float32(cMinVal), float32(cMaxVal), int(minIdx), int(maxIdx)

I guess it should be returning

float32(cMinVal), float32(cMaxVal), int(cMinIdx), int(cMaxIdx)

Moreover, the opencv version of MinMaxIdx returns the indexs in the form of an array of size corresponding to the dimension of the input mat. Here the index is simply a scalar. Does it mean it is a linearized version of the nd-index?

chronicom avatar Feb 19 '24 23:02 chronicom