我正在做一个合并多个图像的项目,类似于iOS中的HDR。我已经成功地通过相机获得了3张不同曝光的图像,现在我想对齐它们,因为在拍摄过程中,一个人的手必须摇动,导致所有3幅图像的排列略有不同。
我已经导入了OpenCV框架,并且一直在探索OpenCV中的函数来对齐/注册图像,但是什么也没有发现。实际上,OpenCV中有一个函数可以实现这一点吗?如果没有,还有其他选择吗?
谢谢!
发布于 2013-12-14 16:48:37
没有一个像对齐这样的函数,您需要自己去做/实现它,或者找到一个已经实现的函数。
这里有一个解决办法。
您需要从所有三个图像中提取关键点,并尝试匹配它们。确保您的关键点提取技术是不变的光照变化,因为所有的强度值不同,因为不同的曝光。你需要匹配你的关键点,找出一些差距。然后,您可以使用视差对齐您的图像。
请记住,这个答案非常肤浅,首先您需要对keypoint/描述符提取和keypoint/描述符匹配进行一些研究。
祝好运!
发布于 2015-07-07 06:45:01
在findTransformECC. 3.0中,您可以使用OpenCV我从ECC图像对齐中复制了这个LearnOpenCV.com代码,其中解决了一个非常类似的颜色通道对齐问题。文章还包含Python中的代码。希望这能有所帮助。
// Read the images to be aligned
Mat im1 = imread("images/image1.jpg");
Mat im2 = imread("images/image2.jpg");
// Convert images to gray scale;
Mat im1_gray, im2_gray;
cvtColor(im1, im1_gray, CV_BGR2GRAY);
cvtColor(im2, im2_gray, CV_BGR2GRAY);
// Define the motion model
const int warp_mode = MOTION_EUCLIDEAN;
// Set a 2x3 or 3x3 warp matrix depending on the motion model.
Mat warp_matrix;
// Initialize the matrix to identity
if ( warp_mode == MOTION_HOMOGRAPHY )
warp_matrix = Mat::eye(3, 3, CV_32F);
else
warp_matrix = Mat::eye(2, 3, CV_32F);
// Specify the number of iterations.
int number_of_iterations = 5000;
// Specify the threshold of the increment
// in the correlation coefficient between two iterations
double termination_eps = 1e-10;
// Define termination criteria
TermCriteria criteria (TermCriteria::COUNT+TermCriteria::EPS, number_of_iterations, termination_eps);
// Run the ECC algorithm. The results are stored in warp_matrix.
findTransformECC(
im1_gray,
im2_gray,
warp_matrix,
warp_mode,
criteria
);
// Storage for warped image.
Mat im2_aligned;
if (warp_mode != MOTION_HOMOGRAPHY)
// Use warpAffine for Translation, Euclidean and Affine
warpAffine(im2, im2_aligned, warp_matrix, im1.size(), INTER_LINEAR + WARP_INVERSE_MAP);
else
// Use warpPerspective for Homography
warpPerspective (im2, im2_aligned, warp_matrix, im1.size(),INTER_LINEAR + WARP_INVERSE_MAP);
// Show final result
imshow("Image 1", im1);
imshow("Image 2", im2);
imshow("Image 2 Aligned", im2_aligned);
waitKey(0);https://stackoverflow.com/questions/20584527
复制相似问题