Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3722548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:56:41+00:00 2026-05-19T05:56:41+00:00

How do I create a 3D stereoscopic image from a 2D image using MATLAB?

  • 0

How do I create a 3D stereoscopic image from a 2D image using MATLAB?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:56:42+00:00Added an answer on May 19, 2026 at 5:56 am

    Either I’m misunderstanding your question (people have already pointed out that it’s not clear), or you are misunderstanding the way 3D vision works. You don’t “see 2D image using 3D glass”. 3D vision is achieved by serving two different images, left image and right image, to the left eye and right eye, respectively. At a fundamental level MATLAB doesn’t have anything to do with it.

    So, in absence of an easily understandable or coherent question, the best I can do is assume you want something like this: you have is a single 2D image, but you still want to “seen into 3d image format”. In that case, you need to somehow split that single image into two new images:

    1. Left image for the left eye
    2. Right image for the right eye

    This isn’t trivial. Generally, you start by inferring the depth of each pixel in the 2D image. Since you’re “guessing” the depth information, the two new images won’t be a perfect representation of a 3D scene.

    Next, you separate your image into layers using that depth information. It will essentially look like a pop-up cutout from a children’s book:

    alt text

    The more layers you can come up with, and the more accurate your depth estimation is, the more realistic your 3D representation will be.

    Finally, you project that layered representation back onto 2D from two different positions — one for the left eye, and one for the right eye. This gives you the two different images you needed.

    EDIT

    The second video you linked to describes the simplified creation of what is commonly known as an anaglyph image. It requires 3D red-cyan glasses — these are not the polarized glasses they use in most 3D theaters now. The reason I say simplified is that it doesn’t discriminate between the foreground and background.

    For best effect, you’d separate the foreground from the background, and apply the approach only to the foreground. This is because typically background has infinite depth and doesn’t change when going from mono to stereo vision. In the case of the piano, everything is more or less foreground, so the approach works.

    The algorithm the video describes is:

    • Start with two images, im1 and im2. They are identical
    • Set the green and blue channels of im1 to zero. This will create the red image
    • Set the red channel of im2 to zero. This will create the cyan image.
    • Offset the two images by some specified amount (depending on the depth to subject) such that im1 is on the left and im2 is on the right. You need to get this order correctly because 3D red-cyan glasses have red on the left, and cyan on the right.
    • Perform element-wise addition of the two shifted images. Note that no channels will saturate.

    Here’s some Python/OpenCV code I wrote:

    import cv
    SHIFT=8
    
    if __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)
    

    Here’s a similar image to what’s used in the video:

    alt text

    Here’s the output:

    alt text

    Unfortunately I don’t have 3D red-cyan glasses to verify that this works. But it seems like it should, at least in theory. Perhaps somebody can correct me if I’ve made a mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

CREATE VIEW myView AS SELECT * FROM `ce_userbadges` WHERE ceub_userid =85; SELECT * FROM
CREATE VIEW xxxx AS SELECT order_date, DATEPART(W, order_date) AS dayID, Type FROM dbo.Shipment_Dates WHERE
I have a random 2D image. I would like to be able to present
CREATE TABLE parent (id INT NOT NULL, PRIMARY KEY (id) ) ENGINE=INNODB; CREATE TABLE
CREATE TABLE `surfkid-db`.`Channels` (`name` VARCHAR( 30 ) NOT NULL ,`commercial` BOOL( 1 ) NOT
CREATE TABLE IF NOT EXISTS `Channels` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(30)
CREATE TRIGGER ChangesTracker on [SearchEngine].[Urls] FOR UPDATE, INSERT AS UPDATE [SearchEngine].[Urls] SET [IsNormalized] =
create table Autorzy(ID int, imie varchar, nazwisko varchar); create table Wydawnictwa(ID int, nazwa varchar,
CREATE TABLE [dbo].[Project]( [ProjectId] [int] NOT NULL, [ProjectName] [nvarchar](255) , [ParentProjectId] [int] null, [ReleaseId]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.