0
A
回答
1
如果圖像始終這口井相連,你可以選擇基於其大小的組件。我在Python代碼(可能是一個更簡單的方法,但這是我如何做到這一點):
#get all connected components in the image with their stats (including their size, in pixel)
nb_edges, output, stats, _ = cv2.connectedComponentsWithStats(img, connectivity=8)
#output is an image where every component has a different value
size=stats[1:,-1] #extracting the size from the statistics
#selecting bigger components
for e in range(0,nb_edges-1):
#replace this line depending on your application, here I chose to keep
#all components above the mean size of components in the image
if size[e]>=np.mean(size):
th_up = e + 2
th_do = th_up
#masking to keep only the components which meet the condition
mask = cv2.inRange(output, th_do, th_up)
result = cv2.bitwise_xor(original_img, mask)
+0
謝謝!但是,您可以將其更改爲C++。 Python與opencv3有一些錯誤。而且我也不熟悉Python。對不起 –
+0
連接組件是最好的方式。 @BryanYU請不要期望人們爲你寫明確的代碼。有足夠的文檔可用於將Python轉換爲C++,反之亦然 –
+0
感謝您的建議。 –
相關問題
- 1. OpenCV - 從圖像中刪除「白色」僞影並擬合曲線
- 2. OpenCV的立體圖像C++
- 3. 用OpenCV刪除圖像的部分
- 4. Android中的背景圖像:每個獨立設備的獨立圖像?
- 5. OpenCV類型獨立圖像訪問的最佳方式?
- 6. 使用opencv刪除圖像邊框
- 7. 獨立的圖像名稱
- 8. 如何從圖像中刪除直線?
- 9. 使用OpenCV從邊緣圖像中刪除長長的水平/垂直線
- 10. 從圖像中刪除行
- 11. iPad獨立發佈圖像?
- 12. 獨立detailTextLabel由圖像
- 13. OpenCV的:刪除鋒利的線條
- 14. OpenCV的 - 去除圖像
- 15. 如何刪除圖像中的小平行線?
- 16. 使用opencv,如何刪除透明圖像中的非對象?
- 17. Opencv刪除/替換圖像中的自定義顏色
- 18. opencv - 刪除圖像中的所有黃色
- 19. 如何刪除opencv中包含文本的部分圖像
- 20. 如何刪除opencv中的二進制圖像噪聲?
- 21. 獨立於平臺的圖像java中的圖像
- 22. 堅持獨立CollectionType(添加/刪除)
- 23. 帶獨立線matplotlib的直方圖
- 24. 獨立駱駝路線,還是ActiveMQ內獨立的路線?
- 25. 使用opencv從圖像中刪除水平條紋
- 26. OpenCV從二進制圖像中刪除海灣
- 27. 用OpenCV從深度圖像中刪除白點
- 28. PyGame獨立的背景圖像
- 29. 獨立的圖像作爲在python
- 30. 如何從Silverlight 4.0中的獨立存儲中刪除目錄?
如何利用形態學操作來尋找結點,然後丟棄那些沒有結線? –