Find the minimum value and it's location from the depth images
I am working depth data which is in the format of 16UC1. I want to find out the min value (greater than 0) with location from the image. I am using the minMaxLoc function but I am getting the error. It may be because of short values. It will be great , if you suggest the way. (previously I asked similar question but that question was general http://answers.opencv.org/question/17...)
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; }
imread("depth272.tiff") // will read a 3 channel, 8bit image. you probably missed the -1 flag
and the error is ?
@berak, I have changed Mat abc = imread("depth272.tiff"); to Mat abc = imread("depth272.tiff", IMREAD_UNCHANGED); The error is gone but I am getting the type of the matrix xyz as 0. It may be because of comparison with 0. I need the type of xyz as same as abc i.e.2.
"I am getting the type of the matrix xyz as 0." -- yes, that's expected. a binary mask is uchar.
why do you need something else ?
Thank you @berak , now I understand :)