mahotas绘图函数
发布日期:2021-06-29 14:44:27 浏览次数:3 分类:技术文章

本文共 1975 字,大约阅读时间需要 6 分钟。

1.函数mahotas.polygon.line((y0, x0), (y1, x1), canvas, color=1)# 画一条线参数:p0 : 一对整数-第一点p1 : 一对整数第二点canvas : ndarray在要显示的图像上绘制color : integer, optional绘图颜色===============================================================================mahotas.polygon.fill_polygon([(y0, x0), (y1, x1), ..., ]canvas, color=1)# 在画布上绘制一个填充的多边形参数:polygon : list of pairs-a list of (y,x) pointscanvas : ndarray在要显示的图像上绘制color : integer, optional绘图颜色===============================================================================mahotas.polygon.convexhull(bwimg)# 将凸包计算为多边形参数:bwimg : ndarray输入图像(解释为布尔值)仅支持2D阵列返回值:	hull : ndarray凸包外轮廓点(y,x)坐标集===============================================================================mahotas.polygon.fill_convexhull(bwimg)# 计算凸包并将其作为二进制掩码返回参数:bwimage : 输入图像(解释为布尔值)必须为int or bool类型返回值:将凸包作为二进制图像返回hull : 与bwimg具有相同大小和dtype的图像,并填充了船体
2.实例:import mahotas as mh,numpy as npfrom matplotlib import pyplot as pltimport cv2girl=r'C:\Users\Administrator\Desktop\Fastener\Resources\Pictures\tubao.jpg'image=mh.imread(girl,1)image=255-imageimg=np.zeros(image.shape,np.uint8)x0,y0,x1,y1=100,100,200,200mh.polygon.line((y0, x0), (y1, x1), image, color=125)# 画一条线x0,y0=400,100x1,y1=400,300x2,y2=500,100x3,y3=500,300# mh.polygon.fill_polygon([(y0, x0), (y1, x1),(y2, x2), (y3, x3) ],canvas, color=125)#画填充多边形binary1=mh.polygon.convexhull(image)#获取凸包外轮廓点binary2=mh.polygon.fill_convexhull(image.astype('uint8'))##获取凸包外轮廓图像 -有些不正常,上面的是白色的?mh.polygon.fill_polygon(binary1,img, color=125)#画填充多边形cv2.imshow('s1',image)cv2.imshow('s2',img)cv2.imshow('s3',binary2.astype('uint8'))cv2.waitKey()print(binary1)"""[[ 56 142] [ 66 200][ 72 223][ 96 301][ 97 303][112 319][258 359][294 359][319 335][423 206][447 175][447 161][423  48][415  46][199  32][ 81  32][ 72  40][ 64  64][ 56 121]]"""print(binary2)"""[[255 255 255 ... 255 255 255] [255 255 255 ... 255 255 255][255 255 255 ... 255 255 255]...[  0   0   0 ...   0   0   0][  0   0   0 ...   0   0   0][  0   0   0 ...   0   0   0]]"""

 

转载地址:https://chunyou.blog.csdn.net/article/details/106294329 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:mahotas标记图像Labeled Image
下一篇:mahotas 距离变换Distance Transform -结合分水岭进行图像分割

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月18日 19时33分13秒