05网站,本地找工作求职用哪个软件好,二维码生成器在线,通过高权重网站做长尾关键词目录 图像的轮廓查找轮廓绘制轮廓 轮廓的特征轮廓面积轮廓周长轮廓近似凸包边界矩形最小外接圆椭圆拟合直线拟合 图像的矩特征矩的概念图像中的矩特征 图像的轮廓 查找轮廓
binary,contours,hierarchycv.findContours(img,mode,method)绘制轮廓
cv.drawContours(img,coutours… 目录 图像的轮廓查找轮廓绘制轮廓 轮廓的特征轮廓面积轮廓周长轮廓近似凸包边界矩形最小外接圆椭圆拟合直线拟合 图像的矩特征矩的概念图像中的矩特征 图像的轮廓 查找轮廓
binary,contours,hierarchycv.findContours(img,mode,method)绘制轮廓
cv.drawContours(img,coutours,index,color,width)import numpy as np
import cv2 as cv
import matplotlib.pyplot as pltimg cv2.imread(./汪学长的随堂资料/4/图像操作/contours.png)
img_gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cannycv.Canny(img_gray,127,255,0)
contours,hicv.findContours(canny,cv.RETR_TREE,cv.CHAIN_APPROX_SIMPLE)
imgcv.drawContours(img,contours,-1,(0,0,255),2)
plt.imshow(img[:,:,::-1])轮廓的特征 轮廓面积
areacv.contourArea(cnt)轮廓周长
perimetercv.arcLength(cnt,isclosed)轮廓近似 approxcv.approxPolyDP(cnt,epsilon,isclosed)img cv2.imread(./汪学长的随堂资料/4/图像操作/contours2.png)img_gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
ret, thresh cv2.threshold(img_gray, 127, 255, 0)
contours, hierarchy cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)
cntcontours[0]
areacv.contourArea(cnt)
lengthcv.arcLength(cnt,True)
esplion0.1*length
approxcv.approxPolyDP(cnt,esplion,True)
imgcv.polylines(img,[approx],True,(0,0,255),2)
plt.imshow(img[:,:,::-1])凸包 hullcv.convexHull(points,clockwise,returnPoints)imgcv.imread(./image/star 2.jpeg)
img1img.copy()
imggraycv.cvtColor(img,cv.COLOR_BGR2GRAY)
cannycv.canny(imggray,127,255,0)
contours,hicv.findContours(canny,cv.RETR_TREE,cv.CHAIN_APPROX_SIMPLE)
hulls[]
for cnt in contours:hullcv.convexHull(cnt)hulls.append(hull)
img1cv.drawContours(img1,hulls,-1,(0,255,0),2)
plt.imshow(img1[:,:,::-1])边界矩形 imgcv.imread(./image/arrows,jpg)
img_graycv.cvtColor(img,cv.COLOR_BGR2GRAY)
ret,threshcv.threshold(img_gray,127,255,0)
contours,hicv.findContours(thresh,1,2)
cntcontours[1]
x,y,w,hcv.boundingRect(cnt)
imgRectcv.rectangle(img,(x,y),(xw,yh),(0,255,0),3)
plt.imshow(imgRect[:,:,::-1])scv.minAreaRect(cnt)
acv.boxPoints(s)
anp.int0(a)
cv.polylines(imgRect,[a],True,(0,0,255),3)
plt.imshow(imgRect[:,:,::-1])最小外接圆 (x,y),rcv.minEnclosingCircle(cnt)
center(int(x),int(y))
rint(r)
imgcirclecv.circle(img,center,r,(0,255,0),3)
plt.imshow(imgcircle[:,:,::-1])椭圆拟合 ellipsecv.fitEllipse(cnt)
imgellipsecv.ellipse(img,ellipse,(0,255,255,3))
plt.imshow(imgellipse[:,:,::-1])直线拟合 outputcv.fitLine(points,distType,param,aeps)[vx,vy,x,y]cv.fitLine(cnt,cv.DIST_L2,0,0.01,0.01)
rows,colsimg.shape[:2]
leftyint((-x*vy/vx)y)
rightyint(((cols-x)*vy/vx)y)
imglinecv.line(img,(0,lefty),(cols-1,righty),(0,0,255),3)
plt.imshow(imgline[:,:,::-1])图像的矩特征 矩的概念 图像中的矩特征 moments(array,binaryImageFalse)imgcv.imread(./image/arrows.jpg,0)
imgmncv.moments(img)
imghucv.HuMoments(imgmn)
ret,threshcv.threshold(img,127,255,0)
contours,hicv.findContours(thresh,1,2)
cntcontours[1]
mncv.moments(cnt)
hucv.HuMoments(mn)