Summary of the invention
The technical problem to be solved in the present invention is, for the above-mentioned defect of prior art, provides a kind of change simple, the fast and effective method and apparatus that two-dimensional video is converted to 3 D video of speed.
The technical solution adopted for the present invention to solve the technical problems is: propose a kind of method that two-dimensional video is converted to 3 D video, comprise the steps:
S1, current video frame is carried out to horizontal convergent-divergent, making the lateral resolution after convergent-divergent is n+M, wherein, and the original lateral resolution that n is frame of video, the parallax that M is 3 D video;
In S2, extraction convergent-divergent rear video frame, the capable j row of the i Component Matrices of the first Color Channel matrix is as the wherein image of a glance of images of left and right eyes, extract in convergent-divergent rear video frame at least one and this first color each other the capable b row of a Component Matrices of the second Color Channel matrix of complementary color as wherein another image of images of left and right eyes, wherein, i=0,1,, m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video;
S3, synthetic left eye figure and right eye figure obtain 3 D video frame.
In an embodiment, described step S1 further comprises:
Adopt cubic spline base interpolation to carry out horizontal convergent-divergent to current video frame, wherein, spline Basis A is as follows:
In an embodiment, described method is carried out interpolation in the following way:
g(u,v)=ABA
T,
Wherein, g (u, v) represents the frame of video after convergent-divergent, 0<u< (n+M), 0<v< (n+M);
A
trepresent the transposition of spline Basis matrix A;
F (x, y) in matrix B represents u, the v nearest coordinate points of correspondence position in former frame of video.
In an embodiment, described step S1 further comprises:
Three Color Channels of red, green, blue to current video frame carry out respectively horizontal convergent-divergent, and making the lateral resolution after convergent-divergent is n+M, wherein, and the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
In an embodiment, described step S2 further comprises:
Extract the capable j row of the i Component Matrices of the red channel matrix after convergent-divergent as left eye figure, extract the capable b row of a Component Matrices of the green channel matrix after convergent-divergent and the blue channel matrix after convergent-divergent as right eye figure, wherein, i=0,1 ..., m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
The present invention solves its technical problem also to propose a kind of device that two-dimensional video is converted to 3 D video, comprising:
Zoom module, for current video frame is carried out to horizontal convergent-divergent, making the lateral resolution after convergent-divergent is n+M, wherein, the original lateral resolution that n is frame of video, the parallax that M is 3 D video;
Extraction module, the capable j row of the i Component Matrices that is used for extracting convergent-divergent rear video frame the first Color Channel matrix is as the wherein image of a glance of images of left and right eyes, extract in convergent-divergent rear video frame at least one and this first color each other the capable b row of a Component Matrices of the second Color Channel matrix of complementary color as wherein another image of images of left and right eyes, wherein, i=0,1 ..., m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video;
Synthesis module, obtains 3 D video frame for the synthesis of left eye figure and right eye figure.
In an embodiment, described Zoom module further adopts cubic spline base interpolation to carry out horizontal convergent-divergent to current video frame, and wherein, spline Basis A is as follows:
In an embodiment, described Zoom module carries out interpolation in the following way:
g(u,v)=ABA
T,
Wherein, g (u, v) represents the frame of video after convergent-divergent, 0<u< (n+M), 0<v< (n+M);
A
trepresent the transposition of spline Basis matrix A;
F (x, y) in matrix B represents u, the v nearest coordinate points of correspondence position in former frame of video.
In an embodiment, described Zoom module further carries out respectively horizontal convergent-divergent to three Color Channels of red, green, blue of current video frame, and making the lateral resolution after convergent-divergent is n+M, wherein, n is the original lateral resolution of frame of video, the parallax that M is 3 D video.
In an embodiment, described extraction module extracts the capable j row of the i Component Matrices of the red channel matrix after convergent-divergent as left eye figure, extracts the capable b row of a Component Matrices of the green channel matrix after convergent-divergent and the blue channel matrix after convergent-divergent as right eye figure, wherein, i=0,1,, m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
The method and apparatus that two-dimensional video is converted to 3 D video that the present invention proposes, that 2D based on complementary colours technology turns 3D technology, by current video frame being carried out to convergent-divergent, extraction left and right eye pattern, tri-steps realizations of compound stereoscopic figure, algorithm is simple, conversion speed is faster, well the definition of keep the edge information.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
The present invention proposes a kind of method and apparatus that based on complementary colours technology, two-dimensional video is converted to 3 D video, by current video frame being carried out to convergent-divergent, extraction left and right eye pattern, tri-steps realizations of compound stereoscopic figure, algorithm is simple, and conversion speed is faster, well the definition of keep the edge information.
Fig. 1 shows the flow chart of the method 100 that two-dimensional video is converted to 3 D video of one embodiment of the invention.As shown in Figure 1, the method 100 starts from step 110.
Next in step 120, current video frame is carried out to horizontal convergent-divergent, making the lateral resolution after convergent-divergent is n+M, wherein, and the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
In order to ensure the definition that can keep video after convergent-divergent, there will not be again frame of video edge to have sawtooth, one embodiment of the present of invention adopt the method for cubic spline base interpolation to carry out horizontal convergent-divergent to frame of video, and wherein, the spline Basis A adopting is as follows:
Further, in specific embodiment, the concrete mode of interpolation is as follows:
g(u,v)=ABA
T,
Wherein, g (u, v) represents the frame of video after convergent-divergent, 0<u< (n+M), 0<v< (n+M);
A
trepresent the transposition of spline Basis matrix A;
F (x, y) in matrix B represents u, the v nearest coordinate points of correspondence position in former frame of video.
Next in step 130, extract left and right eye pattern, that is: the capable j row of the i Component Matrices that extracts the first Color Channel matrix in convergent-divergent rear video frame is as the wherein image of a glance of images of left and right eyes, extract in convergent-divergent rear video frame at least one and this first color each other the capable b row of a Component Matrices of the second Color Channel matrix of complementary color as wherein another image of images of left and right eyes, wherein, i=0,1,, m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.The present invention is that the two dimension based on complementary colours technology turns 3-D technology, left eye figure and right eye figure complementary color each other, and in different embodiment, the complementary colours that can adopt comprises red indigo plant, the red various modes such as green, follow-uply provides detailed introduction in connection with specific embodiment.
Next in step 140, left eye figure and right eye figure that synthesis step 130 extracts obtain 3 D video frame.
As previously mentioned, by above method of the present invention, 2D is faster to the conversion speed of 3D, and the well definition of keep the edge information of energy.
Fig. 2 shows the flow chart of the method 200 that two-dimensional video is converted to 3 D video of another specific embodiment of the present invention.As shown in Figure 2, the method 200 starts from step 210.
Next in step 220, three Color Channels of red, green, blue (RGB) of current video frame are carried out respectively to horizontal convergent-divergent, making the lateral resolution after convergent-divergent is n+M, that is:
Wherein, C represents Color Channel matrix, the longitudinal frame that m is frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
As previously mentioned, in order to ensure the definition that can keep video after convergent-divergent, there will not be again frame of video edge to have sawtooth, can adopt the method for cubic spline base interpolation to carry out respectively horizontal convergent-divergent to three Color Channels of red, green, blue of current video frame.
Next in step 230, extract left and right eye pattern, that is: extract the Component Matrices of the red channel matrix after convergent-divergent as left eye figure, extract the Component Matrices of the green channel matrix after convergent-divergent and the blue channel matrix after convergent-divergent as right eye figure.
Specifically, red component matrix is taken from the capable j row of i of the red channel matrix R after convergent-divergent, i=0, and 1 ..., m; J=0,1 ..., n, that is:
Green component matrix is taken from the capable b row of a of the green channel matrix G after convergent-divergent, a=0, and 1 ..., m; B=M, M+1 ..., n+M, that is:
Blue component matrix is taken from the capable b row of a of the blue channel matrix B after convergent-divergent, a=0, and 1 ..., m; B=M, M+1 ..., n+M, that is:
Next in step 240, the left eye figure that synthesis step 230 extracts and right eye figure (three R, G, B Component Matrices) obtain 3 D video frame.
Finally, method 200 ends at step 250.
In embodiment shown in Fig. 2, the present invention adopts left eye red channel, bluish-green two the such patterns of passage of right eye to realize three-dimensional stereo effect, and obviously, the present invention is not limited to this.In different embodiment according to the subject invention, also can adopt the pattern of Color Channel of left eye, a Color Channel of right eye (complementary colours) to realize three-dimensional stereo effect.
Fig. 3 shows the logic diagram of the device 300 that two-dimensional video is converted to 3 D video of one embodiment of the invention.As shown in Figure 3, this device 300 that two-dimensional video is converted to 3 D video comprises Zoom module 310, extraction module 320 and synthesis module 330.Zoom module 310 is for carrying out horizontal convergent-divergent to current video frame, and making the lateral resolution after convergent-divergent is n+M, wherein, and the original lateral resolution that n is frame of video, the parallax that M is 3 D video.Extraction module 320 is for extracting left and right eye pattern, that is: the capable j row of the i Component Matrices that extracts the first Color Channel matrix in convergent-divergent rear video frame is as the wherein image of a glance of images of left and right eyes, extract in convergent-divergent rear video frame at least one and this first color each other the capable b row of a Component Matrices of the second Color Channel matrix of complementary color as wherein another image of images of left and right eyes, wherein, i=0,1 ..., m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.Synthesis module 330 obtains 3 D video frame for the synthesis of left eye figure and right eye figure.
In an embodiment, Zoom module 310 further adopts cubic spline base interpolation to carry out horizontal convergent-divergent to current video frame, and wherein, spline Basis A is as follows:
Further, in specific embodiment, in order to ensure the definition that can keep video after convergent-divergent, there will not be again frame of video edge to have sawtooth, Zoom module 210 carries out interpolation in the following way:
g(u,v)=ABA
T,
Wherein, g (u, v) represents the frame of video after convergent-divergent, 0<u< (n+M), 0<v< (n+M);
A
trepresent the transposition of spline Basis matrix A;
F (x, y) in matrix B represents u, the v nearest coordinate points of correspondence position in former frame of video.
Further, in embodiment, Zoom module 310 carries out respectively horizontal convergent-divergent to three Color Channels of red, green, blue of current video frame, and making the lateral resolution after convergent-divergent is n+M, wherein, and the original lateral resolution that n is frame of video, the parallax that M is 3 D video.
In a specific embodiment, extraction module 320 extracts the capable j row of the i Component Matrices of the red channel matrix after convergent-divergent as left eye figure, extracts the capable b row of a Component Matrices of the green channel matrix after convergent-divergent and the blue channel matrix after convergent-divergent as right eye figure, wherein, i=0,1,, m; J=0,1 ..., n; A=0,1 ..., m; B=M, M+1 ..., n+M; M is the longitudinal frame of frame of video, the original lateral resolution that n is frame of video, the parallax that M is 3 D video.But obviously,, the present invention is not limited to this.In different embodiment according to the subject invention, extraction module 320 can adopt in Red Green Blue arbitrary primary colors to all the other mixed-color light of two kinds as complementary colours, extract left-and right-eye images.In addition, extraction module 320 also can adopt the pattern of Color Channel of left eye, a Color Channel of right eye (complementary colours) to extract left and right eye pattern.The left and right eye pattern ECDC that extraction module 320 extracts becomes module 330 synthetic, obtains 3 D stereo video.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, all any amendments of doing within the spirit and principles in the present invention, be equal to and replace and improvement etc., within all should being included in protection scope of the present invention.