没有合适的资源?快使用搜索试试~ 我知道了~
线的骨架提取
需积分: 12 8 下载量 117 浏览量
2013-12-05
10:06:45
上传
评论 1
收藏 2KB TXT 举报
温馨提示
试读
2页
Image,Matrix,CvInvoke
资源推荐
资源详情
资源评论
private string imgPath;
private RectLatLng bound;
private Matrix<float> pDst;
private Point curPt;
public LineRecognize(string imgPath, RectLatLng bound)
{
curPt = new Point(0, 0);
try
{
this.imgPath = imgPath;
this.bound = bound;
Image<Bgr, Byte> img = new Image<Bgr, Byte>(imgPath);
// 提取线的目标图像
Image<Gray, Byte> dstImg = new Image<Gray, Byte>(img.Width, img.Height);
// 生成灰度图
Image<Gray, Byte> gray = img.Convert<Gray, Byte>();
// 二值化(翻转像素)
Image<Gray, Byte> binary = gray.ThresholdBinaryInv(new Gray(230), new Gray(255));
Matrix<float> pSrc = new Matrix<float>(binary.Rows, binary.Cols);
pDst = new Matrix<float>(binary.Rows, binary.Cols);
// 细化
CvInvoke.cvConvertScale(binary, pSrc, 1.0f, 0);
MorphologicalThinning(pSrc, pDst);
CvInvoke.cvConvertScale(pDst, dstImg, 256.0f, 0);
// 保存
dstImg.Bitmap.Save(imgPath + ".edge.png");
private RectLatLng bound;
private Matrix<float> pDst;
private Point curPt;
public LineRecognize(string imgPath, RectLatLng bound)
{
curPt = new Point(0, 0);
try
{
this.imgPath = imgPath;
this.bound = bound;
Image<Bgr, Byte> img = new Image<Bgr, Byte>(imgPath);
// 提取线的目标图像
Image<Gray, Byte> dstImg = new Image<Gray, Byte>(img.Width, img.Height);
// 生成灰度图
Image<Gray, Byte> gray = img.Convert<Gray, Byte>();
// 二值化(翻转像素)
Image<Gray, Byte> binary = gray.ThresholdBinaryInv(new Gray(230), new Gray(255));
Matrix<float> pSrc = new Matrix<float>(binary.Rows, binary.Cols);
pDst = new Matrix<float>(binary.Rows, binary.Cols);
// 细化
CvInvoke.cvConvertScale(binary, pSrc, 1.0f, 0);
MorphologicalThinning(pSrc, pDst);
CvInvoke.cvConvertScale(pDst, dstImg, 256.0f, 0);
// 保存
dstImg.Bitmap.Save(imgPath + ".edge.png");
资源评论
明知我做错的总要奉还
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功