depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusdepth_from_focus(算子)

名称

depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusdepth_from_focus — 使用多级对焦提取深度。

签名

depth_from_focus(MultiFocusImage : Depth, Confidence : Filter, Selection : )

Herror depth_from_focus(const Hobject MultiFocusImage, Hobject* Depth, Hobject* Confidence, const char* Filter, const char* Selection)

Herror T_depth_from_focus(const Hobject MultiFocusImage, Hobject* Depth, Hobject* Confidence, const Htuple Filter, const Htuple Selection)

void DepthFromFocus(const HObject& MultiFocusImage, HObject* Depth, HObject* Confidence, const HTuple& Filter, const HTuple& Selection)

HImage HImage::DepthFromFocus(HImage* Confidence, const HTuple& Filter, const HTuple& Selection) const

HImage HImage::DepthFromFocus(HImage* Confidence, const HString& Filter, const HString& Selection) const

HImage HImage::DepthFromFocus(HImage* Confidence, const char* Filter, const char* Selection) const

HImage HImage::DepthFromFocus(HImage* Confidence, const wchar_t* Filter, const wchar_t* Selection) const   ( Windows only)

static void HOperatorSet.DepthFromFocus(HObject multiFocusImage, out HObject depth, out HObject confidence, HTuple filter, HTuple selection)

HImage HImage.DepthFromFocus(out HImage confidence, HTuple filter, HTuple selection)

HImage HImage.DepthFromFocus(out HImage confidence, string filter, string selection)

def depth_from_focus(multi_focus_image: HObject, filter: MaybeSequence[Union[str, int]], selection: MaybeSequence[str]) -> Tuple[HObject, HObject]

描述

算子 depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus extracts the depth using a focus sequence. The images of the focus sequence have to be passed as a multi channel image (MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image). The depth for each pixel will be returned in DepthDepthDepthDepthdepthdepth as the channel number. The parameter ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence returns a confidence value for each depth estimation: The larger this value, the higher the confidence of the depth estimation is.

depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus selects the pixels with the best focus of all focus levels. The method used to extract these pixels is specified by the parameters FilterFilterFilterFilterfilterfilter and SelectionSelectionSelectionSelectionselectionselection

For the parameter FilterFilterFilterFilterfilterfilter, you can choose between the values 'highpass'"highpass""highpass""highpass""highpass""highpass" and 'bandpass'"bandpass""bandpass""bandpass""bandpass""bandpass". To determine the focus within the image a high- or a bandpass filter can be applied. The larger the filter response, the more in focus is the image at this location. Compared to the highpass filter, the bandpass filter suppresses high frequencies. This is useful in particular in images containing strong noise.

Optionally, you can smooth the filtered image using the mean filter by passing two additional integer values for the mask size in the parameter FilterFilterFilterFilterfilterfilter (e.g., ['highpass'"highpass""highpass""highpass""highpass""highpass", 7, 7]). This blurs the in-focus region with neighboring pixels and thus allows to bridge small areas with no texture within the image. Note, however, that this smoothing does not suppress noise in the original image, since it is applied only after high- or bandpass filtering.

The parameter SelectionSelectionSelectionSelectionselectionselection determines how the optimum focus level is selected. If you pass the value 'next_maximum'"next_maximum""next_maximum""next_maximum""next_maximum""next_maximum", the closest focus maximum in the neighborhood is used. In contrast, if you pass the value 'local'"local""local""local""local""local", the focus level is determined based on the focus values of all focus levels of the pixel. With 'next_maximum'"next_maximum""next_maximum""next_maximum""next_maximum""next_maximum", you typically achieve a slightly smoothed and more robust result.

This additional smoothing is useful if no telecentric lenses are used to take the input images. In this case, the position of an object will slightly shift within the sequence. By adding appropriate smoothing, this effect can be partially compensated.

注意

If MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image contains more than 255 channels (focus levels), DepthDepthDepthDepthdepthdepth is clipped at 255, i.e. depth values higher than 255 are ignored.

If the filter mask for FilterFilterFilterFilterfilterfilter is specified with even values, the routine uses the next larger odd values instead (this way the center of the filter mask is always explicitly determined).

If SelectionSelectionSelectionSelectionselectionselection is set to 'local'"local""local""local""local""local" and FilterFilterFilterFilterfilterfilter is set to 'highpass'"highpass""highpass""highpass""highpass""highpass" or 'bandpass'"bandpass""bandpass""bandpass""bandpass""bandpass", depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus 可在 OpenCL 设备上执行。 If smoothing is enabled, the same restrictions and limitations as for mean_imagemean_imageMeanImageMeanImageMeanImagemean_image apply.

请注意,若使用域缩减后的图像作为输入,滤波器算子可能会返回意外结果。请参阅 滤波器 一章

执行信息

参数

MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image (输入对象)  multichannel-image(-array) objectHImageHObjectHImageHobject (byte)

Multichannel gray image consisting of multiple focus levels.

DepthDepthDepthDepthdepthdepth (输出对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject * (byte)

Depth image.

ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence (输出对象)  singlechannelimage(-array) objectHImageHObjectHImageHobject * (byte)

Confidence of depth estimation.

FilterFilterFilterFilterfilterfilter (输入控制)  string(-array) HTupleMaybeSequence[Union[str, int]]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)

Filter used to find sharp pixels.

默认值: 'highpass' "highpass" "highpass" "highpass" "highpass" "highpass"

建议值: 'highpass'"highpass""highpass""highpass""highpass""highpass", 'bandpass'"bandpass""bandpass""bandpass""bandpass""bandpass", 3, 5, 7, 9

SelectionSelectionSelectionSelectionselectionselection (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Method used to find sharp pixels.

默认值: 'next_maximum' "next_maximum" "next_maximum" "next_maximum" "next_maximum" "next_maximum"

值列表: 'local'"local""local""local""local""local", 'next_maximum'"next_maximum""next_maximum""next_maximum""next_maximum""next_maximum"

List of values (for compute devices): 'local'"local""local""local""local""local"

示例 (C++ (HALCON 5.0-10.0))

compose3(Focus0,Focus1,Focus2,&MultiFocus);
depth_from_focus(MultiFocus,&Depth,&Confidence,'highpass','next_maximum');
mean_image(Depth,&Smooth,15,15);
select_grayvalues_from_channels(MultiChannel,Smooth,SharpImage);
threshold(Confidence,HighConfidence,10,255);
reduce_domain(SharpImage,HighConfidence,ConfidentSharp);

可能的前趋

compose2compose2Compose2Compose2Compose2compose2, compose3compose3Compose3Compose3Compose3compose3, compose4compose4Compose4Compose4Compose4compose4, add_channelsadd_channelsAddChannelsAddChannelsAddChannelsadd_channels, read_imageread_imageReadImageReadImageReadImageread_image, read_sequenceread_sequenceReadSequenceReadSequenceReadSequenceread_sequence

可能的后继

select_grayvalues_from_channelsselect_grayvalues_from_channelsSelectGrayvaluesFromChannelsSelectGrayvaluesFromChannelsSelectGrayvaluesFromChannelsselect_grayvalues_from_channels, mean_imagemean_imageMeanImageMeanImageMeanImagemean_image, binomial_filterbinomial_filterBinomialFilterBinomialFilterBinomialFilterbinomial_filter, gauss_filtergauss_filterGaussFilterGaussFilterGaussFiltergauss_filter, thresholdthresholdThresholdThresholdThresholdthreshold

另见

count_channelscount_channelsCountChannelsCountChannelsCountChannelscount_channels

模块

三维计量