depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusdepth_from_focus对焦深度(算子)
名称
depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusdepth_from_focus — 利用多个对焦层提取深度。
签名
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)
描述
算子 depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus 通过对焦序列提取深度。对焦序列中的图像必须作为多通道图像(MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image)传递。每个像素的深度将作为通道编号返回至 DepthDepthDepthDepthdepthdepth 通道。ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence 参数为每个深度估计值返回一个置信度值:该值越大,深度估计的置信度越高。
depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus 会从所有对焦层中选取对焦最佳的像素。提取这些像素所采用的方法由参数 FilterFilterFilterFilterfilterfilter 和 SelectionSelectionSelectionSelectionselectionselection 指定。
对于 FilterFilterFilterFilterfilterfilter 参数,可选择
'highpass'"highpass""highpass""highpass""highpass""highpass" 和
'bandpass'"bandpass""bandpass""bandpass""bandpass""bandpass" 值。为确定图像内的对焦位置,可应用高通滤波器或带通滤波器。滤波器响应越强,该位置的图像对焦越清晰。与高通滤波器相比,带通滤波器会抑制高频成分。这在包含强烈噪点的图像中尤为有用。
此外,您还可以通过在 FilterFilterFilterFilterfilterfilter 参数中额外传入两个整数值来指定掩模大小(例如 ['highpass'"highpass""highpass""highpass""highpass""highpass", 7,
7]),从而使用均值滤波器对滤波后的图像进行平滑处理。这会将对焦区域与相邻像素进行模糊处理,从而能够弥合图像中无纹理的小区域。但请注意,此平滑处理并不能抑制原始图像中的噪声,因为它仅在高通或带通滤波之后应用。
SelectionSelectionSelectionSelectionselectionselection 参数决定如何选择最佳对焦级层。若传入值 '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" 通常能获得略微平滑且更稳健的结果。
若输入图像未使用远心镜头拍摄,此额外平滑处理将非常有用。在此情况下,物体在序列中的位置会发生轻微偏移。通过添加适当的平滑处理,可部分补偿此效应。
注意
如果 MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image 包含超过 255 个通道(对焦层),DepthDepthDepthDepthdepthdepth 将被截断至 255,即大于 255 的深度值将被忽略。
如果 FilterFilterFilterFilterfilterfilter 指定的滤波器掩模使用偶数值,该例程将改用下一个更大的奇数值(这样可以确保滤波器掩模的中心始终被明确确定)。
如果 SelectionSelectionSelectionSelectionselectionselection 设置为 'local'"local""local""local""local""local" 且 FilterFilterFilterFilterfilterfilter 设置为 'highpass'"highpass""highpass""highpass""highpass""highpass" 或
'bandpass'"bandpass""bandpass""bandpass""bandpass""bandpass",depth_from_focusdepth_from_focusDepthFromFocusDepthFromFocusDepthFromFocusdepth_from_focus
可在 OpenCL 设备上执行。如果启用了平滑处理,则适用与 mean_imagemean_imageMeanImageMeanImageMeanImagemean_image 相同的限制和约束。
请注意,若使用域缩减后的图像作为输入,滤波器算子可能会返回意外结果。请参阅 滤波器 一章
执行信息
- 支持 OpenCL 计算设备。
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 在元组级别上自动并行化。
- 在内部数据级别上自动并行化。
参数
MultiFocusImageMultiFocusImageMultiFocusImageMultiFocusImagemultiFocusImagemulti_focus_image (输入对象) multichannel-image(-array) → objectHImageHObjectHImageHobject (byte)
由多个对焦层组成的多通道灰度图像。
DepthDepthDepthDepthdepthdepth (输出对象) singlechannelimage(-array) → objectHImageHObjectHImageHobject * (byte)
深度图像。
ConfidenceConfidenceConfidenceConfidenceconfidenceconfidence (输出对象) singlechannelimage(-array) → objectHImageHObjectHImageHobject * (byte)
深度估计的置信度。
FilterFilterFilterFilterfilterfilter (输入控制) string(-array) → HTupleMaybeSequence[Union[str, int]]HTupleHtuple (string / integer) (string / int / long) (HString / Hlong) (char* / Hlong)
用于查找锐利像素的滤波器。
默认值:
'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*)
用于查找锐利像素的方法。
默认值:
'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"
值列表(用于计算设备):'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
模块
三维计量