Monday, December 29, 2014

3D (Anaglyph) Image With GIMP

What You Need:

1. A mobile/digital camera
2. A PC with GIMP (preferably running GNU/Linux)
3. Glass papers (red, blue and green colors)
4. Carton box (like the one comes with corn flakes, health drinks etc)
5. A pair of scissors
6. Glue

3D - An Introduction:

What ever we see with TWO eyes is 3D. Yes. It needs two eyes to resolve 3 dimensional visual. The same is true for hearing. How this happens? We have two eyes. But they are placed slightly apart on our face. This small distance between the eyes does the trick. Both our eyes send a two dimensional visual to our brain. and our brain merges them to resolve 3 dimensional vision. Closer the object, higher the difference between the images and farther the image lesser the difference between images created by right and left eyes. Using this, our brain creates a 3 dimensional vision.

Clicking The Photo(s!):

As we have seen in the introduction, we need two slightly different images of same object to create a 3D anaglyph. So take a photo with your digital/mobile camera and slightly move the camera few centimetres to left/right and click another image. Extreme care must be taken to avoid change in lighting, shakes and zoom levels. Try your best to keep the change in horizontal plane as much as possible (like our eyes which are horizontally separated). I have clicked first photo of this tiger doll and slightly moved the camera horizontally to left and clicked the second photo.
Right eye view
Left eye view
GIMP Work:

1. First open your right eye view image with GIMP

2. Go to Colors -> Desaturate and choose whatever shade of grey base you like. I have chosen Luminosity.
3. In color picker dialog choose red as foreground color. Make sure the values in Blue and Green fields are 0 and Red field is 255
4. Now go to Layers -> New Layer and choose foreground color. A red layer will be placed on your image! Don't panic!

5. Go to File -> Open as Layer and choose the left eye view image

6. Go to Colors -> Desaturate and choose exactly same shade of grey base as you chose in right eye view image.

7. A quick look in to your layer dialog will be like this!
8. In color picker dialog choose cyan as foreground color. Make sure the values in Blue and Green fields are 255 and Red field is 0
9. Now go to Layers -> New Layer and choose foreground color. A cyan layer will be placed on your image! Again, don't panic!

10. A quick look in to your layer dialog will be like this!
11. Select Cyan layer and choose the mode to "Screen"

12. Click on the eye icon in the layers to toggle visibility. If the eye icon is displayed, the layer is visible. Now make cyan layer and left eye image layer alone visible
13. Now your image will be like this. Go to Image -> Merge Visible Layers...
14. A quick look in to your layer dialog will be like this!
15. Select Red layer and choose the mode to "Screen"

16. Make red layer and right eye image layer alone visible


17. Now your image will be like this. Go to Image -> Merge Visible Layers...
18. A quick look in to your layer dialog will be like this!
19. Make both layers visible and select the cyan layer. Select mode as "Multiply"
20. If done correctly, your image will be like this. Export it as JPEG or PNG as you wish.

21. Fine tune your anaglyph by adjusting the layers while wearing the 3D red-cyan glasses (see below to know how to make it!)

Here is the anaglyph I have made!



The Glasses:

To make the glasses, you need red, blue and green glass papers. Cut two rectangles of red glass paper and one rectangle each of blue and green papers. Cut the frame of the glass from the carton box. Glue the red paper on one eye and blue and green on the other (to create cyan). I have made one within 15 minutes. The glass papers (large sheet) cost Rs. 5 each. You can make at least 10 glasses with a single purchase of glass papers.

Viewing:

Place the cyan side on your right eye and red side on your left eye. If you see ghost image, then move farther from screen or just zoom out the image. Outdoor images with farther backgrounds work better with this trick.

Conclusion:

So we have seen how to create an anaglyph with easy steps using GIMP. Also we have seen how to create 3D glasses at home cheap and easy! So enjoy your weekend with kids. If possible, kindly share your anaglyphs here!