Focus Blending using Adobe Photoshop CS4

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Focus Blending using Adobe Photoshop CS4

Post by augusthouse »

Focus Blending using Adobe Photoshop CS4.

Let's begin to have a serious look at this. There are layer masks in there that can be manually adjusted. Non destructive individual layer masks!

http://www.photoshopuser.com/?page=cs4/ ... depthfield

Look for the depth-of-field section on the link below.

http://photoshopnews.com/feature-storie ... n-evening/

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

rjlittlefield
Site Admin
Posts: 23597
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

Craig,

I'll be interested to hear how well this works out.

I don't have CS4 yet, but what I see in the screenshots and video presentations looks an awful lot like the strategy I played with about 4 years ago.

See this article, especially the images about 1/3 of the way down the page:

Image Image
hard masks, exclusive ........ blended masks, nested stack

What I discovered at the time was that the layer masks were very helpful for handling background, but pretty cumbersome for retouching any stacking artifacts.

The difficulty was in the semantics of Photoshop's layer masks, namely that painting white ("show these pixels") in any mask has no effect if any masks in higher layers are also white at the same pixel positions. So in order to expose detail in a low layer that was originally exposed in a high layer, it was necessary to not only paint white in the desired layer, but also to paint black in all higher layers at corresponding positions. This was tedious, to say the least.

It may be that Photoshop has added more tools for mask editing. A brush that simultaneously painted white in one layer and black in all others would have been very helpful.

There are some other issues as well, particularly with memory and scratch disk. It did not take me long to discover that Photoshop's user interface and performance bogged down rather badly when confronted with a stack of 55 layers. Even at 8 bits RGB and 6.3 Mpixels, that was already 1.4 GB of storage. Scaling up to 100 frames at 16 bits RGB at 12 Mpixels gives something more like 9 GB.

Despite these concerns, I'm pleased to see this capability included in Photoshop. It will expose more people to the concept of focus blending, which can only expand the market for more specialized tools that do a better job on big problems.

Switching subjects, I was intrigued to notice at your second link that "Content Aware Scaling" has already made it into CS4. That's very quick, for a technique that was first published less than 2 years ago!

--Rik

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Post by elf »

CS4 is definitely a memory hog. The 36 images I stacked in this image, http://www.photomacrography.net/forum/v ... 26764c7edd, created a 2.1gb file just for the aligned images. It wasn't able to blend the images until I closed and restarted PS. I have another 70+ images that could be added to this, but it couldn't handle 100 images in one pass.

I haven't tried stacks that have lots of fine detail or where there isn't a smooth transition from the foreground to the background.

It's kind of hard to tell from the mask thumbnails exactly why it chose some of the pixels. I would expect each layer's masked areas to be next to the underlying layer's masked areas. The masks are all hard edged as well, so if you don't chose to blend colors and tones, you may see the blend lines.

Image

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

There are some other examples beginning to appear on the web, so I will list another one at the link below.

http://www.aravind.ca/Tutorials?edof_cs4

(I ran the 5 images from this example through HF, CZP, TuFuse and PhotoAcute to compare the end results with that of the CS4 image. A very simple comparison with a straight-forward subject; but I know which end result I prefer).

There is a pattern emerging.

As elf's experience has indicated, it is probably best to approach the CS4 stacking in stages rather than attempting a deep stack in one pass.

My quote from Bob's post here
However, with PS CS4 we still have all the original pixels available if required (non-destructive), and a host of other Photoshop tools such as layer blending modes to work with in addition to its stacking abilities.

Also, it does not appear that there are other processes being forced upon the image such as program generated noise reduction, contrast and vibrancy shifts and detail smudging.

We can move around and between the layers rather than being restricted to a merged composite.
and here is another review....
http://www.dimagemaker.com/article.php?articleID=1483

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Post by elf »

Getting an acceptable large size image out of CS4 is going to take a lot of manual work. Here's a blend of 10 images (cropped) that shows the problem.

Image

As you can see nothing in this part of the image should have been selected from the bottom image in the stack. In addition, only the masked areas have been color blended, so modifying the mask will leave an even more unsightly blemish.

The left edge of the leg is also clearly better focused in the frame that should have been selected than in the final image.

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

There is nothing at the following link that we didn't already know about; but it's interesting nonetheless; though rather brief.

http://pacific.adobe.acrobat.com/p27669714/

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

P_T
Posts: 461
Joined: Sat Jul 19, 2008 1:13 am
Location: Sydney, Australia

Post by P_T »

Looks like CS4 workflow can be both its strength and weakness at the same time. Keeping all the images for a non-destructive workflow sure does take a LOT of RAM and HDD space.

I think they've only added focus stacking because this is the first PS that runs 64bit natively so you can use more than the usual 2~3GB RAM that people normally use in 32bit. I think the Mac version is still running on 32bit though.

Solution? get a beasty PC. :D

rjlittlefield
Site Admin
Posts: 23597
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

I am puzzled by this term "non-destructive workflow".

In Helicon Focus Pro, the editing process appears to involve a working image that is initialized to whatever the algorithm produced as output.
Starting with the copy of the computed image, there are three basic editing operations:
1. Copy pixels from an aligned source image into the working image ("Copy source").
2. Copy pixels from the computed image into the working image ("Erase changes").
3. Copy pixels from somewhere else in the working image ("Clone").

As one edits, it is only the working copy that gets modified. None of the original pixels become unavailable, including the pixels that were originally computed by the algorithm.

In contrast (as I understand the discussion, not yet having CS4), what you do to edit in Photoshop is to modify the masks.

We normally think of masks as being a powerful way to do nondestructive editing of pixels, but in this case it is the masks themselves that comprise the valuable output. As soon as you edit one of those masks, you have destroyed part of the stacking algorithm's output, and there is no way to get it back short of invoking History.

To my eye, it appears that the Photoshop approach of editing the masks is more destructive than Helicon's, not less.

Am I missing something here? What is it that you folks mean by "non-destructive"?

--Rik

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

Rik,

The pixels are 'masked' not erased. They are still available in the individual 'layers' of the final CS4 image = non-destructive.

The fact that we can edit the masks and individual layers in CS4 is a definite advantage (not to mention having access to the channels).

It means that we are not restricted to the output of what are at present inadequate stacking algorithms which have long since lost the beauty of simplicity. They contain errors and those errors are being multiplied degree by degree ad infinitum.

What is a pixel? Is it on or off?. To what extent can we interogate or what criteria can we apply to an individual pixel in order to determine its 'focus' state, an individual pixel, not an average of a pixel and those surrounding it? The computing power to do this is available.

Considering another benefit of aligned layers, and the interogation mentioned in the previous paragraph, let's say a stack of 10 layers, for eg. We could compare pixels - the same pixel on the 10 individual layers and retain the pixel that conforms to the requirements of an accurate algorithm and mask the non-conforming pixels whilst also retaining the individual layers themselves.

In theory, this may be what current stacking software is attempting to do; but it is failing and in an attempt to counteract those failings it is presenting us with predictable visual errors that in themselves require considerable manual editing to correct.

So let's consider what I define as an accurate algorithm...

How does an AF lens work? How does a piece of glass and some electronics know or determine when a subject is in focus? It's not magic - what is the algorithm used in that instance? This may seem to contradict my earlier question regarding 'comparisons' for the sake of determining focus; but the AF does return an acceptable and accurate result.

Craig

* overlapping posts and typo
Last edited by augusthouse on Wed Nov 05, 2008 4:17 pm, edited 3 times in total.
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

rjlittlefield
Site Admin
Posts: 23597
Joined: Tue Aug 01, 2006 8:34 am
Location: Richland, Washington State, USA
Contact:

Post by rjlittlefield »

Craig,

Hhmm... Let me try again.

No pixels are erased using the Helicon Focus approach either. They are still available in the individual source images. The output of the algorithm is also preserved (until program exit), no matter how much editing you do. Helicon's "Copy source" is equivalent to editing a visibility mask, while still being able to restore the visibility mask to its original state with "Erase changes".

I believe I understand the Photoshop approach, and I'm quite sure I understand the Helicon approach.

What I don't understand is your apparent implication that tools other than Photoshop use "destructive" approaches. They don't, at least in the case of Helicon.

There is one annoying limitation with Helicon, namely that it does not provide a good workflow for editing in multiple sessions. But that doesn't seem to be what you're talking about. Or is it?
How does an AF lens work? How does a piece of glass and some electronics know or determine when a subject is in focus? It's not magic - what is the algorithm used in that instance?
You're gonna hate this. Most cameras use the same algorithm used by stacking software -- maximize the contrast in a neighborhood surrounding the autofocus point.

--Rik

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Post by elf »

The bad news is CS4 autoblending is not non-destructive (a better way to say this would be CS4 is non-reversable when it does the blend). The worst part is it only modifies the unmasked part of the image when color blending. This means you cannot change the mask without also doing color change on the new mask.

The good news is the logic is embedded in a scripts, which can be modified by the end user. Anyone have a couple of hundred extra hours to rewrite the scripts so they are non-destructive :smt024

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

elf,

When you get a moment could you 'uncheck' Seamless Tones and Colors and upload a pixel crop. I can't find any info regarding that feature and stacking; so I'm wondering what impact it has on the result?

If all else fails - just start pressing buttons....

The details in your last post pretty much deflated my hopeful expectations regarding CS4 stacking.

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

Rik,

Yes, yes and yes to your last post. It does look like they are using the method that you suspected.


Rik wrote:
You're gonna hate this. Most cameras use the same algorithm used by stacking software -- maximize the contrast in a neighborhood surrounding the autofocus point
Can I reword that quote?

Craig wrote:
You're gonna hate this. Most stacking software attempts to use the same algorithm used by cameras -- maximize the contrast in a neighborhood surrounding a selected reference point
Wake me when we get there.

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

elf
Posts: 1416
Joined: Sun Nov 18, 2007 12:10 pm

Post by elf »

While not exactly what you requested, here's two stacks that demonstrate the masking and color blending problem. The stack contains two images (of a much larger stack) where the bottom image has been artificially darkened to show the effect.

This image is the stack without color blending:
Image
This image could be fixed by simply adding an adjustment layer and tweaking it until the full image looked good.

And this image shows the same two images stacked with color blended, but with the mask disabled so only the top image is visible.
Image
With the mask enabled it is actually blended pretty well. Editing this image will be a nightmare because the original image has been modified only in the masked areas. I'm getting a migraine just thinking about getting a 100 image stack to look good :smt027

augusthouse
Posts: 1195
Joined: Sat Sep 16, 2006 1:39 am
Location: New South Wales Australia

Post by augusthouse »

Thanks for uploading the images elf. Appreciated!

Craig
To use a classic quote from 'Antz' - "I almost know exactly what I'm doing!"

Post Reply Previous topicNext topic