PDA

View Full Version : Anaglyph - is it possible to preserve colors?



Petr Schreiber
02-02-2010, 20:27
Dear friends,

you might noticed increased level of talk regarding various 3D technologies recently. There are multiple solutions available, like nvidia 3D glasses, special "3D" monitors and projectors.

And then there is the good old anaglyph we've been playing in TBGL for some time. It provided nice illusion of depth, but the colors were just completely wrong. Also lot of talk over net cited impossibility to maintain colors with red cyan glasses.

I was experimenting with this, wanted to break this color fidelity problem. I got some nice results, but then I realised ... somebody did this before me ... and better (http://3dtv.at/Knowhow/AnaglyphComparison_en.aspx).

Anyway this was nice challenge, and I present you here little program implementing algorithms from the mentioned source. It is application allowing to combine two images to one anaglyph.

This is very nice task for ThinBASIC, as the script could take advantage of:

Calling function by name
Built-in matrix handling
Canvas and TImage module


The first one is used for simple thing - all image processing functions start with "PA_", so I can automatically detect them from source and add them as option in the dialog automagically.

Built-in matrix handling allows to perform quite fast per pixel operations.

Canvas serves as display of the images, while TImage allows to load images of various formats.

The script itself is far from perfect - it could use some speed tuning (I don't recommend images over 640x480 unless you have fast PC) and it seems the TImage module sometimes makes image "upside down".

But I hope you will like this experiment, and maybe it will be you who will discover even better technique to maintain good level of color fidelity with anaglyph.

The images you get with the script are photos taken by me using normal camera - you just shoot one frame, focusing on some point on the object, then shift the camera while still keeping the same part of object in focus and grab other frame. This should simulate view of left and right eye. I will appreciate any left-right images from you, as I think the mine do not demonstrate the 3D effect to the edge yet.

Last word - the latest beta is a must to have for fast and proper execution of the script.


Have fun,
Petr

Lionheart008
02-02-2010, 22:54
super! :)

I have tried and built my own horror scene but with a strandgirl ;)
the example works very fine! although I haven't 3d glasses it looks like a charming thing.

it's possible for next release to save the rendered picture ? would be good idea.

many thanks for this great example, petr. I like it!

(sometimes I don't know clearly if I should use better canvas mode or tbgl for my scenes. some days ago I was looking for a chart diagram example like you can see at financial it companies uses for market-prices (dollar, pound, yen and so on...). so I will try to use in canvas mode. I am missing some more and new canvas examples ;) )

servus, many thanks for this great idea, franko lionheart

Petr Schreiber
02-02-2010, 23:00
Hi Frank,

thanks for the test :)

When you need full quality:

Load image for left/right eye
Press "Full render"
After it is done, hit "Save"


This way it will save the image at full resolution, and not just 320x240 preview one you can see. I produced this way the big image attached to the first post (I have rendered even 1280x960 with this program, but it takes time).

The last render is saved automatically to file "___temp___.bmp"


Petr

kryton9
02-02-2010, 23:07
Petr, as always... exciting area to be coding in and researching. Thanks for a cool program and example.

Frank, nice subject for 3D!

Lionheart008
02-02-2010, 23:10
petr, I have only forgotten to "save" the rendered picture ;) thanks for info!
saved my strandgirl in my last post!

frank