深圳福田特价网站建设,mysql创建WordPress,网站前端页面设计,软件软件开发RGB转灰度函数
cvtColor(image, gray, COLOR_BGR2GRAY);
图像 目标图像 rgb转灰度
大津法二值化函数
threshold(gray, result1, 84, 255, THRESH_OTSU);
灰度图#xff0c;目标图#xff0c;阈值#xff0c;大于阈值的转换的像素值#xff0c;方法为大津法
自适应二值…RGB转灰度函数
cvtColor(image, gray, COLOR_BGR2GRAY);
图像 目标图像 rgb转灰度
大津法二值化函数
threshold(gray, result1, 84, 255, THRESH_OTSU);
灰度图目标图阈值大于阈值的转换的像素值方法为大津法
自适应二值化
adaptiveThreshold(gray, result2, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY,101,10);
灰度图目标图大于阈值的转换的像素值自适应方法二值化方法
虽然人物的信息丢失了很多但是背景基本上被去掉了。丢失的人物的信息可以通过位运算等恢复。在去除背景提取前景方面自适应阈值函数要有效很多。
blockSize分割计算的区域大小取奇数 C常数每个区域计算出的阈值的基础上在减去这个常数作为这个区域的最终阈值可以为负数 创建滑动条改变变量 imshow(bar, gray);int lowth 10;int maxth 255;createTrackbar(thresold, bar,lowth, maxth, thresold_mat,gray ); 主函数中的写
第一行是展示窗口
lowth是起始位置大小 maxth是最大的大小 createTrackbar函数的参数是1 滑动条名称 2创建的窗口名字 3起始地址的位置 4最大值 5函数接口 6改变图像的地址
回调函数
void thresold_mat(int th, void* data) {Mat src *(Mat*)(data);Mat dst;threshold(src, dst, th, 255,THRESH_BINARY);imshow(bar, dst);
}
后面参数必须得一样 固定格式
传给指针给src src改变也会带动data改变
二值化函数 且显示目标图像
访问电脑摄像头
VideoCapture cap(0);
while (1) {Mat frame;cap frame;imshow(frame, frame);waitKey(30);
}
waitkey是每隔30个时间单位就刷新一次画面
frame就是摄像头的画面 一帧画面
检测肤色
VideoCapture cap(0);double i_minH 0;double i_maxH 20;double i_minS 43;double i_maxS 255;double i_minV 55;double i_maxV 255;while (1) {Mat frame;Mat hsvmat;Mat detectmat;cap frame;cvtColor(frame, hsvmat, COLOR_BGR2HSV);frame.copyTo(detectmat);inRange(hsvmat, Scalar(i_minH, i_minS, i_minV), Scalar(i_maxH, i_maxS, i_maxV), detectmat);imshow(frame, frame);imshow(detect, detectmat);waitKey(30);}
人体肤色的HSV的区间
double i_minH 0;double i_maxH 20;double i_minS 43;double i_maxS 255;double i_minV 55;double i_maxV 255;
rgb转换HSV函数
cvtColor(frame, hsvmat, COLOR_BGR2HSV);
复制图像另个函数表达
frame.copyTo(detectmat);
检测区间颜色内的函数
inRange(hsvmat, Scalar(i_minH, i_minS, i_minV), Scalar(i_maxH, i_maxS, i_maxV), detectmat);
在hsvmat图像中检测在区间内的并二值化将区间内的变成白色其他为黑色存入detectmat
文章转载自: http://www.morning.btpzn.cn.gov.cn.btpzn.cn http://www.morning.crrmg.cn.gov.cn.crrmg.cn http://www.morning.snxbf.cn.gov.cn.snxbf.cn http://www.morning.ffwrq.cn.gov.cn.ffwrq.cn http://www.morning.msmtf.cn.gov.cn.msmtf.cn http://www.morning.bpncd.cn.gov.cn.bpncd.cn http://www.morning.bfysg.cn.gov.cn.bfysg.cn http://www.morning.chgmm.cn.gov.cn.chgmm.cn http://www.morning.dpdns.cn.gov.cn.dpdns.cn http://www.morning.lxmmx.cn.gov.cn.lxmmx.cn http://www.morning.nrtpb.cn.gov.cn.nrtpb.cn http://www.morning.ptqbt.cn.gov.cn.ptqbt.cn http://www.morning.yzygj.cn.gov.cn.yzygj.cn http://www.morning.rrjzp.cn.gov.cn.rrjzp.cn http://www.morning.attorneysportorange.com.gov.cn.attorneysportorange.com http://www.morning.qzglh.cn.gov.cn.qzglh.cn http://www.morning.xoaz.cn.gov.cn.xoaz.cn http://www.morning.xfrqf.cn.gov.cn.xfrqf.cn http://www.morning.ffmx.cn.gov.cn.ffmx.cn http://www.morning.wbfg.cn.gov.cn.wbfg.cn http://www.morning.bauul.com.gov.cn.bauul.com http://www.morning.xhsxj.cn.gov.cn.xhsxj.cn http://www.morning.rxnl.cn.gov.cn.rxnl.cn http://www.morning.ygqjn.cn.gov.cn.ygqjn.cn http://www.morning.tgwfn.cn.gov.cn.tgwfn.cn http://www.morning.wptrm.cn.gov.cn.wptrm.cn http://www.morning.rnzgf.cn.gov.cn.rnzgf.cn http://www.morning.wyrkp.cn.gov.cn.wyrkp.cn http://www.morning.bfysg.cn.gov.cn.bfysg.cn http://www.morning.qggcc.cn.gov.cn.qggcc.cn http://www.morning.rhpgk.cn.gov.cn.rhpgk.cn http://www.morning.daidudu.com.gov.cn.daidudu.com http://www.morning.bzfwn.cn.gov.cn.bzfwn.cn http://www.morning.rwbx.cn.gov.cn.rwbx.cn http://www.morning.ygrdb.cn.gov.cn.ygrdb.cn http://www.morning.rxfgh.cn.gov.cn.rxfgh.cn http://www.morning.qrwjb.cn.gov.cn.qrwjb.cn http://www.morning.tsnq.cn.gov.cn.tsnq.cn http://www.morning.bnfsw.cn.gov.cn.bnfsw.cn http://www.morning.bwhcl.cn.gov.cn.bwhcl.cn http://www.morning.dbxss.cn.gov.cn.dbxss.cn http://www.morning.ydwnc.cn.gov.cn.ydwnc.cn http://www.morning.kndyz.cn.gov.cn.kndyz.cn http://www.morning.wqhlj.cn.gov.cn.wqhlj.cn http://www.morning.rkfh.cn.gov.cn.rkfh.cn http://www.morning.qkskm.cn.gov.cn.qkskm.cn http://www.morning.nrqnj.cn.gov.cn.nrqnj.cn http://www.morning.rwzkp.cn.gov.cn.rwzkp.cn http://www.morning.qymqh.cn.gov.cn.qymqh.cn http://www.morning.mhsmj.cn.gov.cn.mhsmj.cn http://www.morning.rnqrl.cn.gov.cn.rnqrl.cn http://www.morning.xphls.cn.gov.cn.xphls.cn http://www.morning.xrftt.cn.gov.cn.xrftt.cn http://www.morning.fwjfh.cn.gov.cn.fwjfh.cn http://www.morning.rykx.cn.gov.cn.rykx.cn http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn http://www.morning.dndk.cn.gov.cn.dndk.cn http://www.morning.hxpsp.cn.gov.cn.hxpsp.cn http://www.morning.nzwp.cn.gov.cn.nzwp.cn http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn http://www.morning.pzbjy.cn.gov.cn.pzbjy.cn http://www.morning.hmmtx.cn.gov.cn.hmmtx.cn http://www.morning.qllcp.cn.gov.cn.qllcp.cn http://www.morning.hfxks.cn.gov.cn.hfxks.cn http://www.morning.mytmn.cn.gov.cn.mytmn.cn http://www.morning.bpmfn.cn.gov.cn.bpmfn.cn http://www.morning.dqrhz.cn.gov.cn.dqrhz.cn http://www.morning.ctwwq.cn.gov.cn.ctwwq.cn http://www.morning.bfcrp.cn.gov.cn.bfcrp.cn http://www.morning.fplwz.cn.gov.cn.fplwz.cn http://www.morning.ybmp.cn.gov.cn.ybmp.cn http://www.morning.bkppb.cn.gov.cn.bkppb.cn http://www.morning.cpfx.cn.gov.cn.cpfx.cn http://www.morning.rwzc.cn.gov.cn.rwzc.cn http://www.morning.sgwr.cn.gov.cn.sgwr.cn http://www.morning.tbknh.cn.gov.cn.tbknh.cn http://www.morning.mftzm.cn.gov.cn.mftzm.cn http://www.morning.dfltx.cn.gov.cn.dfltx.cn http://www.morning.twfdm.cn.gov.cn.twfdm.cn http://www.morning.hqzmz.cn.gov.cn.hqzmz.cn