从opencv c ++中的深度图像中找到最小值及其位置
Find the minimum value and it's location from the depth images in opencv c++
我正在处理16UC1格式的深度数据。我想从图像中找出带有位置的最小值(大于 0)。我正在使用 minMaxLoc 函数,但出现错误。这可能是因为短值。如果你能推荐一下就太好了。
int main()
{
Mat abc = imread("depth272.tiff");
cout << abc.size() << endl;
imshow("depth_image",abc);
Mat xyz = abc > 0;
cout << "abc type: " << abc.type() << "xyz type " << xyz.type() << endl;
double rmin, rmax;
Point rMinPoint, pMaxPoint;
minMaxLoc(abc, &rmin, &rmax, &rMinPoint, &pMaxPoint, xyz);
int row = rMinPoint.x;
int col = rMinPoint.y;
waitKey(0);
return 0;
}
图像加载为 3 通道 8UC3
图像。
函数 minMaxLoc()
仅适用于单通道图像。
正如@Miki 建议的那样,您应该使用 imread(..., IMREAD_UNCHANGED)
加载为 CV_16UC1
.
我正在处理16UC1格式的深度数据。我想从图像中找出带有位置的最小值(大于 0)。我正在使用 minMaxLoc 函数,但出现错误。这可能是因为短值。如果你能推荐一下就太好了。
int main()
{
Mat abc = imread("depth272.tiff");
cout << abc.size() << endl;
imshow("depth_image",abc);
Mat xyz = abc > 0;
cout << "abc type: " << abc.type() << "xyz type " << xyz.type() << endl;
double rmin, rmax;
Point rMinPoint, pMaxPoint;
minMaxLoc(abc, &rmin, &rmax, &rMinPoint, &pMaxPoint, xyz);
int row = rMinPoint.x;
int col = rMinPoint.y;
waitKey(0);
return 0;
}
图像加载为 3 通道 8UC3
图像。
函数 minMaxLoc()
仅适用于单通道图像。
正如@Miki 建议的那样,您应该使用 imread(..., IMREAD_UNCHANGED)
加载为 CV_16UC1
.