(1 to 100 of 138 replies)
tom.keil 1:51pm, 27 February 2011
I propose a new filter which automatically turns your 2D image into a 3D stereoscopic image. Output is a red/cyan anaglyph which seems to be the most popular form of viewing 3D images.

Here is how it goes:

You need a pair of red/cyan glasses for adjustment as well as for viewing your final 3D image!

Open your image and call the Make 3D filter from G´MIC. Select from the "Scene selector" which scene represents best the image you are processing. The filter is based on estimated depth distributions for most of standard scenes, so you may need to play around with the settings to get the best results.

With the slider "Stereo base" you control how much the image for the left eye differs from the image for the right eye.
With the slider "Depth control" you can vary the distribution of the depth field of the image.

Red/cyan stereoscopic glasses are a cheap, non calibrated article. They absorb a lot of light and change the colors, in particular most of them absorb a lot of red. So you may adjust the Gamma, colors and red/cyan balance of your anaglyph according to your individual glasses, monitor and printer. Making a black & white 3D image often is also a good choice.

This filter is based on estimations of a theorectical depth field of your image. Your 2D image in reality does not contain any real depth information, it is just one flat image. So results can not compete with real stereoscopic captures taken with a twin camera or carefully crafted handmade stereo conversions.
But you can reach a quite strong and convincing 3D view on most images.
Very advanced users may also like you use a individually created depth map, this is also possible. In this case place the depth map below you image and set G´MIC input layers to "active&below". A depth map in short words is a greyscale representation of your image where the parts closest to the viewer are white and the most distant parts are black.

Here is the filter interface:

Make 3D filter interface

And here is a 3D conversion example:

Make 3D filter demo

The filter file can be downloaded here:

(1 to 100 of 138 replies)
zonderr 6 years ago
I don't have glasses to try, but your way of creating a 3D image is interesting.
Ronounours 6 years ago
Very nice idea, added to the official filter list (in 'Rendering/').
Thanks Tom !
lylejk 6 years ago
Anyway to convert to crosseye 3D or parallel 3D? I don't have a pair of color 3D glasses either. :)
tom.keil 6 years ago
@lyle: yes. crosseye and parallel should be possible, i will try to put the options next week.
lylejk Posted 6 years ago. Edited by lylejk (moderator) 6 years ago
That would be cool Tom. Crosseye is the easiest for most to do but does make the result look slightly smaller. Parallel (magiceye) method is the hardest, but, for me, it makes for a more in focus and slightly bigger result (when the image merges). :)
PhotoComiX 6 years ago
lylejk cool idea, i hate 3D glasses they give me headaches but i love magiceye
tom.keil 6 years ago
Here is another question: I wanted to implement the cross eyed and parallel views for those who do not like glasses :-)

Thought it was simple but now i got stuck again.
In my stack are my left eye and right eye image.
With -r[-2] 50%,50% -array[-1] 2,1 -to_rgba[-2] i perfectly get the desired view in GIMP, but on two layers.
When i want to merge them down with -rv[-1,-2] -compose_rgba[-1,-2] my upper image moves to the middle.
And whatever i try with -shift and -expand_x on the upper image i can not keep it on the left side?
Ronounours 6 years ago
To append two images together, just use the '-append' command, in your cas, '-append x' should to the trick.
tom.keil 6 years ago
Thanks David,

i will try it out. In the meantime i found that

-array[-1,-2] 2,1 -to_rgba[-2] -shift[-2] 50%
-rv[-1,-2] -compose_rgba[-1,-2]

does it, but yours looks more elegant :-)
tom.keil 6 years ago
I have put in the option for output of stereo pairs in the filter.

Just tick the option "Stereo pairs" and "Flip left/right" to change between parallel and cross eyed view:


Could someone with skills in viewing stereo pairs please check if the effect comes out well, I am only used to stereo glasses?
lylejk 6 years ago
OK Tom. There might be a bug in G'MIC. Currently I have no entries in my .gmic file. I placed you updated preset in it and then G'MIC won't work (all presets). Get the transparent thingy issue. I tried refreshing filters and even rebooted my machine but to no avail. Only when I removed your preset from my .gmic file did gmic work right again. Oh well. Maybe David can figure this one out. :)
PhotoComiX Posted 6 years ago. Edited by PhotoComiX (member) 6 years ago

I noticed some lines break : as example i believe this

" #@gimp : Scene selector = choice("light motive","dark motive","landscape","center

foreground","center background","left foreground","right


should be in only one line same for

"#@gimp : note = note("To use this option your depth map must be placed

below your image. Switch input layers to Active and

.") "

I may be wrong i don't have time to check my guess and for sure Tom and David know better

But you may try: empty lines are not a problem but broken lines may be well a problem

wait i want be more clear :
before this lines

gimp_make3D :

-repeat @# -l[$>] -if {$6==0} -to_rgb[0] --gimp_do_nothing[0]

each line has to start with #@ (or # if is a comment ) if not the line was broken...and in case i am sure you may guesss the fix (longer lines with no breaks ...)
PhotoComiX Posted 6 years ago. Edited by PhotoComiX (member) 6 years ago
EDIT- Solved

i believe was a pastebin issue:
i corrected all the broken lines, tested, but after uploading i noticed that one of the lines i was sure to have fixed was again broken

so i uploaded again, this time should work

lylejk 6 years ago
Hey PC; looks like your fix worked but I had to figure out how to use it. Didn't like the 50% scale feature so did modfify that (would be nice to be an input then forced; I just changed it to 100% and I decide what the scale should be then). Still pretty convincing result, but, like Tom said, not like actually having 2 images created properly. Below's a cross-eye result. :)

Fake x-eye 3D by lylejk
PhotoComiX Posted 6 years ago. Edited by PhotoComiX (member) 6 years ago
that was really easy to fix because were no errors in Tom code

only the inline for some reason went screwed up, but in a such evident way to jump to the eyes

it would be nice if fix my own errors would be so simple !
lylejk 6 years ago
Maybe so PC, but besides you, Tom or David, and a handful of others maybe, don't think this one would have gotten fixed. Again, I'm no coder; just a poser (inside joke for those who frequent GIMPChat). :)
Ronounours 6 years ago
Very nice ! I can see the 3d effect clearly in the picture Lyle has posted.
tom.keil 6 years ago
sorry for the pastebin-confusion :-). do not know what happened. I just copied and pasted the code from the functioning file into pastebin as usual.

I will make an option for the output size, i thought 50% to be good choice because you do not need to adjust image size in GIMP afterwards.

Concerning the quality of the effect, of course it can never match in full with a 3D image made from 2 photos with really different viewpoint.
Although the filter simple, the background is complicated.
A single 2D image does not have any 3D information, you need to create it. That is the challanging part. Next it is stored in something called a depth map and used to create another image which should look as much as possible as taken from another viewpoint.

To define the depth maps i just took some typical depth distributions in typical photographic scenes. So the quality of the final 3D image of course depends on how good this images real depth distribution correlates with the applied typical depth map. That is why you sometimes get excellent results and sometimes crap.

If anyone has good ideas how to estimate depth from 2D images of certain typical scenes, please let me know and i will try to improve the filter further (if it is in the range of my skills to code it). Any ideas are welcome :-)
zonderr 6 years ago
I can't managed to see Lyle 3D image. I guess I am supposed to order my left eye to watch the left image and my right one the other one, but I can't flex that much, is there a trick?

I am usually quite good at seeing stereogram, would it be useful/possible to add such a feature?
PhotoComiX 6 years ago
Tom you did nothing wrong was pastebin having hiccups:
i had to upload twice to solve, the first the code was again mangled
zonderr 6 years ago
Any ideas are welcome

An other useful feature could be to propose to preview or only make the depth map, so that the user could see at once how 3D will look the result.

G'mic is able to handle 3D images, so it could be possible to directly propose a view of a 3D object.
Forest (GKweb.it) 6 years ago
Do you think it would be possible to export only the "fake" 3D map, to be used also for other applications (for instance, the Focus Blur plug-in in GIMP)? It could be very interesting.
lylejk 6 years ago
That's a good idea Forest. I've seen results that use depthmaps to create DOF simulations with photographs. :)
lylejk Posted 6 years ago. Edited by lylejk (moderator) 6 years ago
Hey Zonderr. I did the cross-eye since most folk find it easier to cross their eyes as opposed to paralleling them. Just cross your eyes until the two images merge like when you puty your index finger 3 inches from your forhead, you at first see two fingers, but you can focus to see just a single finger by crossing the eyes. I have heard that there are a small number of folk that can't get the 3D effect with parallel and maybe the carry over applies to crosseye too. Not sure why those folk's mind's eye can't interpret the result as 3D though. :)
tom.keil 6 years ago
Thanks for all the suggestions. I will collect it all and try to make a new version over the weekend.

By now i noted: choice of 50%/100% size for stereo pairs and separate output/preview of the depth map. Any other needs for the output? That is not so hard to do i guess.

@zonderr: i have little knowledge about 3D-modelling, so i think if it is possible to turn an image into a usable 3D-object by alligning the depth map data as z-coordinates i will not be right guy to do it. I am not sure if it is possible at all, it is like reverse engineering the 3D object from 2 renderings if i understood the idea right? And how to recognize an object inside a image? Also this is beyond of what i can do.
lylejk 6 years ago
Not sure if your parallel method works right. Crosseye works find, but I'm not really seeing the stereo effect when choosing the parallel option. Not sure it's as simple as just switching the left and right images (but I could be wrong). :)
zonderr 6 years ago
@tom: there are easy things to make a 3D extrusion according to a depth map in G'mic, but then, I guess some 2D projection is needed to get to normal in gimp. I'll show you some time (not soon) if you are interested.
zonderr Posted 6 years ago. Edited by zonderr (moderator) 6 years ago
If [0] is your image and [1] your depth map:
-elevation3d[0] [1] creates a 3D image
-snapshot3d[0] can make a 2D image of that 3D.

so in your script, that combination should be useful :
-elevation3d[0] [1] -snapshot3d[0]

As an example, If I use that command line, I get flowers looking like a car:
gmic flower.jpg auto.jpg -*[-1] 0.1 -resize[-1] [0] -elevation3d[0] [1] -k[0] -snapshot3d 512 -o flowcar.jpg

flowcar by zonderr
tom.keil 6 years ago
@zonderr: Thanks for the hint, very interesting indeed, i will play around with these sommands a little. Since the results are something completely different than a streoscopic view of the image maybe it is better you make a different new filter from that idea?

While improving the filter i found another issue which is a bit nasty to correct. When using individual depth maps i get preview error. I can keep the preview also for this option intact only if i turn off the all layer processing and the split preview.
If there is no better workaround i think i will drop the split preview for this filter, it is anyway best to use with normal preview of the whole image.
tom.keil 6 years ago
Here is the updated version of the filter:


I called it 3D conversion now because it makes more than anaglyphes.

New options need a short explanation to make full use of them:

There are new output formats besides anaglyphes for parallel and cross eyed pairs (small and big) plus output of the depth map only and also output of the unalligned images.
Output of the depth map is useful for visualisation during adjusting the filter settings and also for manual improvement of the automatic depth map by painting on it. Refine it and use for conversion as individual depth map afterwards. From the depth map you can also easily create a 3D object using 3D elevation filter, use the original image as texture layer.
Parallel and cross eye view in theory is just flipping the images, but you may need to change also the stereo base to adjust to your individual viewing habits.
The output of unalligned images is useful to store them as individual frames and make animated GIF´s from or to produce more exotic stereoscopic views like color code or bottom/top pairs for prismatic stereo viewers.

There are many more 3D scenarios in the scene selector now, so you most certainly will get good results even on complicated images.

There are new methods of improving the depth perception which try to mimic certain abilities of human 3D perception.

With the sliders for the "Feature analyser" image features are emphazised stronger compared with the chosen general 3D perspective. This considers that edges in human perception indicate discrete significant changes in depth (one object in the foreground hides another object in the background).

With the "Local detail enhancer" you may emphazise the 3D appearence of smaller image details in more even areas. This mimics the human ability to perceive depth variations in smaller details stronger in relation to the overall image depth.

Last is the "DOF analyzer" which considers the photographic experience that the main motive is sharp in the foreground whereas the background may be significantly out of focus. This feature is of specific use for shots with shallow DOF, like portrait shots with wide aperture.

The analyser may slow the conversion process of larger images significant, so leave the sliders on zero if you do not need them.

Few new examples using the new features:

automatic 3D conversion test2

automatic 3D conversion test1
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
I just tried the new one, the preview errors, and trying to perform it on the image also results in error. Not sure of pastebin has broken it or not. Sorry I can't look at the script and point out any problems, newbie here.

Edit: Most of the drop down options are broken and left with numbers instead.
tom.keil 6 years ago
Ooops, i saw it, it is this pastebin issue again, pastebin adds some unwanted line breaks to the code, i do not know why. I will repost tomorrow and if it still creates bugs i will uplink the file to another less problematic space. My own code file is working without problems here.
rabidcopy 6 years ago
Ah. I was really looking forward to the new features in this version. Guess it will have to wait. Btw, great work on this script so far!
rabidcopy 6 years ago
Ah hah! With my very little know-how of G'MIC's scripting, I removed all the inappropriate line breaks given by Pastebin, and I now have the script working as it should.
PhotoComiX Posted 6 years ago. Edited by PhotoComiX (member) 6 years ago
i post the links to a couple of pastebin alternatives in the submission topic
tom.keil 6 years ago
Uploaded gain here:


This link should work without problems now :-)
Forest (GKweb.it) Posted 6 years ago. Edited by Forest (GKweb.it) (member) 6 years ago
I had the same problems, but the filter loads correctly now, thank you!
However, there are still other problems.
I tried with a small image 500x375, jpg, a flower macro (and, strangely, the best fitting setting, according to the depth map preview, seems "underwater", I don't know why).
In any case, I tried it with the default settings.
Applying it with output "depth map only" results in a completely uniform gray image (probably just an empty image with dimensions 1x1 if I understand correctly), though with rulers on its sides.
Applying it with any other output choice results in the following message:

" *** Error in ./gimp_make3D/*if/ *** [instance(500,375,1,3,0x103beb000,non-shared)] CImg::warp() : Instance and specified relative warping field (1,1,1,2,0x1022de960) have different XYZ dimensions."

I am using G'MIC as a plug-in on GIMP 2.6.8, on Mac OSX 10.6.6.

(By the way, shouldn't "indivial" depth map read "individual" depth map?)
tom.keil 6 years ago
@Forest: Hard to guess what happened there. I have tested the filter on many images but never had something like you.

When you output "depth map only" with default settings, you should get a black (representigt zero change) image in the same dimensions as your original. In the default the depth control slider is on zero so move it right to make the depth map show up.

From the error code i can only guess: Did you maybe work with the option "individual depth map"? In this case you must make sure that your depth map has exactly the same dimensions as your image has and the input mode must be "active&below", and if you just process a single image it must be "active".

Scene mode "Underwater" uses information from the red channel (because water absorbes red light very strong with increasing distance) so indeed it can be good choice for flower macros too if there is enough red in the blossom color.
Forest (GKweb.it) Posted 6 years ago. Edited by Forest (GKweb.it) (member) 6 years ago
I tried again a moment ago - I just opened a small 500x375 pixels JPG, and clicked "OK" in G'MIC, nothing else than that (I did not touch the "individual depth map" option; on the contrary, if I use it, the error does not appear). G'MIC returned this message:

*** Error in ./gimp_make3D/*if/ *** [instance(500,375,1,3,0x103a00000,non-shared)] CImg::warp() : Instance and specified relative warping field (1,1,1,2,0x10393fa10) have different XYZ dimensions.

I confirm that, when I choose to output "depth map only", the output is a single pixel image, 1x1 (therefore, the grey rectangle that I see is just the empty image background surrounding that single pixel, since a single pixel cannot be seen)

I have also recorded an error log with the console. Would it help you? It's quite a long text, so perhaps it is not suitable to be posted here.

Yes, you are right, the "Underwater" option seems useful for flowers, since they are often surrounded by a lot of green grass (so with a very low red channel value), contrasting with their color.

Just another idea: could the fact that my GIMP is partially in Italian cause this error? Anyway, I think that the console error log I recorded might help to understand what happened.

I will also try to update my GIMP from 2.6.8 to 2.6.11 and see if it helps.
lylejk 6 years ago
Thanks Tom; you re-upload works great. Excellent stuff. Can't wait for either the beta or the full release for Windows to be done since David said this one will be part of that release. :)
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
I just realized. When using a custom-made depth map made from scratch, and using it instead of one of the presets, you can get insanely convincing results! I know converting a 2d image to 3d by hand typically would involve hours upon hours of work shifting segments of the image to simulate the other angle. But by making a rough depth map from scratch in times as short as minutes, it really can give an impressive result. Now my new favorite thing to do in Gimp is these 3D conversions. Hah.
lylejk 6 years ago
Yeah; I use to create fake depth maps and use displacment mapping, but using Tom's plugin seems to give better results. Also, if you export the depthmap made using one of the canned inputs then fine tune it and apply that result, you will be impressed for sure (not showing, but trust me). Again, a big thanks to Tom for this gem. :)
tom.keil 6 years ago
Many thanks that you like this filter. The typing mistake in the interface i will correct in the next upload.

@Forest: Sorry, i tried to replicate your error to find the bug, but i could not make it. All worked fine whatever i tried? Maybe it is best you remove the filter file and install again?
Forest (GKweb.it) Posted 6 years ago. Edited by Forest (GKweb.it) (member) 6 years ago
@tom.keil: I'm sorry not to be able to use your filter, since I think it is really a wonderful one and I'm very thankful for your work.

I removed the filter and installed it again, but this didn't help, the same bug is still there.
Maybe these details can help:
- I did not touch the "use individual depth map" option (I left it unchecked);
- the error message I mentioned above appears only when the output is NOT set to "depth map only".;
- when the output is set to "depth map only", applying the filter to a 500x375 image results in a "depth map" produced with a size of 1x1 (one pixel only);
- when the output is set to "depth map only", applying the filter to a 4000x3000 image results in a "depth map" produced with a size of 4000x1 (one row of pixels, only);
- I have an automatic debugging report about the problem from my console, if it can help, I can send it to you.

When I have time, I will also try updating from GIMP 2.6.8 to 2.6.11 and see if it helps.

Perhaps I can send you in some way this log file from my console with the automatic report about the problem?
rabidcopy 6 years ago
So I've been toying around with this even more and I feel that there's a few improvement/features that could be implemented. 1 feature could be the ability to use the depth map controls on custom depth maps, and possibly a way to save custom depth maps to the presets. (I fear that isn't feasible though.) Another idea is to give the ability to use the script to take a true stereo pair and combine them into an anaglyph/crosseye/parallel image.
lylejk 6 years ago
If you have a true Stereo Pair, you could make a depth map by copying the Right Channel on top of the left (or is it Vice Versa) and then set the layer property to Subtract and then use that result as the base layer for the "Use individual Depthmap" option. :)
tom.keil 6 years ago
I can add a feature to process true stereo pairs relatively easy, BUT: the challanging part in that is not creating the stereo view, but adjusting the two images, in real stereo pairs you have height differences, trapezoid distortions, feature size differences etc., in particular when your images are taken free hand one other other. It is much more convenient to use specialized software for this. StereoPhoto Maker is a great freeware for this, using the hugin allignment modules for auto allignment. This is what i use for processing true stereo pairs.

Using the depth map controls on a custom depth map i will take a look at during the weekend, you mean something like drawing a rough shape by hand and then bring in more details by the filter?

Custom depth maps as a preset inside the filter are not possible, but it is easy to work with them if you store them simply as image and load them as a layer in GIMP for processing your image. If i manage to enable the depth map controls for custom depth maps that should solve the problem i guess.

@Forest: Maybe you can send me your error message by fm, though i am afraid if the error is not related to the filter code directly i may not find it?
rabidcopy 6 years ago
@tom.keil: As for using a custom depth map with access to the controls for depth,feature analyzer threshold, feature analyzer smoothing, and dof, that's what I mean. I'd imagine that this could improve the results when using a custom depth map as it'd be able to fit to the image better opposed to constantly tuning up the custom depth map. (or using the depth map output option to further improve the depth map after using the various controls)

I guess I wasn't really thinking about how trivial it'd be for this script to have the option to provess true stereo pairs when it's meant to convert images to 3D itself. Especially since I've used StereoPhoto Maker before..

Again I must say, great work on this script so far. :)
tom.keil 6 years ago
i am just testing the refinement of manually created depth maps with the filter analyzers. Makes sense and will work, thanks for the hint. I will upload the new file on the weekend. I think with that the filter should be complete, and since it became quite complex in the meantime, i hope i find time to write a tutorial at next occasion.
tom.keil 6 years ago
Recently i am testing on conversions of masterpieces of art. Here is Rembrandts "Nightwatch" in 3D converted in G´MIC without manual work:

Rembrandt: Nightwatch 3D
tom.keil 6 years ago
Here is the new update:


It has some bugfixes and improvements in creating the depth maps plus you now may also load custom depth maps and use image features to refine them by using the various analyzers.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Ouch, unwanted line breaks on the pastie. Oh well not hard to remedy. I'll get back to you on the update when I fix it for myself. Looking forward to the improvements!

Edit: Well everything seems to still be working, and the new presets are there. Just tried the new custom depth map settings and they all seem to work as they should. :) Though there is one thing about custom depth maps now that they can be affected by the modifiers. The depth control has to be higher than zero or the depth map will just register as black. (similar to the light/dark motive presets) Just setting it to 0.1 works and doesn't seem to even give the depth map any noticeable change. Either way, great job and thanks for implementing my idea.
lylejk 6 years ago
Hey Tom. A few years ago, I ran across this cool article on how to convert an image to 3D from a single image. I actually posted it on Fredmirand's site in 2005. Unfortunately, the website is not the same, but that's where the wayback machine comes into play. :)

gentlemanbeggar Posted 6 years ago. Edited by gentlemanbeggar (member) 6 years ago
How hard would it be to add an output option that works like the stereo-pair, only, rather than putting them side-by-side, layering the two images on top of one another? It could be useful for making "wiggle-vision" images.

Coincidentally, thanks for this awesome filter! I've had so much fun since I discovered this.
Forest (GKweb.it) 6 years ago
This note summarizes a problem and an effective workaround to solve it.
A problem has been detected with this filter on GIMP 2.6.11 (and also on GIMP 2.6.8) with G'MIC working on Mac OSX 10.6.6. The problem can be described as follows.

Mac OSX 10.6.6 in Italian
iMac 3.06 GHz Intel Core 2 Duo
Gimp 2.6.8 in Italian (partially, some menu voices are not translated)
X11 2.3.6
G'mic (as a GIMP plug-in: "gmic_gimp")
Input layers in G'mic: default (Active)
Output mode in G'mic: default (In place)
"Use individual depth map" option in the filter: unchecked
Many other Gimp plug-ins present (FX-Foundry among them)

- G'mic "3D Conversion" filter aborted with the error message:
*** Error in ./gimp_make3D/*if/ *** [instance(500,375,1,3,0x103806000,non-shared)] CImg::warp() : Instance and specified relative warping field (1,1,1,2,0x10321d620) have different XYZ dimensions.

- the error message mentioned hereabove appears only when the output is NOT set to "depth map only";

- when the output is set to "depth map only", applying the filter to a 500x375 image results in a "depth map" produced with a size of 1x1 (one pixel only);

- when the output is set to "depth map only", applying the filter to a 4000x3000 image results in a "depth map" produced with a size of 4000x1 (one row of pixels, only).

In plain words, it seems that the image size is not recognized correctly and a depth map is built (strangely) with the size of 1x1 pixels or with weird or inconsistent sizes, which stops G'MIC and GIMP from applying the filter.

The problem is not related to the original size of the image, since it appears on a 4000x3000 pixels image, but also on a much smaller 500x375 image as well, exactly in the same way.

The bug disappears if, before applying the filter, the image is scaled (in GIMP>Image>Scale Image) to a different size. If the image is scaled so that the size of any side of the picture is approximately between 800 and 1500, the filter can be applied and works perfectly! These values (800 and 1500) are approximative, the exact boundary values have not been found yet, since weird things happen (some size values do not work if a dramatic scaling is made at once, but the same values often work - not always - if the scaling is made gradually, in small incremental or decremental steps).
Anyway, if an image scaling is made just before the filter is applied, this works perfectly, so the filter can be used after this preliminary operation. Please note that depth maps do not need to be made at very high resolution, so you don't need to use the full sized original image to make them.

It would be useful if any other Mac user tests this filter and tries to check whether the same problem appears in the same way also on his own Mac. If so, perhaps an automatic resizing of the image could be included in the filter in order to prevent the problem.
karo03 6 years ago
With Gimp 2.6.11 from GimponOSX and gmic_gimp (testing version) I cannot see anything you mentioned.
OS X 10.6.6 German

I tried X11 2.3.6 and XQuartz (X11) 2.6.0
Forest (GKweb.it) 6 years ago
Thank you for testing. Really, I don't know why it happens, here.
Everything is normal with the other filters.
tom.keil 6 years ago
@gentlemanbeggar: yes i can implement such "bottom/top" view. I will put it in when i make an update. I will wait a little and collect if there are more suggestions to change the filter.

In the meantime there is a simple workaround if you need this. You may use the output option "unalligned images" and then put you two images into a stereoscopic software like "StereoPhoto Maker" (very good freeware for this) and create here all types of stereoscopic views you like, even more exotic which i did not implement in the filter like these bottom/top or blue/yellow anaglyphes or animated GIF´s and so on.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Well, this topic has been slow since the last update, so I've been thinking about further improvements. One idea that popped into my head would be the option to displace in the opposite direction. (aka creating a right eye image of an image, opposed to a left)

Another one would be the option to use a left eye angle displacement and right eye angle displacement to be put together into a 3D format, instead of it being the original image with the left eye angle displacement. (Using Gimp's built in Displace filter, this process would be making 2 duplicates of the original, then applying a positive X amount of displacement, and then using a negative X amount of displacement on the other duplicate, and then overlapping/aligning them into a 3d format) This would allow for a more drastic 3D effect, without the original image becoming too distorted while being displaced in only one direction.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Here's a quick shot taken at one of the images you used as an example before. On this one I used 20.0 stereo base on 2 duplicates of the image, the second duplicate mirrored along with it's depth map. (very minimalist depth map) Then after outputting them unalligned, I got rid of the original image layers, then mirrored the right eye angle, and overlapped the layers into an anaglyph.

test by rabidcopy

(Basically an example of a conversion with my 2nd suggestion above.)

Edit: Wow, it just now hit me on what makes the this script a lot different than displace. In this script, dark areas mean that part of the image will move less, and white areas will move more. With displacement, the white areas move more in the specified direction of displacement, while the darker areas move more in the opposite direction, creating an unfavorable shearing effect. That only makes me appreciate this script more though. :)
tom.keil Posted 6 years ago. Edited by tom.keil (moderator) 6 years ago
@rabidcopy: good ideas indeed, thank you. I am currently working on an update. While the first update focused more on the creation of the depth map i will now implement a more flexible stereoscopic model like you suggest (the first model i used was a simplified one giving good stereoscopic impression an many images, but not on all:

You will have independend control over the far point deviation and the near point deviation with both positive and negative deviation. That will allow you to control where the stereoscopic perception begins and where it ends (with current version you just control the overall strength of the stereoscopic effect.
I am almost done with coding, but i still have to test and maybe finish a tutorial, so will be next week i assume. When you build your stereo image with settings for near point and far point in opposite directions you can create this "popout" effect where parts of your image virtually seem to jump out your screen.

You are right about the GIMP displacement filter, it moves areas lighter than neutral grey in one direction and darker areas in the opposite direction. You should set the darkest color of your depth map to neutral grey to avoid this. In G´MIC there are more possibilities to control this because you can adjust the warp field as you need it inside the whole 32bit floating point data range.

There will be also bidirectional warping as you suggest, you can also use this to render a whole series of different views for lenticular prints.

Maybe i manage to post few examples from testing during today.
tom.keil 6 years ago
few more test examples:

Quentin Massys Der Goldwaeger und seine Frau-3D

automatic 3D conversion with G´MIC

automatic 3D conversion with G´MIC

automatic 3D conversion with G´MIC
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Looking forward to the next update. :)

Thanks for the tip on the built-in Displace filter,(I really am clueless) even though I don't use it much, it seems that if I want to use a depth map with it, all I have to do is alter levels so the darkest color possible is 127 gray.

Thanks for taking my suggestions and putting them in.

Edit: Forgot to mention, as for the new 'popout' feature you're going to put in, I'm supposing its similar to the 3D elevation script with FOV. (been messing around with making images 3D in that now heh)
tom.keil 6 years ago
I updated the filter again, this update besides some improvements has now built in most of the user suggestions.

Since the filter became more complex over time i wrote a tutorial which is posted here: www.mediafire.com/?8d2jffrawfd4r7s and also linked to the new filter file. All new options are explained in the tutorial.

The new filter file is here: pastebin.com/9uyrMyd1

I thought to give good old pastebin a chance again, hope it will work without problems:
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
From seeing the new filter code, can't wait to try out the new features, but sadly pastebin has butchered the code as usual. Have to get rid of all the incorrect line-breaks before I can try it out.
rabidcopy 6 years ago
Oh wow, so much new stuff. And the depth map improving controls seem to give better results now. I like the autocrop and multi-direction displacement. Well to be fair, I like everything about this update. :)
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Alright, I'm a bit confused on how multi-directional rendering is intended to work.
I drew a line roughly down the middle of a blank image and used a near to far circle gradient. I'm not sure displacing in the opposite direction is working as it should in your script.

test by rabidcopy

Edit: Under further examination, it seems that with negative direction, instead of shifting the near-areas to the left, it wants to shift the far-areas to the left.
tom.keil 6 years ago
I uploaded the filter file again as a plain text file to avoid the inconvenience with pastebin:


@rabidcopy: yes, thank you, you are right, there is a bug in my negative warp field. While testing i did not notice because with small settings results looked like expected to me (i tested it mainly on GIF animations) so it shouid be useable at least in many cases.
Nethertheless i will try to find time to fix the bug today or tomorrow, thanks again.
tom.keil 6 years ago
I fixed the bug, here is the corrected file

as textfile: www.mediafire.com/?2qd265d6u2du6b4

and pastebin: pastebin.com/YRcMT0VP
rabidcopy 6 years ago
Thanks for the fix, Tom, but I can still feel that with bidirectional rendering enabled, negative warping is still iffy.

Without bidirectional rendering enabled, negative values do fine as to shifting near-areas as the other direction does. But with it enabled, the negative displacement, instead of shifting near-areas to the left as the positive value is doing, it shifts the far-areas to the right. While this is still technically correct, it makes for needing to manually align the right-eye angle result afterwords. Not a big problem though.
tom.keil 6 years ago
Hi rabidcopy, thank you very much for the quick observation. That was my fault, i noticed when storing the file i erased one "-" character and that was the result. :-(

Here is the correction:


Tested today and seems to do all it should do.
rabidcopy 6 years ago
Everything seems to work as it should now. :) Thanks for going the extra mile to provide fixes.
rabidcopy 6 years ago
It just now hit me on what could be a further output option in this. Animated sequences!

You could choose the number of frames for the animation, and the beginning and ending displacement values.


Starting near-point deviation = -20
Ending near-point deviation 20
Frames = 20 (each frame will go up 2 values in displacement, higher frame amounts would be smoother)

And there could be an option for 'ping-pong motion' so it will go back and forth from the starting and ending deviation.

This would be a nice feature to have. :)
tom.keil 6 years ago
yes i am thinking of that, basically that was one reason to make the output of unaligned images. I will look deeper in that.

I only made some "wiggle images" by now as simple GIF animation, and just with 2 or 3 frames, otherwise loading times are high on websites.

What i by now is these images look best if foreground and background move in opposite directions and a stable object is in the middle. I need to explore more if this is consistant with the way i create the depth maps for the other stereoscopic views.

In the meantime i did some bugfixes and minor improvements, the new filter comes automatic now if the external sources are enabled.

And all the documentation i collected on the support website
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
"What i by now is these images look best if foreground and background move in opposite directions and a stable object is in the middle."

Thinking about that, there's one issue I could see if my suggestion was put in.

If you put in 20 near-point deviation, you can put far-point deviation on -20 to keep the nearest object aligned. And similarly -20 near-point deviation can have 20 far-point deviation to keep the nearest object aligned.

Basically say a 11 frame -20 to 20 near-point deviation animation while keeping the near object aligned would be.
Near-point deviation: -20(starting) -16 -12 -8 -4 0 4 8 12 16 20(ending)
Far-point deviation: 20(starting) 16 12 8 4 0 -4 -8 -12 -16 -20(ending)

But the issue I have found is, by using bidirectional rendering, the same animation would require these values for each frame.
Near-point deviation: (starting)-20 -16 -12 -8 -4 0 4 8 12 16 20(ending)
Far-point deviation: -20 -16 -12 -8 -4 0 -4 -8 -12 -16 -20

I'm not sure if this (bug?) is present in the latest update, but with bidirectional rendering, the far-point deviation always has to be negative or it will align the opposite way.

Edit: Disregard the issue, I just now hit me that bidirectional rendering for animation sequences would really have no purpose. My brain's working slow today.
tom.keil 6 years ago
@rabidcopy: i have been playing around with the "wiggle" subject and it looks to me like i have to adopt the filter a little for this purpose.

I will try with another definition of the warp field for this purpose only, doing changes in both positive and negative x-directions the same time.

The operator far point deviation (which is working correct for "normal" stereoscopic views) does not serve the purpose for wiggle images. It emulates the pure distance between the two viewpoints without considering parallax (which is controlled by the near point deviation), means it a simple shift.
The general rules of stereoscopy seem not to apply in full on these wiggle images because they are not a true stereoscopic representation but just an "optical illusion".
I guess i will leave the output for this on two images only, majority of the applications will be animated GIF´s which mostly just use 2 frames due to loading time in the browser, and you anyway get 3 frames at least (original plus 2 renderings). If i put in rendering of many frames at once this will tend to be very slow plus you loose the preview. So i guess it might be better to work pair by pair, but if there is a high demand for such multi-frame feature i will code it in.

I came to another idea. What about converting video, i know G´MIC accepts AVI and MPEG input, but i have no idea what about preview then. If it works well to define a depth map by parameters for a scene at once this could be even used to convert complete Hollywood movies. Maybe anyone has ideas on this subject?
zonderr 6 years ago
I came to another idea. What about converting video, i know G´MIC accepts AVI and MPEG input, but i have no idea what about preview then. If it works well to define a depth map by parameters for a scene at once this could be even used to convert complete Hollywood movies. Maybe anyone has ideas on this subject?

I don't have time nowadays to follow this thread thoroughly (nor any other one btw), so my answer might seem stupid.

G'mic handles videos because it uses ffmpeg in background, and since you don't want to load every single images of a hollywood video in your memory, it is best to first dump every images in a directory and then to run a G'mic script on only 2 images at once.

Then you have an issue at scene cut, but it is probably not that difficult to deal with that.

But I don't know what happens if you handle video scene where the camera moves or if there is too much action.
tom.keil Posted 6 years ago. Edited by tom.keil (moderator) 6 years ago
I made the update to create frames for animation purposes. The new version is active, just refresh. The new source code and explanation of the new features in the tutorial are on the support site www.tkfilter.bplaced.net/index.html
rabidcopy 6 years ago
Ooh, the new update seems nice, thanks for adding in the feature to render multiple frames. :)

Though I'm guessing 'ping-pong' animations wouldn't of worked do to some scripting limitation. Nothing saving a copy of the layers, reversing the layer order, then importing the original frames won't fix.

I take it bidirectional rendering is not meant to be used with the multiple frame option, it gives a slightly choppy frame output of the animation first going one way, then the other way.

Other than that, everything seems to be working right. :)
tom.keil 6 years ago
You can use the bidirectional rendering for frames too. The output sequence is automatically sorted the way that your animation starts with the frame with the maximum deviation in one direction, moves stepwise over the original image to the frame with the largest distortion in the opposite direction. That should be the natural order for smooth transitions i guess?
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
I mean with bidirectional output enabled, it gives an animation in this order.

Positive to negative, then negative to positive. But, there's a large step in displacement thus making it choppy. (example: 10 8 6 4 2 0 -2 -10 -8 -6 -4 -2 0 2 then loops (these are guessed displacement steps in a 14-frame animation with this issue) )

I tried different frame amounts such as odd and evens, but it happens in each animation.

It seems buggy in a sense.
rabidcopy 6 years ago
Just a thought that ran through my head, would it be possible to implement a warp field that could do displacement on the Z axis?

AKA closer objects would get bigger and far away objects would stay the same/get smaller

Basically a warp field with similar properties to 3D Elevation's FOV parameter. One idea is using a manually created depth to convert an image to be orthographic by bringing far areas to be level with the 50% threshold of depth, and sending near areas back to also be level with the 50% threshold. (or just do depth-based panning forward/backward) I've played around with 3D Elevation's animation sequences and having a starting FOV value of 0 and an ending value of 90 does give an interesting effect.

Not exactly within the purpose of this script, but it would be interesting to have that method of displacement in the script as an option. Perhaps I can figure out how to make the warp field behave like that myself. =p

Thinking about it, wouldn't 3d images using Z-axis displacement give a 3d effect to an extent?
tom.keil Posted 6 years ago. Edited by tom.keil (moderator) 6 years ago
@rabidcopy: thank you checking, concerning the frames i suppose i found a bug, i could not reproduce exactly your findings but what I get in your example with 10 frames bidirectional is like:

-2,-4,-6,-8,-10,0,2,4,6,8,10 and what i want it to be is:


I think i can fix this tonight or tomorrow, i suppose the second order is the best for smooth animations.

Concerning your second idea if I understand well you want to create a kind of "popout illusion" by frames, lets say you image shows a round ball before even background and you want to become the ball bigger and bigger in each frame with unchanged background so the animation creates the illusion of the ball flying towards the viewer?

If that is right i do not think the -warp command is the right way to do it because you can not warp anything along a fictious "z-axis". Such does not exist and you really need a 3D object (as your data array) to manipulate something along a z-axis.

But maybe there is another way to create such illusion on framesets of 2D images:

First create the depth map of your image, the ball is white and the background is black. The copy the image layer and the depth map layer as many times as you want frames.

Next i would use the -zoom command to blow up your image and depth map layer. Do this stepwise for each frame a little bit more. After that split the the frame image into channels and multiply your zoomed depth map with the alpha channel of the zoomed image.

What you get now for each frame should be a visible ball (little bigger for each frame) on transparent background. Now copy the original image once for each frame again and combine them. You now should have the bigger ball on the original background for each frame.

If you play all frames as animation now you should have the illusion of the ball flying towards the viewer.

That would be completely different filter I would say, but also interesting effect, maybe you try to code it and if you get stuck the community will help :-)

My suggestion has two weaknesses, maybe there are ideas to straighten this out:
First i suppose the effect will only work on really isolated image parts, meand pure black and white depth maps, no greyscale.
Second i think it will only work to move objects forwards, not backwards because in such case your background would be needed to cloned over to cover unwanted (now bigger) parts of the original image.

The task is not easy, and these are just some crude ideas. Maybe someone who is more experienced than me in handling 3D data objects can point the direction to a smarter solution.

EDIT: it was just a small fix, updated filter version is already online. Just refresh and you have it.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
I think I may have find a work around to get this impossible z-axis displacement to work.

It uses Gimp's built in Displace and partially relies on the properties of values lower than 50% going in the opposite direction.

First, have your image and depth map in the layer stack.

Make a copy of the depth map.

Select exactly half(vertically cut down the horizontal center) of the depth map and invert it.

Gaussian blur the half-inverted depth map by 40 or so.

Now open displace with the original depth map selected in the layer stack.

Select the half inverted-blurred depth map as the displacement factor and make sure only X-displacement is toggled.

Enter a value like -20 and OK. (if you inverted the left side of the depth map, positive if the other half)

Now apply the same to the main image in the layer stack.

Go to the now displaced original depth map in the layer stack, and select exactly half of it. (horizontally cut down the vertical center) Invert it.

Now Gaussian blur it with the same settings as before.

Select the main image in the image stack and bring up Displace. Select the new blurred,horizontally-inverted depth map for Y-displacement and untoggle X.

Enter the value used before. (-20) Ok it.

Now the main image shall be displaced in a way that near objects have expanded to be larger, and far objects have shrunk a bit depending on the values used in your depth map.

Note: Keep the inverted depth map consistent on which half is inverted. Left half inverted = Top half inverted Right half inverted = Bottom half inverted. Or just make sure to adjust the displacement settings properly.
tom.keil 6 years ago
Shall we try to produce some samples when there is a little time to see where these ideas will lead to?
rabidcopy 6 years ago
I'll try to get an example up shortly. I have tried this process on a few images and it seems to work, it's just that the steps can get pretty tedious to perform.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Alright here's a quick test.

5551198270_fbbd467c4e by rabidcopy

right picture is sample

note: the seam running down the middle is from not going through the depth map layer steps and I just decided to make selections and displace each area by the depth map from the -displacement depth map topic.
tom.keil 6 years ago
looks like it moved forward, but very hard to judge if it can make a convincing animation.
Problem here on flickr is that without pro account it seems to be impossible to upload animations and see them in motion, tried it today and i failed.
rabidcopy 6 years ago
I just realized that in your latest update, there's been a change to how individual depth maps are interpreted. By looking at the depth map output while using a custom, it seems it now forces the contrast to make the lightest value 100% white and the darkest value to be 100% black. The thing that I'm noticing it breaks the depth layering and makes the shifting too dramatic. Now anything over a value of 10 in deviation gives undesirable results.

Although it does seem the animation bugs are gone. :)
tom.keil 6 years ago
Depth maps are always normalized within the filter, that needs to be done to calculate correct warp fields. But that should not have the effect you observed.

When you use a custom depth map still the sliders for all the image analyzers are active and you can use them to refine your custom depth map.
And if you have the output in such case on depth map only too also the gamma and color contrast sliders are effective.
Maybe it was a case of certain settings, i did not change it with the last version.
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
EDIT: Completely disregard my last posts claiming a bug/issue with using individual depth maps. After some more testing and such, it seems I just had a large phase of stupidity. I sincerely apologize for this mess. It turns out I was somehow completely neglecting the fact that I always use bi-directional rendering, and a displacement value of 20 without it enabled is obviously going to be a more dramatic shift seeing as bi-directional rendering divides the value and shifts in both direction.
tom.keil 6 years ago
The filter got another update with few improvements. It has now the "anti-ghosting" function to reduce ghosts in dark high contrast parts of the image like the video filter. This function turned out to be useful for making anaglyphs.

Second news is a new output possibility for lenticular prints. This comes as a separate filter named "Lenticular print" because in this way it can not only be used for lenticular prints from 2D to 3D conversions but also to make such lenticular images from normal stereo pairs and sequences or create other lenticular illusions. The filter needs two or more input images and can be adjusted to any type of lenticular foil available on the market.
tom.keil 6 years ago
After a long while of testing I have been able to provide some interesting new features for the filter.

The first improvement is that it comes now with new possibilities for the output of optimized anaglyphs. These output formats may lead to slight colour changes but they reduce retinal rivalry which is immanent to standard anaglyphs and can improve the viewing experience.for many 3D images. The factors for the colour channel computations were published by Eric Dubois. Optimized anaglyphs are available now in red/cyan and blue/yellow (Color code).

The second and more significant change is that the filter has now a routine for fully automatic depth detection without any user interaction. The new routine analyzes the geometry of the image as well as the objects and frequency distribution.
In the test series it found well matching depth maps in about 90% of the test cases. Test were done on selected images and on randomly selected image files.
Limits are mainly totally black or white areas of the image where is no information for depth analysis available. If these areas are too significant the depth map may contain unwanted holes.
But even in these problematic cases i was able in 100% of the tests to produce good and viewable stereoscopic images from the automatic depth estimation. The human brain seems to be capable to ignore smaller irregularities in stereoscopic images and still create a good 3D impression.
Special thanks to David for providing all these fine algebraic filters which made the depth estimation possible.

Here is an example how the filter results look:

automatic depth estimation from 2D image

The new version is online already, just press refresh as usual.
The automatic depth estimation is a subroutine which can be also called up seperate without using the 3D conversion. It is available under "Automatic depth estimation", you may use it if you only need the depth map.
(i plan to use the routine for other filters too, I have the idea of making a new DOF manipulator).
I would be happy if you share test results, in particular if you find highly problematic image examples so I can improve the filter further.
gentlemanbeggar 6 years ago
A DOF manipulator would be awesome. Your automatic depth map and my simple lens-blur might make a good starting point.
Ronounours 6 years ago
That looks awesome Tom.
lylejk 6 years ago
Wow Tom; that is some cool stuff. You really put G'MIC over the top with creating this preset. :)
rabidcopy Posted 6 years ago. Edited by rabidcopy (member) 6 years ago
Whoa, this is somewhat amazing, Tom. It gives very convincing results in most cases.. It must of been a nightmare coding this.

After trying this out a bit, I have to wonder. Would it be possible to somehow combine the geometry processing with the influence of a rough gradient depth map? Basically where the automatic detection makes work of what geometries belong on the depth layers of the gradient.

Edit: here's a little picture illustrating the concept.

Upoc by rabidcopy

gradient = gradient to be used for influence
white outlines = depiction of geometries detected
then using the outlines, the geometry is filled with the level of depth it starts on the gradient.
tom.keil 6 years ago
Thank you all, i will try to improve it further when I come to further ideas :-)

@rabidcopy: Yes you are right, my routine has a standard gradient included in this sense. This is what in CG research is commonly called the "gravity cue". It can be overwritten by the detected geometry fully or partly.
The filling of objects is not trivial, in opposite it is the most challenging part of the task. On a real photo you need to decide what is considered as object and what not, just think of having bush or rocks in the background of your image.
Did you make the test image with my routine? I know it still has weaknesses in particular in uniform color areas without any texture, luckily these are not so often occuring in real life photography.

The main point is, there is no defined mathematic solution for the determination of depth existing, so you need to consider numerous influence factors. These you need to blend together using weighting coefficents that you get good results on most pictures. And this really needs a lot of testing on completely different images and makes it time consuming. I have an idea already to improve the results in uniform colour areas but that will take some time because whenever you improve something for one image category you are in danger that you worsen your results on other image categories.
Forest (GKweb.it) Posted 6 years ago. Edited by Forest (GKweb.it) (member) 6 years ago
I hope you don't mind if I show here some examples that are very typical of my photos. I find these examples particularly difficult. I used all of them with the default settings "automatic depth estimation", output "Depth map only". (Tom, please feel free to use these images to test your filter, if you want.)







On the other hand, this is the excellent result I obtained some time ago with an older version of G'MIC on a landscape photo. I passed the depth map (obtained with the settings I show herebelow) into Focus Blur, then I obtained two images, one focused on the nearest object, the other focused on the farthest objects. This time, fantastic result! Please note the half-way mountains which appear correctly, just a little blurred, but not too much. Note also the clouds, correctly sharp or blurred in each case.

SETTINGS (with an older G'MIC version):
tom.keil 6 years ago
Hi Forest, thank you posting your examples, great. I will have some more time to analyze during the next week, just few general observations which might be helpful.

At first, closeups are not the easiest subjects for the fully automatic detection, in reality they have very limited depth, centimeters instead of maybe kilometers you find in landcapes.

What you got from the fully automatic detection looks not to bad for me, except the first one.
I think they all give quite good anaglyphs, i will test it out when there is a little time.
Maybe it needs little tweaking with the image analyzers on top.

The first image refelects a still existing problem area of fully automatic detection, the background has high saturation in red and magenta, which are drawn more in the foreground because in the vast majority of images these are not typical background colours.

For this image it is for sure better to choose one of the other presets in the scene selector which will fit better to this particular scene. I think landscape with very low depth control plus feature and local detail analyzer added should fit best.
(1 to 100 of 138 replies)
Groups Beta