Pages: 1 [2]   Go Down

Author Topic: "Focus stacking" from 1 image??  (Read 14859 times)

Hening Bettermann

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 945
    • landshape.net
Re: "Focus stacking" from 1 image??
« Reply #20 on: March 26, 2015, 04:22:12 pm »

After some fiddling around, I have found out that even if I convert the stacked RGB to 8 bit grayscale before trying the Bandpass filter, I get the Out of Memory message. I had overlooked that, because the alert window is covered by any new image window which is created.
If I use 8bit gray images, and export as tifs, I get a grayscale image, not just black. But regardless which parameters I use, the resulting images are all the same. Meaning the Bandpass Filter operation is not performed at all, due to memory problems.
So I think it is a problem of memory management, maybe specific for the Mac. When I get back home, I'll try it on Windows.
Regardless, Bart, I don't understand the conversions you recommend. Why the conversion from a 16 bit RGB TIF to a 32 bit grayscale image? Since these will be used as masks, even 8 bit may be enough?

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8914
Re: "Focus stacking" from 1 image??
« Reply #21 on: March 27, 2015, 05:33:38 am »

After some fiddling around, I have found out that even if I convert the stacked RGB to 8 bit grayscale before trying the Bandpass filter, I get the Out of Memory message. I had overlooked that, because the alert window is covered by any new image window which is created.

Sorry, I can't help with that Mac or machine specific issue.
 
Quote
Regardless, Bart, I don't understand the conversions you recommend. Why the conversion from a 16 bit RGB TIF to a 32 bit grayscale image? Since these will be used as masks, even 8 bit may be enough?

It's more of a safety measure, because Fourier Transforms can produce artifacts of their own if not done with enough numerical precision. So 16-bit/channel integer values as input may be okay, but I want to be sure that the subsequent processing is done at the highest precision that ImageJ can deliver. Since your goal is to produce masks, even 8-b/ch input may be adequate, as long as you don't intend to do other calculations in Fourier space (divisions by zero, e.g. for deconvolution, cause trouble). Band-pass filtering should probably be safe if implemented as multiplication.

For the generation of selections/masks, there are also lots of other tools available in ImageJ (e.g. Filters>Variance...), but that's getting a bit too involved in Digital Signal Processing of images for a quick explanation.

Maybe you are making things a bit too difficult for yourself. A good HDR application will automatically take care of Ghosting artifacts, or offer manual intervention in the process of stacking the exposure brackets.

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

Hening Bettermann

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 945
    • landshape.net
Re: "Focus stacking" from 1 image??
« Reply #22 on: March 27, 2015, 01:09:04 pm »

Hi Bart,

thank you for your reply.
Of course you can not do anything about the Mac.
I understand now the logic behind the conversion to 32 bit.

> For the generation of selections/masks, there are also lots of other tools available in ImageJ (e.g. Filters>Variance...), but that's getting a bit too involved in Digital Signal Processing of images for a quick explanation.

Hm- where can I read more about it? The ImageJ Help > Documentation only says
"29.11.9 Variance…Highlights edges in the image by replacing each pixel with the neighborhood variance."

> A good HDR application will automatically take care of Ghosting artifacts, or offer manual intervention in the process of stacking the exposure brackets.

Lumariver, my HDR app, takes care of ghosting artifacts to a good degree, if not 100%. But what is at stake here is the *focus* stacking, which I will try to work around.

> Maybe you are making things a bit too difficult for yourself.

Well - my intention is of course the opposite. Assume that a major part of the foliage in this image is moving, then try to manually retouch it in Helicon...

Thanks again - Hening.

Hening Bettermann

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 945
    • landshape.net
Re: "Focus stacking" from 1 image??
« Reply #23 on: March 31, 2015, 02:33:36 pm »

The RAM mystery is solved at last:
As the attached screen shot shows, I had not allocated 12 GB of RAM, but just 1.2... This is what happens if I have to deal with numbers - just not my thing... Sorry for bothering you with this.
So now I can run the bandpass filter. But the result looks like a luminance mask, not a sharpness selection. Is there a way to achieve what I want?
« Last Edit: April 01, 2015, 04:12:17 pm by Hening Bettermann »
Logged

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8914
Re: "Focus stacking" from 1 image??
« Reply #24 on: April 01, 2015, 04:30:12 am »

Quote
For the generation of selections/masks, there are also lots of other tools available in ImageJ (e.g. Filters>Variance...), but that's getting a bit too involved in Digital Signal Processing of images for a quick explanation.

Hm- where can I read more about it? The ImageJ Help > Documentation only says
"29.11.9 Variance…Highlights edges in the image by replacing each pixel with the neighborhood variance."

Well, if there is a lot of detail, then the local variance will be high. So that should give an indication of where the focus is high and the detail is fine and of high contrast. But it would be one step in a series towards creating a mask, depending on image content. Thresholding of images, and differences between images may need to be done to get the detail out, but it still won't solve the issue of detail displacement between slices. It would only offer a means to select detail in a single image. This is a separate thing.

Quote
Quote
A good HDR application will automatically take care of Ghosting artifacts, or offer manual intervention in the process of stacking the exposure brackets.


Lumariver, my HDR app, takes care of ghosting artifacts to a good degree, if not 100%. But what is at stake here is the *focus* stacking, which I will try to work around.

Yes, I understand. But the Focus stacking algorithms are based on one image being (locally) better focused than all others. When there are multiple candidates for the same image feature, then ghosting is likely to show up. Non-stationary subjects are not the prime candidates for focus-stacking, if you want to avoid a lot of manual intervention.

Occasionally it may help to divide the stacking procedure into multiple runs. One could e.g. try stacking the odd and the even  images from a sequence separately, thus skipping one each time, and thereby create a better separation between the level of focus of each slice. Then stack the two resulting stacked images. The best strategy depends a lot on the actual images, and pre-processing the images into spatial frequency band masked versions may also be an option, but it's not all that easy.

The cleaner the slices can separate focused layers of the scene by distance, the easier the stacking should be, but it doesn't help if each slice's detail has moved ... Maybe shooting with a slower shutterspeed will blur the movement enough for the branches and grass to blend, while the stationary parts of the image benefit from the enhanced DOF resolution.

Cheers,
Bart
« Last Edit: April 01, 2015, 04:38:10 am by BartvanderWolf »
Logged
== If you do what you did, you'll get what you got. ==

Bart_van_der_Wolf

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 8914
Re: "Focus stacking" from 1 image??
« Reply #25 on: April 01, 2015, 04:36:13 am »

The RAM mystery is solved at last:

Good!

Quote
So now I can run the bandpass filter. But the result looks like a luminance mask, not a sharpness selection. Is there a way to achieve what I want?

It's just a first step. You can now e.g. calculate a difference with a uniform gray layer, so the dark and light edges will all turn light, you can then threshold it, and blur it, and contrast adjust it, to fine-tune the selection mask.

Cheers,
Bart
Logged
== If you do what you did, you'll get what you got. ==

Hening Bettermann

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 945
    • landshape.net
Re: "Focus stacking" from 1 image??
« Reply #26 on: April 01, 2015, 04:24:32 pm »

Hi Bart

thank you for your extensive answer.

> it still won't solve the issue of detail displacement between slices. It would only offer a means to select detail in a single image. This is a separate thing.

And this is exactly what I have in mind. My idea is to work *around* the focus stacking, using the one image with the most important parts in focus, and then use "graduated deconvolution" on the other parts.

> It's just a first step. You can now e.g. calculate a difference with a uniform gray layer, so the dark and light edges will all turn light, you can then threshold it, and blur it, and contrast adjust it, to fine-tune the selection mask.

This sounds like I would need a more detailed recipe, which does not seem to exist.

Thanks again! - Hening.
« Last Edit: April 11, 2015, 02:40:52 pm by Hening Bettermann »
Logged

Hening Bettermann

  • Sr. Member
  • ****
  • Offline Offline
  • Posts: 945
    • landshape.net
Re: "Focus stacking" from 1 image??
« Reply #27 on: April 14, 2015, 04:42:28 pm »

There may be hope for a solution. Not for images of which you have only one frame. Rather for those which are shot with focus stacking in mind, but suffer from moving foliage or the like. And the depth of the subject must not be too large; in this case, the sharpening of the extreme slices would lead to artefacts.

Helicon Focus lets you export the depth map as gray images. These could be used as masks. However, they are based on the source images as aligned in HF, so they will not fit the genuine source image. HF also allows you to export the aligned source images, but they are reduced to 8 bit color depth. So if HF just would offer an option to export the original source images in an aligned state, but otherwise untreated, it might work.

I have tried to persuade Stas Yatzenko from HF, and he has promised to put this on their to-do list, without a date of course. So their may be hope ahead...

Good light!
Pages: 1 [2]   Go Up