This plugin generates a depthmap out of two stereoscopic images.
Install it with:
$ gimptool-2.0 --install elsamuko-depthmap.c
Then open the two images as layers in GIMP and start the plugin under Filters -> Map -> Depthmap.
The two layers need to be identical in size.
The algorithm takes a pixel of the first layer plus its surrounding area and searches on the second layer for the best match.
First option changes the horizontal parallax size the algorithm searches for a match. Try smaller values first, it's getting slow with big ones. Second option is the radius of the tile, which is compared to the tiles of the other image in the search area. Start here with small values too.
This algorithm can't interpret the image content, so the results will be 'ugly' in digital noisy or under- or overexposed areas. Just try out.
The depthmap can be used then e.g. in another plugin like focus blur to simulate a bigger aperture.
Examples here and here:
The two layers conjoined to an anaglyph:
Update1: Gained some speed by searching on the left side only for a matching pattern. The backgrounds of the two pictures have to be aligned.
Update2: Complete rewrite with OpenCV and preview included. Extract the zip folder and type "make", the code needs the libcv-dev and the libcvaux-dev packet.
For all scripts together, go here.