【问题标题】:extract intensity profile along a line from image从图像中提取沿线的强度分布
【发布时间】:2022-06-11 04:49:58
【问题描述】:

我有一个 numpy 数组,其中包含一些图像数据 (ch4_out)。现在,我想沿特定线(水平)提取强度分布。我正在使用 skimage 模块中的profile_line 函数来执行此操作,但出现错误。我正在寻求一些帮助来解决我的代码。

显示的错误是

order = _validate_interpolation_order(image.dtype, order)

# reading multiple images 
S01=[i for i in 
glob.glob("C:/Users/experiment/S01/*.tif")]

# Averaging images
ch4=np.array([np.array(Image.open(fname)) for fname in
S01])
ch4_avg=np.array(np.mean(ch4,axis=(0)),dtype=np.uint16)
ch4_out=Image.fromarray(ch4_avg) # image data as numpy array

#plotting figure
plt.figure()
plt.subplot(1,2,1)
plt.imshow(ch4_out,cmap='gray',interpolation='none') 
#code works fine until this point

#Now, extract intensity profile at pixel along horizontal line x (2 to 1000) at a height in vertical direction of 730 
pixels

p = profile_line(ch4_out, (2, 1000), (730, 730)) 
# coordinates for horizontal (2,1000) and vertical 
(730,730))
plt.imshow(p)
plt.show()

【问题讨论】:

  • 哪一行面临错误?
  • 在线p= profile_line(ch4_out,(),())。基本上,该代码适用于 .jpg 或 .png 或其他图像格式,但不适用于将图像数据作为数组的 numpy 数组(Ch4_out 是一个 numpy 数组),我更喜欢使用诸如 profile_line 之类的函数作为数组.
  • 基于the documentation,排序很重要。这也是错误中提到的内容。你的数组是如何排序的?可以分享示例图片吗?
  • 我已经编辑了帖子,示例图像名为 ch4_out 附加到问题中。
  • 阵列的形状对她很重要@vashista。在ch4=np.array([np.array(Image.open(fname)) for fname in S01]) 行中,您正在形成一个数组数组,这会改变所需的输入形状

标签: python arrays numpy image-processing scikit-image


猜你喜欢
  • 1970-01-01
  • 2017-12-14
  • 2016-07-02
  • 2018-10-30
  • 2013-06-17
  • 1970-01-01
  • 2019-05-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多