skimage profile_line 没有意义
skimage profile_line does not make sense
我正在尝试使用测量配置文件来检测一系列管中的荧光,因此我编写了以下代码
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")
但是我得到了
原图是
有什么建议么 ?它在 x 轴上落在 100 处...
按照@MarkSetchell 告诉我交换 x 和 y 问题解决了
我需要在次要方向上做一些工作,但看起来很不错的解决方案
PS:重做了
import matplotlib
matplotlib.use("Agg")
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']=6
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)
start=(35,0)
end=(35,1300)
profile = profile_line(img,start,end, linewidth=2)
fig, ax = plt.subplots(2,1)
major_ticks = np.arange(0,1350,50)
fig.subplots_adjust(hspace=0,wspace=0)
ax[1].imshow(imagen, cmap=plt.cm.gist_earth, interpolation='gaussian',origin='lower',alpha=1)
ax[1].plot([start[1],end[1]],[start[0],end[0]],'r-',lw=2)
ax[1].set_xticks(major_ticks)
ax[1].grid(color="black", linewidth=0.2)
ax[1].grid(True)
ax[0].plot(profile)
ax[0].set_title('data points = '+str(profile.shape[0])+'')
ax[0].set_xticks(major_ticks)
ax[0].grid(color="black", linewidth=0.2)
ax[0].grid(True)
我正在尝试使用测量配置文件来检测一系列管中的荧光,因此我编写了以下代码
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")
但是我得到了
原图是
按照@MarkSetchell 告诉我交换 x 和 y 问题解决了
我需要在次要方向上做一些工作,但看起来很不错的解决方案
PS:重做了
import matplotlib
matplotlib.use("Agg")
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']=6
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)
start=(35,0)
end=(35,1300)
profile = profile_line(img,start,end, linewidth=2)
fig, ax = plt.subplots(2,1)
major_ticks = np.arange(0,1350,50)
fig.subplots_adjust(hspace=0,wspace=0)
ax[1].imshow(imagen, cmap=plt.cm.gist_earth, interpolation='gaussian',origin='lower',alpha=1)
ax[1].plot([start[1],end[1]],[start[0],end[0]],'r-',lw=2)
ax[1].set_xticks(major_ticks)
ax[1].grid(color="black", linewidth=0.2)
ax[1].grid(True)
ax[0].plot(profile)
ax[0].set_title('data points = '+str(profile.shape[0])+'')
ax[0].set_xticks(major_ticks)
ax[0].grid(color="black", linewidth=0.2)
ax[0].grid(True)