5
我正在使用SimpleCV来拼接图像。我在SimpleCV的GitHub代码中做了一些改变,并最终正确地转换了图像。但问题是,变换后图像的颜色会发生变化。图像拼接SimpleCV:变形后的颜色空间变化
我已经使用了这些图像http://imgur.com/a/lrGw4。我的代码的输出是:http://i.imgur.com/2J722h.jpg
这是我的代码:
from SimpleCV import *
import cv2
import cv
img1 = Image("s.jpg")
img2 = Image("t.jpg")
dst = Image((2000, 1600))
# Find the keypoints.
ofimg = img1.findKeypointMatch(img2)
# The homography matrix.
homo = ofimg[1]
eh = dst.getMatrix()
# transform the image.
x = Image(cv2.warpPerspective(np.array((img2.getMatrix())), homo,
(eh.rows, eh.cols+300), np.array(eh), cv.INTER_CUBIC))
# blit the img1 now on coordinate (0, 0).
x = x.blit(img1, alpha=0.4)
x.save("rishi1.jpg")
我正在使用github的SimpleCV的最新版本。我这样做是因为我在SimpleCV的代码中做了一些改变。在此之前,单应性矩阵本身是错误的。但是现在图像完全变形了,但变换图像的颜色会发生变化。在findkeypointMatch函数中,我更改了一些代码。这是我执行的变更https://github.com/ingenuitas/SimpleCV/pull/63/files。但颜色问题也在之前。 – Rishi 2012-04-16 17:06:43
我编辑了答案。我不能完全运行你的代码,但写了一个类似的脚本,发现问题是倒置的颜色空间。 – fireant 2012-04-18 05:54:15
真棒.. :)。你的逻辑完美无缺。 :)。谢谢。 – Rishi 2012-04-18 13:43:16