今天就跟大家聊聊有關利用Python+OpenCV圖像處理功能實現輪廓發現,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
代碼如下:
import cv2 as cv import numpy as np def contours_demo(image): dst = cv.GaussianBlur(image, (3, 3), 0) #高斯模糊去噪 gray = cv.cvtColor(dst, cv.COLOR_RGB2GRAY) ret, binary = cv.threshold(gray, 0, 255, cv.THRESH_BINARY | cv.THRESH_OTSU) #用大律法、全局自適應閾值方法進行圖像二值化 cv.imshow("binary image", binary) cloneTmage, contours, heriachy = cv.findContours(binary, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE) for i, contour in enumerate(contours): cv.drawContours(image, contours, i, (0, 0, 255), 2) print(i) cv.imshow("contours", image) for i, contour in enumerate(contours): cv.drawContours(image, contours, i, (0, 0, 255), -1) cv.imshow("pcontours", image) src = cv.imread('E:/imageload/coins.jpg') cv.namedWindow('input_image', cv.WINDOW_NORMAL) #設置為WINDOW_NORMAL可以任意縮放 cv.imshow('input_image', src) contours_demo(src) cv.waitKey(0) cv.destroyAllWindows()
網頁標題:利用Python+OpenCV圖像處理功能實現輪廓發現-創新互聯
URL網址:http://vcdvsql.cn/article8/ddgeop.html
成都網站建設公司_創新互聯,為您提供網頁設計公司、網站改版、網站收錄、手機網站建設、網站導航、網站建設
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯