Focus-stacking and halos around foreground objects

Optical microscopes + digital photography
Post Reply
User avatar
PhilS
Posts: 36
Joined: 12.10.2020 21:41

Focus-stacking and halos around foreground objects

Post by PhilS »

Earlier posts are in the long thread at
viewtopic.php?t=11152

In many focus-stacked photos, there are halos of out-of-focus pixels around the edges of nearby objects. I have found some ways to deal with this problem that may be useful to others.

First, the cause:

Images that are focused on the foreground have out-of-focus pixels where the background is, including the area adjacent to the foreground in the image.

Images that are focused on the background have out-of-focus pixels where the foreground is. Since the foreground is out of focus, each point of the foreground is spread out on the sensor. Each object point is spread into the “circle of confusion.” In particular, the edge of the foreground spreads out, and blocks the part of the background that is nearest to the foreground in the image.

Consider the pixels that are in the background that are adjacent to the foreground in the image. In any of the the foreground images, they are out of focus. In any of the background images, they are obscured by the fuzzy foreground edge. There are no images with in-focus pixels in the background that are adjacent to the foreground in the image — Neither nearby images nor far images have any pixels there in focus. That’s the halo. This is a lens/physics problem. It is not directly fixable with either the camera or software.

Now, some partial solutions. None is perfect, but all help.

1. Copy and paste from nearby background to the halo. If you can avoid obvious duplication, this often helps. The rubber-stamp tool works well.

2. Use the healing brush on the halo. This changes the halo to something like the nearby pixels.

3. Select the halo with lasso tools, and use Photoshop’s generative fill command to use nearby background pixels to generate the filling-in material.

4. Some people have had some success with using HeliconFocus’s Method C and changing the radius with Method B. I have not explored these much. If someone does, please post your findings on this forum

My newest idea — A closed-down aperture will get more pixels in focus than a wide-open aperture. However, the closed-down image will be less sharp due to diffraction*.

A background image in a small-aperture shot has a smaller out-of-focus foreground than a big-aperture shot, since everything is more in focus with the small aperture. Use pixels outside of the smaller halo of the small-aperture image to fix some pixels inside the larger halo of the large-aperture image.

5. The newest idea:

Do a focus-stacking procedure with the usual wide aperture. I use f/8. Without moving the camera, do a focus-stacking procedure with a closed-down aperture. I use f/32. Make both composites, and name one f/8-something and the other f/32-something. Copy the f/32 image and paste it onto the f8 image as a new layer**. Make a mask on the new layer, and make the mask black. You will now see just the f/8 images.

Use a large magnification of the image. Wherever there’s a halo, paint the f/32 layer mask with a small white brush. This will work best on the outer part of the halo. You can go back and forth with white and black brushes to refine the painting.

You’ll get some improvement in the halos. Perhaps enough to make the halos insignificant. Perhaps a good enough improvement to make the first three procedures easier to do.

Let me know if this makes sense. Let me know if you try it, and what you find out.

I did a test image of a favorite shell to test out and demonstrate these ideas. I did not fix all the halos, since this is just a test image. I marked a few areas for you to examine. I’ll also attach the final finished image of this shell for your amusement or interest. Note that the full-size image of each raw shot is about 49” X 35” at 300 ppi. When the images are enlarged to full size, the flaws jump out. One obvious solution to all the halo problems is to print small. :-)

Conclusions:

The diffraction effects are massive at full-size printing.
Using the f/32 image for fixing some of the halos works ok. It’s a start, and not too onerous. Worth doing for important images.

List of images with a caveat: These are for for demonstration purposes only. Not every halo is fixed as well as possible.
NOTE: This forum only allowed three image be uploaded into this message. I've put all the images in a dropbox folder in the next message in this thread.

1 f/8 composite (143 original images)
2 f/32 composite (37 original images)
3 f/8 and f/32 layered together with f/32 image masked in at halos
4 f/8 and f/32 layered together with f/32 image masked in at halos with annotations about the detail photos

To show the diffraction effects:
5 Detail of the f/8 image
6 the same detail of the f/32 image

To show benefit of the f/8 and f/32 layering and masking.

7 Detail at f/8
8 Detail at f/32
9 Detail using some of the f/32 image to cover some of the f/8 image

10 Shell montage using eight images of this same shell — I printed it on paper at about 60”X30”

*Diffraction explanation: Light bends around objects, in particular around the edge of the opening of the the lens. With a wide-open lens, a small percentage of the light going through the lens passes close to the edge of the lens opening — Diffraction is minimal. With a tiny aperture, a high percentage of the light passes close to the edge, so there is lots of diffraction. In the extreme of a pinhole lens (perhaps f/100), everything is in focus, but everything is fuzzy.

** You make have to make a curves layer with the new image layer as a clipping path to adjust the exposure of the new layer to make it match the original image.
Attachments
3 f8 and f32 using f32 image to fill in all halos.jpg
(1.62 MiB) Not downloaded yet
2 f32 full image.jpg
(1.09 MiB) Not downloaded yet
1 f8 full image.jpg
(1.63 MiB) Not downloaded yet
Last edited by PhilS on 26.10.2024 16:40, edited 3 times in total.
Post Reply