簡體   English   中英

重新縮放單應性/圖像變形

[英]Rescaling Homographys / Image warping

我基於scikit圖像構建全景圖代碼。 它的標准,就像

1)加載和灰度圖像

2)ORB檢測與匹配

3)RANSAC單應性搜索(產生3x3矩陣)

4)變形和縫合圖像

這與我的圖像配合得很好。 但是,要使其在可接受的時間內工作,我必須縮小圖像以使用ORB。 然后將導出的變換應用於縮小后的圖像會產生良好的效果,但是將其應用於非縮小后的圖像則行不通。

供參考:縮放是通過skimage.transform.rescale以一個恆定的縮放比例完成的,轉換是skimage.transform.ProjectiveTransform類,而變形是通過skimage.transform.warp完成的

Q1)在我的理解中,單應性僅按比例定義。 那么,為什么不能以不同的比例使用它們(如果在圖像中心進行了切片)

Q2)有沒有辦法簡單地縮放我的單應性?

在將單應性H應用於單應性矢量p = [xyz] ,所得矢量Hp = [x' y' z']代表二維矢量[x'/z' y'/z'] 這樣,對單應矩陣的任何縮放(例如kH )都可以得到kHp = [kx' ky' kz']或2D等效項[x'/z' y'/z'] kHp = [kx' ky' kz'] [x'/z' y'/z'] ,與之前相同。

在您描述的場景中,您想要的是重新縮放變換,以便即使在按比例縮小的坐標上估計了單應性的情況下,也可以將其應用於原始圖像坐標。

因此,您可以執行以下操作:

from skimage import transform as tf
import numpy as np

# Set up a fake homography as illustration
# This homography is estimated on the scaled down image,
# but we'd 
estimated_tf = tf.ProjectiveTransform(np.arange(9).reshape((3, 3))/10)
print('Estimated:\n', estimated_tf.params)

S_down = tf.SimilarityTransform(scale=0.5)
S_up = tf.SimilarityTransform(scale=2)

full_tf = S_down + estimated_tf + S_up

print('On scaled down coordinates:', estimated_tf([1, 2]))
print('On full coordinates:', full_tf([2, 4]))

哪個產量

Estimated: [[ 0. 0.1 0.2] [ 0.3 0.4 0.5] [ 0.6 0.7 0.8]] On scaled down coordinates: [[ 0.14285714 0.57142857]] On full coordinates: [[ 0.28571429 1.14285714]]

暫無
暫無

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

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