Focus stacking involves taking essentially the same photo several times but focusing first on the foreground, then the mid, then the farthest point on the subject. You can take as many shots as you like to “bracket” the image and get a sequence of shots that have the whole of the object in focus at some point in each photo. As you can see in the photo above.
It works best if you set the camera up on a tripod and take the series of photos using magnified LiveView and manually focusing on different parts of the subject. There are automated systems (software and hardware) and some cameras have focus bracketing built in (think of it as the focusing analogue of exposure bracketing, which lets you create high dynamic range (HDR) photos.
Once you have your set of focus-bracketed photos, you can then use a photo editor to blend them into a single composite image where pretty much all of the shot is in focus. The technique overcomes the very shallow depth-of-field you have with a small aperture when shooting taking close-ups. That said, the technique works to extend DoF for any type of photo.
Today’s subject is the beautifully patterned Angle Shades moth (who said moths were dull and grey?). I had it sat in a pot and perched that on an old patterned chair. If I could have persuaded it out of the pot without it flying away, you could have seen better just how well camouflaged this moth is against such William Morris style arts and crafts prints. In the wild, of course, it finds itself beautifully camouflaged among multicoloured and dappled foliage.