簡體   English   中英

圖像輪廓強度

[英]Image profile intensity

為什么我正在處理的圖像的強度分布不包括右端? 我應該看到 7 個“高峰”,但我沒有。

下面是我的代碼:

from matplotlib import pyplot as plt
from skimage.measure import profile_line
from skimage.io import imread

start = (0, 714) #Start of the profile line
end = (100, 100) #End of the profile line

#image = imread('....tif') #Read the images
profile = profile_line(image, start, end, linewidth=1, mode='constant') #Take the profile line
fig, ax = plt.subplots(2, 1, figsize=(10, 10)) #Create the figures
ax[0].imshow(image) #Show the film at the top
ax[0].plot(start, end, 'r-', lw=2) #Plot a red line across the film
ax[1].plot(profile)
ax[1].grid()

結果圖:

在此處輸入圖像描述

我正在處理的電影:

電影

你在這里混淆了一堆不同的概念。 一方面,您的可視化是錯誤的。 skimage.measure.profile_line接受(row, col)坐標中的兩個點。 matplotlib.pyplot.plot接受兩個數據集,一個x和一個y 通過將start繪制為x並將end繪制為y ,您會混淆自己,相信您擁有的線是水平的。 讓我們正確地獲取profile_line從中切割的x坐標(列)和 plot 它們,對於y坐標(行)也是如此:

start = (0, 714) #Start of the profile line
end = (100, 100) #End of the profile line
image = skimage.io.imread(...)

fig, ax = plt.subplots(1, 2)
ax[0].set_title('Wrong')
ax[0].imshow(image)
ax[0].plot(start, end, 'r')
ax[1].set_title('Correct')
ax[1].imshow(image)
ax[1].plot([start[1], end[1]], [start[0], end[0]], 'r')

結果如下:

在此處輸入圖像描述

希望您看到標有“正確”的圖像准確地顯示了您在 plot 中看到的內容。

您可以輕松地糾正這一點。 首先,讓我們以復雜的方式來做:使用profile_line 您希望開始和結束 y 坐標相同,並且開始和結束 x 坐標跨越圖像。 請記住profile_line在兩端都包含:

image = skimage.io.imread(...)

start = (100, 0) #Start of the profile line row=100, col=0
end = (100, image.shape[1] - 1) #End of the profile line row=100, col=last

profile = skimage.measure.profile_line(image, start, end)

fig, ax = plt.subplots(1, 2)
ax[0].set_title('Image')
ax[0].imshow(image)
ax[0].plot([start[1], end[1]], [start[0], end[0]], 'r')
ax[1].set_title('Profile')
ax[1].plot(profile)

在此處輸入圖像描述

這看起來好多了。 對於垂直和水平橫截面,您可以使用簡單的索引獲得相同的結果。 skimage.io.imread加載的圖像是numpy arrays ,所以你可以這樣做:

profile = image[100, :]

對於一條垂直線,比如在第 202 列,您沿着第二個(列)軸進行索引:

profile = image[:, 202]

暫無
暫無

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

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