Zerene Stacker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
stacker:docs:tutorials:tutorial003 [2012/11/18 01:26]
rjlittlefield [How DMap Works On The Inside]
stacker:docs:tutorials:tutorial003 [2019/06/02 14:10]
rjlittlefield Added "How to save a Depth Map Image"
Line 65: Line 65:
 Now we're talking again about normal operations. Now we're talking again about normal operations.
  
-In addition to the contrast threshold setting, DMap is controlled by a couple of other "​radius"​ parameters: Estimation Radius and Smoothing Radius. ​ Roughly speaking, Estimation Radius controls the size of detail that DMap considers when deciding which source image is in focus, and Smoothing Radius controls how quickly DMap will switch from one source image to another. ​+In addition to the contrast threshold setting, DMap is controlled by a couple of other "​radius"​ parameters: Estimation Radius and Smoothing Radius.  These controls are located in Options > Preferences > DMap Settings.  Roughly speaking, Estimation Radius controls the size of detail that DMap considers when deciding which source image is in focus, and Smoothing Radius controls how quickly DMap will switch from one source image to another.  As a matter of practice, it works well to just set Smoothing Radius equal to half the Estimation Radius. ​ That's the default setting, so we won't talk further about Smoothing Radius.
  
 Subjects with simple structure and no fine detail will work best with large radius settings, while subjects with complex structure and lots of fine detail will work best with small settings. Subjects with simple structure and no fine detail will work best with large radius settings, while subjects with complex structure and lots of fine detail will work best with small settings.
Line 88: Line 88:
 In practice, this simple concept needs some refinement to work well.  There are two main issues: In practice, this simple concept needs some refinement to work well.  There are two main issues:
  
-  - It turns out that there'​s no way to determine how well an image is focused by looking at just one pixel -- the software has to look at nearby pixels also.  Estimation Radius controls the definition of "​nearby"​. +  - It turns out that there'​s no way to determine how well an image is focused by looking at just one pixel -- the software has to look at nearby pixels also.  Estimation Radius controls the definition of "​nearby"​. ​\\ \\ 
-  - Most scenes have some areas where there is not enough detail to tell reliably which input image has the best focus. ​ Those areas have to be identified so that the proper image to use can be determined from other information. ​ In Zerene Stacker, this identification is carried out mostly by using the "​contrast threshold"​. ​ Pixel positions that contain only low contrast information are less trustworthy to determine focus, because the calculation gets disturbed by random pixel noise and by out-of-focus blurs from nearby strong edges. ​ By setting the threshold, you use your human judgment to specify which locations can be trusted and which cannot. ​ At locations that cannot be trusted, DMap ignores its estimate of depth based on image content, and instead switches to a different scheme that bases the estimate on surrounding pixel positions that can be trusted. ​ In the terminology that we used earlier, the locations that can be trusted are where you care about detail, and the locations that cannot be trusted are where you prefer smooth gradations.+  - Most scenes have some areas where there is not enough detail to tell reliably which input image has the best focus. ​ Those areas have to be identified so that the proper image to use can be determined from other information. ​ In Zerene Stacker, this identification is carried out mostly by using the "​contrast threshold" ​slider.  Pixel positions that contain only low contrast information are less trustworthy to determine focus, because the calculation gets disturbed by random pixel noise and by out-of-focus blurs from nearby strong edges. ​ By setting the threshold, you use your human judgment to specify which locations can be trusted and which cannot. ​ At locations that cannot be trusted, DMap ignores its estimate of depth based on image content, and instead switches to a different scheme that bases the estimate on surrounding pixel positions that can be trusted. ​ In the terminology that we used earlier, the locations that can be trusted are described as being where you care about detail, and the locations that cannot be trusted are described as being where you prefer smooth gradations.  There'​s only one mechanism, but it can be used for two different purposes -- either to emphasize smooth gradations or to help guide the software to make proper decisions for the images at hand.
  
 The final refinement is "​smoothing"​. ​ It turns out that even with both of the above refinements,​ there is still a bit of noise in the estimates of which image has the best focus. ​ To reduce this error, a weighted average is taken of estimates at nearby pixel positions. ​ Again, there'​s a numeric definition of "​nearby",​ and this time it's determined by Smoothing Radius. The final refinement is "​smoothing"​. ​ It turns out that even with both of the above refinements,​ there is still a bit of noise in the estimates of which image has the best focus. ​ To reduce this error, a weighted average is taken of estimates at nearby pixel positions. ​ Again, there'​s a numeric definition of "​nearby",​ and this time it's determined by Smoothing Radius.
  
-In the end, what DMap ends up computing is a sort of “Depth Map” ---  hence the name.  The word "​depth"​ refers to distance from the camera, or more precisely, image position within the stack. ​ The word "​map"​ describes a sort of virtual surface that hugs tightly to the focused subject where it can, and varies smoothly elsewhere. ​ You can think of the depth map as being similar to a thin rubber sheet that gets pressed down through the stack of input images. ​ At each pixel position, the sheet sticks tightly to the strongest detail ​that is above the contrast threshold.  At other pixel positions, the sheet stretches so as to make smooth gradations between the positions where it is stuck to detail. ​ Then as a final step, the sheet is allowed to come unstuck just a little bit to make it smoother. ​ After the rubber sheet has come to its final position, the result image is computed by choosing pixels from input images based on the rubber sheet’s position. ​ Where the sheet is firmly attached to one input image, the output pixel values are exactly those of that one image; where the sheet lies between two input images, the output pixel values are a weighted average of those two images.+In the end, what DMap ends up computing is a sort of “Depth Map” ---  hence the name.  The word "​depth"​ refers to distance from the camera, or more precisely, image position within the stack. ​ The word "​map"​ describes a sort of virtual surface that hugs tightly to the focused subject where it can, and varies smoothly elsewhere. ​ You can think of the depth map as being similar to a thin rubber sheet that gets pressed down through the stack of input images. ​ At each pixel position ​where some image contains contrast above the threshold, the sheet sticks tightly to the image with the strongest detail. ​ At other pixel positions, the sheet stretches so as to make smooth gradations between the positions where it is stuck to detail. ​ Then as a final step, the sheet is allowed to come unstuck just a little bit to make it smoother. ​ After the rubber sheet has come to its final position, the result image is computed by choosing pixels from input images based on the rubber sheet’s position. ​ Where the sheet is firmly attached to one input image, the output pixel values are exactly those of that one image; where the sheet lies between two input images, the output pixel values are a weighted average of those two images.
  
 Now that you understand how DMap works, you can probably understand why it produces the results that it does.  What you want is for the depth map to accurately track the subject where you care about detail, and to vary smoothly in detail-free areas where you care more about smooth gradations. ​ If the contrast threshold is too low, then in areas where there is no focused detail the software ends up getting misled by noise and the depth map is liable to flail wildly between several images. ​ That’s what produces the crazy halos and blotches. ​ If the input images are out of order, then it’s almost guaranteed to do that.  If the estimation radius is too big, then the software can't track edges very well, and if it's too small, again it's more likely to get misled by noise. ​ Now that you understand how DMap works, you can probably understand why it produces the results that it does.  What you want is for the depth map to accurately track the subject where you care about detail, and to vary smoothly in detail-free areas where you care more about smooth gradations. ​ If the contrast threshold is too low, then in areas where there is no focused detail the software ends up getting misled by noise and the depth map is liable to flail wildly between several images. ​ That’s what produces the crazy halos and blotches. ​ If the input images are out of order, then it’s almost guaranteed to do that.  If the estimation radius is too big, then the software can't track edges very well, and if it's too small, again it's more likely to get misled by noise. ​
Line 128: Line 128:
  
 At lower magnifications,​ this situation is likely to occur when the subject is both deep and complicated,​ such as shooting the interior of a bush that has many overlapping branches. At lower magnifications,​ this situation is likely to occur when the subject is both deep and complicated,​ such as shooting the interior of a bush that has many overlapping branches.
 +
 +===== How to save a Depth Map Image =====
 +
 +Normally the depth map that is computed internally by DMap is used only to construct the DMap output image and is not retained after the output image is constructed.
 +
 +However, you can optionally save the depth map by setting a couple of parameters __before__ you run a DMap operation, and then the DMap operation exports the depth map as a side effect.
 +
 +To make the settings, go to Options > Preferences > DMap Settings, then scroll down the panel so that you can see the checkbox labeled "Save depth map"​. ​ Click the box to put a checkmark in it.  Then specify a folder to contain the depth map, either by typing its full path such as C:​\ImageFiles\ZSDepthMaps or by using the Choose button and then navigating to the desired folder.  ​
 +
 +It looks like this:
 +{{:​stacker:​docs:​tutorials:​tutorial003:​savedepthmapcontrols.jpg}}
 +
 +With this setting made, click OK to close the Preferences dialog.
 +
 +Every time you run DMap after making this setting, the corresponding depth map will be saved as an image file in the specified folder. ​ The file name is same as the output image, with "​_depthmap"​ added to it.  The file format is 16-bit TIFF, nominally RGB but with all components equal to the same value. ​ The pixel values range from 0 to 65535, corresponding to image numbers from 1 to N in the list of "Input Files" after stacking. ​ (Photoshop will show these pixel values as 0 to 255, following its 8-bit convention.) ​ To stop saving depth maps, just un-check the option.
 +
 +Note that "Save depth map" is a Pro-only option, which means that it requires Prosumer or Professional Edition to be used beyond a 30-day trial period. ​ There will be a popup message reminding you of this, the first time that you select the option.
  
 ===== Summary ===== ===== Summary =====
stacker/docs/tutorials/tutorial003.txt · Last modified: 2021/04/29 15:50 by rjlittlefield
Copyright 2009-2024, Zerene Systems LLC, all rights reserved.