It is usually done by using a computer program connected to a digital camera, that is programmed to take a sequence of photographs at different but equal distances from above (with the upper surface in focus) to the lowest part of the object. The computer then superimposes the photos, taking the best image for each part and putting them together. Such programs are available commercially, though you must have the equipment for the computer to control the changes between the photos.
Try it with the Focus Stacking using Helicon Focus Pro for making photo stacking pictures. You can try out this computer program for 30 days, by free download.
I have thus achieved very good results. See my newest contributions.
There a nice plugging for ImageJ from the Biomedical Imaging Group called Extended Depth of Field: http://bigwww.epfl.ch/demo/edf/
I do nothave much experience with it because I usually work with fluorescence and not with BF, but it looks a free nice alternative altough the Helicon Focus it is really impresive and not too expensive.