には、次の点について助けが必要です。私は30分間隔でキャプチャされた3つの静止したオブジェクト画像を持っています。私はカメラと物体を所定の位置に固定し、部屋は暗くなっていましたが、まだ3つの異なる露出/明るさ/ガンマ画像で終わり、オブジェクトも少し動いています。私がやろうとした何 Image1 Image2イメージアライメントの前に明るさ/コントラスト補正を先に行うか、その逆にするか?
第一の画像を参考に合わせ、明るさ/ガンマ/コントラストの2番目と3番目の画像を調整することです。私は以下のECCtransformメソッドを使用してイメージを整列する方法について解答しています:
import os, sys
import cv2
from PIL import Image
import numpy as np
path = "C:\\Users\\xxxx\\Desktop\\"
path1 = "C:\\Users\\xxxx\\Desktop\\aligned\\"
def alignment():
for i in range(1,4):
# Read the images to be aligned
im1 = cv2.imread(path + '1.png')
im2 = cv2.imread(path + '%d.png' %(i))
print(i)
# Convert images to grayscale
im1_gray = cv2.cvtColor(im1,cv2.COLOR_BGR2GRAY)
im2_gray = cv2.cvtColor(im2,cv2.COLOR_BGR2GRAY)
# Find size of image1
sz = im1.shape
# Define the motion model
warp_mode = cv2.MOTION_TRANSLATION
# Define 2x3 or 3x3 matrices and initialize the matrix to identity
if warp_mode == cv2.MOTION_HOMOGRAPHY :
warp_matrix = np.eye(3, 3, dtype=np.float32)
else :
warp_matrix = np.eye(2, 3, dtype=np.float32)
# Specify the number of iterations.
number_of_iterations = 5000;
# Specify the threshold of the increment
# in the correlation coefficient between two iterations
termination_eps = 1e-10;
# Define termination criteria
criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, number_of_iterations, termination_eps)
# Run the ECC algorithm. The results are stored in warp_matrix.
(cc, warp_matrix) = cv2.findTransformECC(im1_gray, im2_gray, warp_matrix, warp_mode, criteria)
if warp_mode == cv2.MOTION_HOMOGRAPHY :
# Use warpPerspective for Homography
im2_aligned = cv2.warpPerspective (im2, warp_matrix, (sz[1],sz[0]), flags=cv2.INTER_LINEAR + cv2.WARP_INVERSE_MAP)
else :
# Use warpAffine for Translation, Euclidean and Affine
im2_aligned = cv2.warpAffine(im2, warp_matrix, (sz[1],sz[0]), flags=cv2.INTER_LINEAR + cv2.WARP_INVERSE_MAP);
cv2.imwrite(path1 + "%d.png" % (i), im2_aligned)
alignment()
私の質問は、どの方面に向いていますか?シーケンスは重要ですか? 最初の画像を基準にして:
画像の明るさ/露出を正確に調整できるように変換ECC画像のアライメントを先に実行する必要がありますか?
OR
私は正確に写真を整列するように私が最初に明るさ/露出を調整する必要がありますか?
私はまだ第1の画像を参照して第2および第3の画像の明るさ/露出を調整する方法を考えています。どんなアイデアも歓迎され、感謝しています!!
https://i.stack.imgur.com/Xe2Fk.jpg << 3番目の画像 – SacreD