立体感的3D图像(包含左右眼)生成Red-Cyan分析图

来源:互联网 发布:查微信聊天记录软件 编辑:程序博客网 时间:2024/04/29 12:13

现在在作3D的东西,得到左右两个视角的图,但不知道怎么来判断效果,不知道哪个结果更好,怎么办?现在整理了些方法,备份在此,供大家分享和讨论。

1.Red-Cyan anaglyph

      没有眼镜也没有关系,看视觉的一致性,视觉不一致,会带来retinal rivalry,我是这么理解的吧,如果object A在左视角出现,不在右视角出现,或者虽然都出现,但是二者形状改变等,左右眼融合得到3D时,就会很不舒服。

具体的话,看红绿色块的重叠情况。

1) vertical disparity,vertical disparity会带来3D fatigue(看3D会有明显的疲劳感).

比如:


2)monocular object violation,就是有可能object只在一个视角出现


上面2组对比,显然,Oure Result要比Baseline result好!

Code:

import cvSHIFT=8if __name__ == '__main__':    import sys    _, fname = sys.argv    im  = cv.LoadImage(fname)    size = cv.GetSize(im)    width, height = size    left  = cv.CreateImage(size, im.depth, im.nChannels)    right = cv.CreateImage(size, im.depth, im.nChannels)    anaglyph = cv.CreateImage((width - SHIFT, height), im.depth, im.nChannels)    #    # This would be easier if we had COI support for cv.Set, but it doesn't    # work that way.    # OpenCV uses BGR order (even if input image is greyscale):    # http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html    # red goes on the left, cyan on the right:    # http://en.wikipedia.org/wiki/Anaglyph_image    #    b = cv.CreateImage(size, im.depth, 1)    g = cv.CreateImage(size, im.depth, 1)    r = cv.CreateImage(size, im.depth, 1)    cv.Split(im, b, g, r, None)    zeros = cv.CreateImage(size, r.depth, 1)    cv.Merge(zeros, zeros, r, None, left)    cv.Merge(b, g, zeros, None, right)    #    # cvRect is ( x, y, width, height ) and it MUST be a tuple, not a list    #     cv.SetImageROI(left,  ( SHIFT, 0, width - SHIFT, height ))    cv.SetImageROI(right, ( 0,     0, width - SHIFT, height ))    cv.Add(left, right, anaglyph, None)    cv.SaveImage('anaglyph.jpeg', anaglyph)

结果验证:



好啦,先更新到这里,以后有方法,在补充~

原创粉丝点击