xiongyihui / notes

Notes
https://xiongyihui.github.io/notes/
3 stars 0 forks source link

频响曲线中提取数据 #34

Open xiongyihui opened 1 year ago

xiongyihui commented 1 year ago

尝试从频响曲线中提取原始数据

4731681199008_ pic

import numpy as np
import matplotlib.pyplot as plt

img = plt.imread('fr.png')

margin = 80     # 左、下边距,把文字滤除

# 用图片的第一个通道,取区域最大值y轴坐标
b = -np.argmin(img[:-margin, margin:, 0], axis=0)

# 查找左右边框的x轴坐标
r1, r2 = np.argmin(b[:100]), np.argmin(b)
print(r1, r2)
c = b[r1:r2]
print(list(c))

plt.subplot(2, 1, 1)
plt.plot(b)
plt.subplot(2, 1, 2)
plt.plot(c)
plt.show()

top = 127
bottom = 88
c_min = np.min(c)
c_max = np.max(c)
d = (c - c_min) / (c_max - c_min) * (top - bottom) + bottom
print(list(d))

plt.plot(d)
plt.show()

image

image