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.
Examples:
http://www.flickr.com/photos/28653536@N07/2928731453/
http://www.flickr.com/photos/28653536@N07/2922989392/
The two layers (http://www.flickr.com/photos/85451010@N00/3875966714/):

The depthmap:

The depthmap can be used then e.g. in another plugin like focus blur to simulate a bigger aperture and more beautiful bokeh:
http://sudakyo.hp.infoseek.co.jp/gimp/fblur/focusblur_e.html
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 packet. Example here: http://sites.google.com/site/elsamuko/c-cpp/opencv-depthmap
For all my scripts together, go here:
http://sites.google.com/site/elsamuko/gimp
| Attachment | Size |
|---|---|
| elsamuko-depthmap.c | 12.61 KB |
| elsamuko-depthmap-cv.zip | 6.39 KB |
Comments
needs makefile
The c source code doesn't compile without some help. :-)
On my Fedora11, I had to set 8 include directories and 3 libraries to link.
Something like this works for a Makefile:
%<----------------------------------------
CFLAGS=\
-I /usr/include/gimp-2.0 \
-I /usr/include/glib-2.0 \
-I /usr/lib64/glib-2.0/include/ \
-I /usr/include/gtk-2.0/ \
-I /usr/include/cairo/ \
-I /usr/include/pango-1.0/ \
-I /usr/lib64/gtk-2.0/include/ \
-I /usr/include/atk-1.0/
LDLIBS=\
-lgimp-2.0 \
-lgimpui-2.0 \
-lgtk-x11-2.0 \
elsamuko-depthmap_0: elsamuko-depthmap_0.c
gcc $(CFLAGS) $(LDLIBS) -o $@ $^
%<----------------------------------------
(You will have to re-insert a TAB at the beginning of that last gcc line.)
~jim
gimptool
That's why I recommend
$ gimptool-2.0 --install elsamuko-depthmap.c
to install that plugin.
Depthmap Generator Plugin for GIMP 2.4,- windows xp-vista
Always got error at the very last of the processing
I get a gimp 2.6.10 installed on my pc. And I download this and try to use it to get a depth map. But it shows an error. I do not know why.
I open two images with the same size as layers.
Could you help me ?
By the way, I'm using winXP.
Thanks a lot