opencv inrange 和 mix
Posted 每天一点积累
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了opencv inrange 和 mix相关的知识,希望对你有一定的参考价值。
opencv inrange:
http://blog.csdn.net/xiaoyufei117122/article/details/53572904
http://blog.csdn.net/wejoncy/article/details/50599640?locationNum=2&fps=1
在Python中如果是单通道,假设lower=[0],upper=[128],那么,对每个数在0-128之间为255,否则为0;
如果是多通道,假设lower=[0,0,0],upper=[128,128,128,128],那么,对每一行,对任意一个数,如果在范围内,则255,否则0,最后的几个数相与,因此如果都是255,为255,否则为0
opencv mixchannels:
http://www.cnblogs.com/ruic/archive/2015/10/31/4926254.html
opencv calchist:
http://blog.csdn.net/ubunfans/article/details/23619771
// Object has been selected by user, set up CAMShift search properties once Mat roi(hue, selection), maskroi(mask, selection); calcHist(&roi, 1, 0, maskroi, hist, 1, &hsize, &phranges); normalize(hist, hist, 0, 255, NORM_MINMAX); trackWindow = selection; trackObject = 1; // Don\'t set up again, unless user selects new ROI histimg = Scalar::all(0); int binW = histimg.cols / hsize; Mat buf(1, hsize, CV_8UC3); for( int i = 0; i < hsize; i++ ) buf.at<Vec3b>(i) = Vec3b(saturate_cast<uchar>(i*180./hsize), 255, 255); cvtColor(buf, buf, COLOR_HSV2BGR); for( int i = 0; i < hsize; i++ ) { int val = saturate_cast<int>(hist.at<float>(i)*histimg.rows/255); rectangle( histimg, Point(i*binW,histimg.rows), Point((i+1)*binW,histimg.rows - val), Scalar(buf.at<Vec3b>(i)), -1, 8 ); }
以上是关于opencv inrange 和 mix的主要内容,如果未能解决你的问题,请参考以下文章
在 OpenCV (Java) 中获取正确的 HSV 颜色 inRange
如何在OpenCV中为InRange阈值选择颜色的最佳HSV值