还是和以往一样,在研究OpenCV。
在看到OpenCV.2.Computer.Vision.Application.Programming.Cookbook的第五章的时候出现了个watershed算法,用起来到挺简单,但是一直想不通那个marker image应该怎么标!
书上有一句:
Here, we will mark foreground pixels with label 255 and background pixels with label 128 (this choice is totally arbitrary, any label number other than 255 would work).
他说这个选择是任意的!
然后继续看:
在看到OpenCV.2.Computer.Vision.Application.Programming.Cookbook的第五章的时候出现了个watershed算法,用起来到挺简单,但是一直想不通那个marker image应该怎么标!
书上有一句:
Here, we will mark foreground pixels with label 255 and background pixels with label 128 (this choice is totally arbitrary, any label number other than 255 would work).
他说这个选择是任意的!
然后继续看:
1 2 3 4 5 | // Identify image pixels without objects cv::Mat bg; cv::dilate(binary,bg,cv::Mat(),cv::Point(-1,-1),6); cv::threshold(bg,bg,1,128,cv::THRESH_BINARY_INV); //这里我就怪了!前面说Marker是任意的,这里的阈值结果为啥要反一反啊? |
于是我就试着把cv::THRESH_BINARY_INV改为cv::THRESH_BINARY
看看会出现什么情况!结果查找结果跟前景图一样了!!
看看会出现什么情况!结果查找结果跟前景图一样了!!