1
我有一个Image从相机(我的VW T5范的内部)获得。我想知道如何准确地重现形状。我使用lensfun和gimp纠正镜头变形。我想通过利用矩形特征来量化剩余的扭曲。我可以使用match_template
检测矩形,但我不知道如何检测矩形。在图像中找到矩形,最好与滑雪图像
最后我想标记它们并测量宽度和长度。为了更好地显示中心,我试图找到这些中心,但这并不像我想象的那么简单,因为一个简单的阈值可以多次计算相同的点。我如何找到所有检测到的矩形的中心?
这可以通过skimage完成吗?或者我应该使用opencv?
import numpy as np
import matplotlib.pyplot as plt
from scipy import ndimage as ndi
from scipy.ndimage.filters import maximum_filter
from scipy.ndimage import center_of_mass
from skimage.color import rgb2grey
from skimage.feature import match_template
from skimage import feature, io
from skimage import img_as_float
%matplotlib inline
image = io.imread('../lensfun_cut.JPG')
imgray = rgb2grey(image)
template = imgray[1365:1390,445:470]
result = match_template(imgray, template)
#
hit = np.where(result>0.90)
fig, ax = plt.subplots(ncols=1,figsize=(8,8))
ax.imshow(result,cmap=plt.cm.spectral)
# loop over the detected regions and draw a circe around them
for i in range(len(hit[0])):
rect = plt.Circle((hit[1][i],hit[0][i]), 20,linewidth=1, edgecolor='r', facecolor='none')
ax.add_patch(rect)
有趣的解决方案。特别是删除边框的方法。我会试一试。你认为像索贝尔这样的方法可能会引入更少的噪音吗? – Moritz
我可能不会尝试去除图像预处理中的噪点,但要等待轮廓等级。你的矩形具有几乎完美的形状,但非常小,每个预处理都有形状恶化的危险。但是,从其他斑点选择矩形形状类型时,形状将是您的选择,我认为您可以通过简单地使用上面显示的轮廓特征来完成此操作,尽管您可能必须稍微使用一些参数。我选择的下一个方法是检测矩形网格并仅在网格十字的位置查找斑点。 – tfv