我有一张超声图像和每个图像的肿瘤坐标(x 和 y 点的阵列)。如何使用“cv.drawContours()”用那些已知的坐标在肿瘤周围绘制轮廓?我希望删除肿瘤周围的所有信息,只保留肿瘤图像/信息。
temp=np.array([[284., 60.],[276., 59.],[269., 58.],[260., 58.],[247., 60.],[241., 65.],[237., 68.],[233., 72.],[228., 80.],[225., 87.],[225., 96.],[229., 107.],[233., 109.],[238., 110.],[244., 111.],[253., 112.],[260., 113.],[267., 115.],[273., 116.],[290., 115.],[298., 113.],[306., 110.],[313., 109.],[323., 108.],[330., 102.],[330., 100.],[335., 96.],[338., 94.],[344., 91.],[346., 86.],[346., 82.],[346., 77.],[346., 73.],[341., 70.],[337., 68.],[327., 64.],[322., 63.],[314., 62.],[305., 62.],[300., 61.],[293., 60.],[289., 60.],[284., 60.]])
imagem = cv2.imread('thyroid/2_1.jpg', cv2.IMREAD_GRAYSCALE)
cc=cv2.drawContours(imagem,temp,3,(0,255,0),3)
我收到此错误:
error Traceback (most recent call last) <ipython-input-25-59da73cb5b29> in <module> 2 imagem = cv2.imread('thyroid/2_1.jpg', cv2.IMREAD_GRAYSCALE) 3 ----> 4 cc=cv2.drawContours(imagem,temp,3,(0,255,0),3) error: OpenCV(3.4.1) C:\Miniconda3\conda-bld\opencv-suite_1533128839831\work\modules\imgproc\src\drawing.cpp:2515: error: (-215) npoints > 0 in function cv::drawContours
如何解决此错误?因为我的轮廓是一个列表
img = cv2.imread('thyroid/2_1.jpg', cv2.IMREAD_GRAYSCALE)
temp=temp.astype(np.int32)
cc=cv2.drawContours(img,[temp.astype('i4')],-1,(0,255,0),3)