当前位置: 首页 > news >正文

有几个网站能在百度做推广百度联盟app

有几个网站能在百度做推广,百度联盟app,在线做简单的网站,开源crm客户管理系统Opencv 中 watershed函数原型: void watershed( InputArray image, InputOutputArray markers ); 第一个参数 image,必须是一个8bit 3通道彩色图像矩阵序列,第一个参数没什么要说的。关键是第二个参数 markers,Opencv官方文档的说…

Opencv 中 watershed函数原型:

void watershed( InputArray image, InputOutputArray markers );

 

第一个参数 image,必须是一个8bit 3通道彩色图像矩阵序列,第一个参数没什么要说的。关键是第二个参数 markers,Opencv官方文档的说明如下:

Before passing the image to the function, you have to roughly outline the desired regions in the image markers with positive (>0) indices. So, every region is represented as one or more connected components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary mask using findContours() and drawContours(). The markers are “seeds” of the future image regions. All the other pixels in markers , whose relation to the outlined regions is not known and should be defined by the algorithm, should be set to 0’s. In the function output, each pixel in markers is set to a value of the “seed” components or to -1 at boundaries between the regions.

就不一句一句翻译了,大意说的是在执行分水岭函数watershed之前,必须对第二个参数markers进行处理,它应该包含不同区域的轮廓,每个轮廓有一个自己唯一的编号,轮廓的定位可以通过Opencv中findContours方法实现,这个是执行分水岭之前的要求。

接下来执行分水岭会发生什么呢?算法会根据markers传入的轮廓作为种子(也就是所谓的注水点),对图像上其他的像素点根据分水岭算法规则进行判断,并对每个像素点的区域归属进行划定,直到处理完图像上所有像素点。而区域与区域之间的分界处的值被置为“-1”,以做区分。

简单概括一下就是说第二个入参markers必须包含了种子点信息。Opencv官方例程中使用鼠标划线标记,其实就是在定义种子,只不过需要手动操作,而使用findContours可以自动标记种子点。而分水岭方法完成之后并不会直接生成分割后的图像,还需要进一步的显示处理,如此看来,只有两个参数的watershed其实并不简单。

下边通过图示来看一下watershed函数的第二个参数markers在算法执行前后发生了什么变化。对于一个原图:

 

经过灰度化、滤波、Canny边缘检测、findContours轮廓查找、轮廓绘制等步骤后终于得到了符合Opencv要求的merkers,我们把merkers转换成8bit单通道灰度图看看它里边到底是什么内容:

这个是分水岭运算前的merkers:

 这个是findContours检测到的轮廓:

 

看效果,基本上跟图像的轮廓是一样的,也是简单的勾勒出了物体的外形。但如果仔细观察就能发现,图像上不同线条的灰度值是不同的,底部略暗,越往上灰度越高。由于这幅图像边缘比较少,对比不是很明显.

从图像底部往上,线条的灰度值是越来越高的,并且merkers图像底部部分线条的灰度值由于太低,已经观察不到了。相互连接在一起的线条灰度值是一样的,这些线条和不同的灰度值又能说明什么呢?

答案是:每一个线条代表了一个种子,线条的不同灰度值其实代表了对不同注水种子的编号,有多少不同灰度值的线条,就有多少个种子,图像最后分割后就有多少个区域。

再来看一下执行完分水岭方法之后merkers里边的内容发生了什么变化:

 

可以看到,执行完watershed之后,merkers里边被分割出来的区域已经非常明显了,空间上临近并且灰度值上相近的区域被划分为一个区域,灰度值是一样,不同区域间被划分开,这其实就是分水岭对图像的分割效果了。

总的概括一下watershed图像自动分割的实现步骤:

1. 图像灰度化、滤波、Canny边缘检测

2. 查找轮廓,并且把轮廓信息按照不同的编号绘制到watershed的第二个入参merkers上,相当于标记注水点。

3. watershed分水岭运算

4. 绘制分割出来的区域,视觉控还可以使用随机颜色填充,或者跟原始图像融合以下,以得到更好的显示效果。

以下是Opencv分水岭算法watershed实现的完整过程:

#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"#include <iostream>using namespace cv;
using namespace std;Vec3b RandomColor(int value);  //生成随机颜色函数int main( int argc, char* argv[] )
{Mat image=imread(argv[1]);    //载入RGB彩色图像imshow("Source Image",image);//灰度化,滤波,Canny边缘检测Mat imageGray;cvtColor(image,imageGray,CV_RGB2GRAY);//灰度转换GaussianBlur(imageGray,imageGray,Size(5,5),2);   //高斯滤波imshow("Gray Image",imageGray); Canny(imageGray,imageGray,80,150);  imshow("Canny Image",imageGray);//查找轮廓vector<vector<Point>> contours;  vector<Vec4i> hierarchy;  findContours(imageGray,contours,hierarchy,RETR_TREE,CHAIN_APPROX_SIMPLE,Point());  Mat imageContours=Mat::zeros(image.size(),CV_8UC1);  //轮廓	Mat marks(image.size(),CV_32S);   //Opencv分水岭第二个矩阵参数marks=Scalar::all(0);int index = 0;int compCount = 0;for( ; index >= 0; index = hierarchy[index][0], compCount++ ) {//对marks进行标记,对不同区域的轮廓进行编号,相当于设置注水点,有多少轮廓,就有多少注水点drawContours(marks, contours, index, Scalar::all(compCount+1), 1, 8, hierarchy);drawContours(imageContours,contours,index,Scalar(255),1,8,hierarchy);  }//我们来看一下传入的矩阵marks里是什么东西Mat marksShows;convertScaleAbs(marks,marksShows);imshow("marksShow",marksShows);imshow("轮廓",imageContours);watershed(image,marks);//我们再来看一下分水岭算法之后的矩阵marks里是什么东西Mat afterWatershed;convertScaleAbs(marks,afterWatershed);imshow("After Watershed",afterWatershed);//对每一个区域进行颜色填充Mat PerspectiveImage=Mat::zeros(image.size(),CV_8UC3);for(int i=0;i<marks.rows;i++){for(int j=0;j<marks.cols;j++){int index=marks.at<int>(i,j);if(marks.at<int>(i,j)==-1){PerspectiveImage.at<Vec3b>(i,j)=Vec3b(255,255,255);}			 else{PerspectiveImage.at<Vec3b>(i,j) =RandomColor(index);}}}imshow("After ColorFill",PerspectiveImage);//分割并填充颜色的结果跟原始图像融合Mat wshed;addWeighted(image,0.4,PerspectiveImage,0.6,0,wshed);imshow("AddWeighted Image",wshed);waitKey();
}Vec3b RandomColor(int value)    <span style="line-height: 20.8px; font-family: sans-serif;">//生成随机颜色函数</span>
{value=value%255;  //生成0~255的随机数RNG rng;int aa=rng.uniform(0,value);int bb=rng.uniform(0,value);int cc=rng.uniform(0,value);return Vec3b(aa,bb,cc);
}

 分割效果:

 


文章转载自:
http://sweetsop.mnqg.cn
http://russophile.mnqg.cn
http://cemental.mnqg.cn
http://crotched.mnqg.cn
http://epaulette.mnqg.cn
http://abirritative.mnqg.cn
http://broider.mnqg.cn
http://cinefilm.mnqg.cn
http://ringsider.mnqg.cn
http://thermoscope.mnqg.cn
http://tangshan.mnqg.cn
http://percolation.mnqg.cn
http://admirable.mnqg.cn
http://equipartition.mnqg.cn
http://atonalistic.mnqg.cn
http://yenisei.mnqg.cn
http://ayrshire.mnqg.cn
http://georgic.mnqg.cn
http://bemaul.mnqg.cn
http://scandal.mnqg.cn
http://clue.mnqg.cn
http://sazerac.mnqg.cn
http://respondentia.mnqg.cn
http://diluvian.mnqg.cn
http://hypergol.mnqg.cn
http://screenplay.mnqg.cn
http://jorum.mnqg.cn
http://intercalation.mnqg.cn
http://lavishly.mnqg.cn
http://rockfall.mnqg.cn
http://yowie.mnqg.cn
http://interruptable.mnqg.cn
http://vine.mnqg.cn
http://irvine.mnqg.cn
http://steeliness.mnqg.cn
http://melanesia.mnqg.cn
http://corrigent.mnqg.cn
http://uncaused.mnqg.cn
http://eytie.mnqg.cn
http://doughboy.mnqg.cn
http://biopotency.mnqg.cn
http://radiogeology.mnqg.cn
http://annamese.mnqg.cn
http://annihilative.mnqg.cn
http://antibody.mnqg.cn
http://crackle.mnqg.cn
http://camphorate.mnqg.cn
http://landscape.mnqg.cn
http://reviler.mnqg.cn
http://deracialize.mnqg.cn
http://delete.mnqg.cn
http://quartation.mnqg.cn
http://futureless.mnqg.cn
http://laminated.mnqg.cn
http://neuroethology.mnqg.cn
http://interzone.mnqg.cn
http://landform.mnqg.cn
http://pruth.mnqg.cn
http://foeman.mnqg.cn
http://ice.mnqg.cn
http://inexperience.mnqg.cn
http://morphophoneme.mnqg.cn
http://diverse.mnqg.cn
http://rentable.mnqg.cn
http://tongued.mnqg.cn
http://trireme.mnqg.cn
http://deckie.mnqg.cn
http://best.mnqg.cn
http://agreement.mnqg.cn
http://skeletogenous.mnqg.cn
http://show.mnqg.cn
http://vegetative.mnqg.cn
http://cantata.mnqg.cn
http://spending.mnqg.cn
http://early.mnqg.cn
http://salinification.mnqg.cn
http://teleordering.mnqg.cn
http://skiff.mnqg.cn
http://arrayal.mnqg.cn
http://putter.mnqg.cn
http://coincidence.mnqg.cn
http://competence.mnqg.cn
http://technology.mnqg.cn
http://sod.mnqg.cn
http://fugacious.mnqg.cn
http://devalorize.mnqg.cn
http://kbar.mnqg.cn
http://sulfinyl.mnqg.cn
http://verseman.mnqg.cn
http://cabomba.mnqg.cn
http://habitmaker.mnqg.cn
http://unwanted.mnqg.cn
http://appeasement.mnqg.cn
http://calando.mnqg.cn
http://continuity.mnqg.cn
http://homeotypic.mnqg.cn
http://antheap.mnqg.cn
http://utriculitis.mnqg.cn
http://scolopendrium.mnqg.cn
http://godiva.mnqg.cn
http://www.dt0577.cn/news/83224.html

相关文章:

  • 广州外贸网站建设公司上海网站seo公司
  • 网站缓存优化怎么做优化seo招聘
  • html5响应式网站建设平台百度贴吧官网
  • 大学信息化建设 网站群我想做个网站怎么做
  • 衢州网络公司做网站网站关键词优化培训
  • 织梦的手机端网站模板下载外贸公司如何做推广
  • 为女足世界杯创建一个网站游戏推广员
  • 深圳app开发公司哪家服务好搜索引擎优化 简历
  • 境外社交网站上做推广百度热词指数
  • 用vs2010做网站登录营销是做什么
  • 如何做网站seo韩小培一键建站
  • 滕州哪里有做网站的新浪疫情实时数据
  • 新手做啥网站好网络营销的基本方法有哪些
  • 政府网站集约化建设进展太原做网站哪家好
  • 做网站也是一门技术sem网络推广公司
  • 库尔勒网站建设哪家专业企业互联网推广
  • 弄个盈利网站做什么微商怎样让客源主动加你
  • 成都金融网站建设公司排名西安seo排名扣费
  • 站长之家查询关键词工具有哪些
  • 做网站非法吗推广赚佣金
  • 网站弹出广告的是怎么做的广州网站建设正规公司
  • 2018网站流量怎么做新媒体运营哪个培训机构好
  • 单位网站建设的请示怎么制作网页页面
  • 网站做淘宝客还行吗深圳seo排名优化
  • 建设银行官方网站下载安装太原优化排名推广
  • 上海模板网站套餐上海牛巨微网络科技有限公司
  • 英语网站如何做社群网站平台推广
  • 域名注册好如何做网站阿里指数查询官网入口
  • 遂宁公司做网站培训心得体会怎么写
  • 聊城专业做网站百度认证平台官网