【发布时间】:2020-06-16 19:40:48
【问题描述】:
我正在尝试使用测量配置文件来检测一系列管中的荧光,因此我编写了以下代码
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage
from skimage.measure import profile_line
import os
import argparse
import string
from PIL import Image
plt.rcParams['font.size']=16
plt.rcParams['font.family'] = 'sans-serif'
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())
imagen = Image.open(args["image"])
imagename=args["image"]
img = np.array(imagen)
#profile position
start=(0,35)
end=(1300,35)
#profile_line
profile = profile_line(img,start,end, linewidth=5)
fig, ax = plt.subplots(2,1,figsize=(15,9))
ax[0].imshow(imagen, cmap=plt.cm.gist_earth, interpolation='gaussian',origin='lower',alpha=1)
ax[0].plot([start[0],end[0]],[start[1],end[1]],'r-',lw=3)
ax[1].plot(profile)
ax[1].set_title('data points = '+str(profile.shape[0])+'')
plt.tight_layout()
plt.savefig("scipy.jpg")
但我得到了
【问题讨论】:
-
请分享您使用的图像 - 不是它的情节,而是您在
Image.open()中使用的实际图像。谢谢。 -
尝试将您的
x,y坐标换成profile_line()...35,0和35,1300 -
上帝保佑你或布达,或任何人......非常感谢
标签: python scipy scikit-image