Creating Anaglyph & CrossEyed 3D images using (MaxScript)
Stereoscopy (also called stereoscopic or 3-D imaging) is any technique capable of recording three-dimensional visual information or creating the illusion of depth in an image. More info here.
Now to create a 3D image we need two pictures - one for the left eye and one for the right eye. These two images must be of the same size (height x width). These two images can be obtained by either clicking 2 pictures form a camera (one representing the image for the left eye and one representing the right eye) or can be rendered in a 3D program such as 3Ds max or Maya by creating 2 cameras in them offset by about 2" (the average distance between the human eyes) .
Left Eye Image:
Right Eye Image:
Now we can combine these images to get different types of 3D images . This can be done in various ways such using specialized programs available on the internet or using Photoshop but we will do the same using maxscript(F11 to open script editor).
Here is the script for creating red-cyan anaglyph 3D images.
a = openbitmap (getOpenFileName caption:"Left Eye Image")
b = openbitmap (getOpenFileName caption:"Right Eye Image")
c = bitmap a.width a.height
for i=0 to a.width -1 do
{
for j=0 to a.height -1 do
{
ColorLeft = getPixels a [i,j] 1
ColorRight = getPixels b [i,j] 1
ColorFinal = #([ColorLeft[1].red , ColorRight[1].green , ColorRight[1].blue])
setPixels c [i,j] ColorFinal
}
}
display c
Output:
Note: You will need a pair of red-cyan 3D glasses to view the image
Here is the script for creating cross-eyed 3D images.
a = openbitmap (getOpenFileName caption:"Left Eye Image")
b = openbitmap (getOpenFileName caption:"Right Eye Image")
c = bitmap a.width+b.width a.height
for i=0 to a.width -1 do
{
for j=0 to a.height -1 do
{
setPixels c [i,j] getPixels a [i,j] 1
setPixels c [i,j+a.width] getPixels b [i,j] 1
}
}
display c
Output:
Note :
1) .jpg images were giving a problem with this code but it worked fine with .png format.
2) The above images are of Apache LongBow made using 3Ds max with mental ray and photometric lighting...
Now to create a 3D image we need two pictures - one for the left eye and one for the right eye. These two images must be of the same size (height x width). These two images can be obtained by either clicking 2 pictures form a camera (one representing the image for the left eye and one representing the right eye) or can be rendered in a 3D program such as 3Ds max or Maya by creating 2 cameras in them offset by about 2" (the average distance between the human eyes) .
Left Eye Image:
Right Eye Image:
Now we can combine these images to get different types of 3D images . This can be done in various ways such using specialized programs available on the internet or using Photoshop but we will do the same using maxscript(F11 to open script editor).
Here is the script for creating red-cyan anaglyph 3D images.
a = openbitmap (getOpenFileName caption:"Left Eye Image")
b = openbitmap (getOpenFileName caption:"Right Eye Image")
c = bitmap a.width a.height
for i=0 to a.width -1 do
{
for j=0 to a.height -1 do
{
ColorLeft = getPixels a [i,j] 1
ColorRight = getPixels b [i,j] 1
ColorFinal = #([ColorLeft[1].red , ColorRight[1].green , ColorRight[1].blue])
setPixels c [i,j] ColorFinal
}
}
display c
Output:
Note: You will need a pair of red-cyan 3D glasses to view the image
Here is the script for creating cross-eyed 3D images.
a = openbitmap (getOpenFileName caption:"Left Eye Image")
b = openbitmap (getOpenFileName caption:"Right Eye Image")
c = bitmap a.width+b.width a.height
for i=0 to a.width -1 do
{
for j=0 to a.height -1 do
{
setPixels c [i,j] getPixels a [i,j] 1
setPixels c [i,j+a.width] getPixels b [i,j] 1
}
}
display c
Output:
Note :
1) .jpg images were giving a problem with this code but it worked fine with .png format.
2) The above images are of Apache LongBow made using 3Ds max with mental ray and photometric lighting...
Comments
Post a Comment