簡體   English   中英

有什么方法可以選擇由線條圖像形成的直方圖的正確峰值嗎?

[英]Is there any way to select the correct peaks of a histogram formed from an image of lines?

我有一些代碼可以使圖像直方圖。 我目前正在使用scipy方法find_peaks來查找峰,但它也在檢測一些冗余值。 這是我正在使用的代碼:

from scipy.signal import find_peaks
...
hist = cv2.reduce(threshed,1, cv2.REDUCE_AVG).reshape(-1)
peaks, _ = find_peaks(hist)
plt.figure(figsize=(20,20))

plt.plot(hist)
plt.plot(peaks, hist[peaks], "x")
plt.show()
...

這是帶有Peaks的輸出Histplot:

輸出

假設我只希望這些值大於20,但由於每個圖像的限制都不同,因此無法對其進行硬編碼。

嘗試使用prominence = 30並成功。 消除噪音並獲得良好的效果。

peaks, _ = find_peaks(hist,prominence=30)

需要調整“突出度”和“距離”度量以獲取列表中的最佳峰值。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM