Pardon my ignorance of Photo Stacking but did this process work because the Before Photo (engine only) was in great focus and the background photo was slightly blurry that the computer selected the scenery to be replaced by the in-focus engine? Did you have to tell the computer to replace the white wall, electric cords, and desktop?
Would you also list the software programs that you used?
This was the setup. Canon 1Dx, Speedlight 550ex x 2 (slave on right with diffuser, and a 28-70 mm f2.8 L zoom lens. I took a series of photos with various points of focus. (24 images) shot at f5.6 at 1/125 sec with the two flashes on TTL auto. I did not use an extension tube with this lens because the focus range which can be obtained is very limited once you start using macro extension tubes and this engine is about 18 inches long. (I can do much higher mag with the Lens at 28 mm and two extension tubes, at about 1 to 1.3 mag which is not bad for a nondedicated macro lens setup.)
The photos are then taken into Lightroom and onto Photoshop as layers. Then Photoshop can auto align all the images (they are pretty much aligned since I used a remote trigger and was very careful not to move the camera.) Once aligned you then use the Auto Blend Layers feature and Photoshop will generate masks for each layer to mask out the areas that are not in focus and keep the areas of each layer which are in focus. The result is a sharp photo with augmented depth of field which you would not be able to capture even if shooting at f32 (smaller aperture of this particular lens)
I added the background from a shot from my front yard from a few years ago, just a quick gag for my kids to see.
You are correct the background image is not sharp, it was actually from a series of images I took at 200 mm at f5.0 to capture this photo of my dog, so yes shallow depth of field but the dog is in sharp focus.
I kind of stumbled on Focus Stacking when I was trying to learn about the Stacking used for Astrophotography since a fried of mine is very into that. With that kind of stacking it is a similar idea but all the images are at the same focus point, and you are using the technique to eliminate atmospheric interference (clouds moving etc) and sensor Noise (electronic noise that is inherent to any electronic device). If you read about that it's very interesting. Those crazy sharp moon images you see are done by average Joes with average budgets and great technique.
The other neat thing about focus stacking is that it will generate a picture that you can keep zooming into and still see details, just like in the movies where they take a terrible video image and zoom in to read the license plate (only in the movies)! The other way to get great depth of field is to use a pinhole camera, but then you need really bright lights -- much easier to focus stack.
WARNING! THIS PURSUIT WILL BECOME HIGHLY ADDICTIVE!
I have only used CombineZM and ZP versions and have had modestly good results. With CZP, I found that it really helps to minimize the border 'waste' or 'loss' by ensuring the same focus point from image-to-image. In this image, I only took four exposures, each with the same aim-point, but with focus distances of about 12", 17", 24" and infinity (the latter to capture the trees across the road just past the diorama and to also capture the field and glacier beyond).
This image, all indoors on a layout that was dismantled eight years ago, I used seven different exposures. I found that one should concentrate the density of exposures in the near-ground when imaging models because of the relative focus problems nearest the lens. And, I used macro for at least the first two exposures, sometimes three or four.