久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

圖像中土壤顆粒分水嶺以外的替代分割技術(shù)

Alternative segmentation techniques other than watershed for soil particles in images(圖像中土壤顆粒分水嶺以外的替代分割技術(shù))
本文介紹了圖像中土壤顆粒分水嶺以外的替代分割技術(shù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在尋找一種替代方法來分割以下土壤顆粒圖像中的顆粒,而不是 python 中的分水嶺分割,因為它可能會誤導(dǎo)對顆粒的正確檢測此外,我正在研究邊緣檢測圖像(使用 HED算法)如附件..我希望找到一種更好的方法來分割顆粒以進行進一步處理,因為我想在我的項目中獲得圖像中每個多邊形的面積..提前致謝我也在詢問隨機游走器分割或任何其他可用方法.

解決方案

您可以嘗試使用已實現(xiàn)為 Stats 的 Connected Components

每個對象的質(zhì)心可以在centroid參數(shù)中找到,面積等其他信息可以在cv2.connectedComponentsWithStats返回的status變量中找到/代碼>.這是標(biāo)有每個多邊形面積的圖像.您可以使用最小閾值區(qū)域進行過濾以僅保留較大的多邊形

代碼

導(dǎo)入 cv2將 numpy 導(dǎo)入為 np# 加載圖片,高斯模糊,灰度,Otsu的閾值圖像 = cv2.imread('2.jpg')模糊 = cv2.GaussianBlur(圖像, (3,3), 0)灰色 = cv2.cvtColor(模糊,cv2.COLOR_BGR2GRAY)thresh = cv2.threshold(灰色, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]# 執(zhí)行連通分量標(biāo)注n_labels,標(biāo)簽,統(tǒng)計,質(zhì)心 = cv2.connectedComponentsWithStats(閾值,連接 = 4)# 創(chuàng)建假彩色圖像和背景顏色為黑色顏色 = np.random.randint(0, 255, size=(n_labels, 3), dtype=np.uint8)colors[0] = [0, 0, 0] # 出于美觀的原因,我們希望背景為黑色false_colors = 顏色[標(biāo)簽]# 每個多邊形的標(biāo)注區(qū)域false_colors_area = false_colors.copy()對于 i,枚舉中的質(zhì)心(質(zhì)心 [1:],開始 = 1):面積 = 統(tǒng)計[i, 4]cv2.putText(false_colors_area, str(area), (int(centroid[0]), int(centroid[1])), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1)cv2.imshow('thresh', thresh)cv2.imshow('false_colors', false_colors)cv2.imshow('false_colors_area', false_colors_area)cv2.waitKey()

I am searching for an alternative way for segmenting the grains in the following image of soil grains other than watershed segmentation in python as it may mislead the right detection for the grains furthermore , I am working on the edge detection image ( using HED algorithm ) as attached .. I hope to find a better way to segment the grains for further processing as I would like to get the area of each polygon in the image in my project .. Thanks in advance I am asking also about random walker segmentation or any other available method.

解決方案

You could try using Connected Components with Stats already implemented as cv2.connectedComponentsWithStats to perform component labeling. Using your binary image as input, here's the false-color image:

The centroid of each object can be found in centroid parameter and other information such as area can be found in the status variable returned from cv2.connectedComponentsWithStats. Here's the image labeled with the area of each polygon. You could filter using a minimum threshold area to only keep larger polygons

Code

import cv2
import numpy as np

# Load image, Gaussian blur, grayscale, Otsu's threshold
image = cv2.imread('2.jpg')
blur = cv2.GaussianBlur(image, (3,3), 0)
gray = cv2.cvtColor(blur, cv2.COLOR_BGR2GRAY)
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1]

# Perform connected component labeling
n_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(thresh, connectivity=4)

# Create false color image and color background black
colors = np.random.randint(0, 255, size=(n_labels, 3), dtype=np.uint8)
colors[0] = [0, 0, 0]  # for cosmetic reason we want the background black
false_colors = colors[labels]

# Label area of each polygon
false_colors_area = false_colors.copy()
for i, centroid in enumerate(centroids[1:], start=1):
    area = stats[i, 4]
    cv2.putText(false_colors_area, str(area), (int(centroid[0]), int(centroid[1])), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,255), 1)

cv2.imshow('thresh', thresh)
cv2.imshow('false_colors', false_colors)
cv2.imshow('false_colors_area', false_colors_area)
cv2.waitKey()

這篇關(guān)于圖像中土壤顆粒分水嶺以外的替代分割技術(shù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 欧美一级黄色片在线观看 | 久久综合一区 | 正在播放一区二区 | 国产免费拔擦拔擦8x高清 | 91一区二区 | 国产精品久久二区 | 亚洲欧美综合 | 久久99精品久久久久久国产越南 | 成人老司机 | 日韩中文字幕在线免费 | 久久精品成人热国产成 | 少妇一级淫片免费播放 | 色天天综合| www.亚洲视频 | 免费看国产一级特黄aaaa大片 | 午夜电影福利 | 欧美综合一区二区 | 午夜小电影 | 日韩免费中文字幕 | 一区二区免费 | 午夜激情一区 | 精品久久久久久久久久久下田 | 成人在线观看网站 | 亚洲欧美男人天堂 | 亚洲欧美久久 | 天天操天天射综合网 | 久久精品69| 日日夜夜91 | 欧美一区二区三区在线观看视频 | 蜜桃免费一区二区三区 | 人人亚洲| 亚洲一区二区三区免费 | 欧美激情黄色 | 免费网站在线 | 欧美日韩国产一区二区三区不卡 | 亚洲午夜视频在线观看 | 国产精品色综合 | 亚洲欧美在线一区 | 欧美激情精品久久久久久 | 91麻豆精品国产91久久久更新资源速度超快 | 欧美综合网 |