Name
binocular_disparitybinocular_disparityBinocularDisparitybinocular_disparityBinocularDisparityBinocularDisparity — Compute the disparities of a rectified image pair using correlation
techniques.
binocular_disparity(Image1, Image2 : Disparity, Score : Method, MaskWidth, MaskHeight, TextureThresh, MinDisparity, MaxDisparity, NumLevels, ScoreThresh, Filter, SubDisparity : )
Herror binocular_disparity(const Hobject Image1, const Hobject Image2, Hobject* Disparity, Hobject* Score, const char* Method, const Hlong MaskWidth, const Hlong MaskHeight, double TextureThresh, const Hlong MinDisparity, const Hlong MaxDisparity, const Hlong NumLevels, double ScoreThresh, const char* Filter, const char* SubDisparity)
Herror T_binocular_disparity(const Hobject Image1, const Hobject Image2, Hobject* Disparity, Hobject* Score, const Htuple Method, const Htuple MaskWidth, const Htuple MaskHeight, const Htuple TextureThresh, const Htuple MinDisparity, const Htuple MaxDisparity, const Htuple NumLevels, const Htuple ScoreThresh, const Htuple Filter, const Htuple SubDisparity)
Herror binocular_disparity(Hobject Image1, Hobject Image2, Hobject* Disparity, Hobject* Score, const HTuple& Method, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& TextureThresh, const HTuple& MinDisparity, const HTuple& MaxDisparity, const HTuple& NumLevels, const HTuple& ScoreThresh, const HTuple& Filter, const HTuple& SubDisparity)
HImage HImage::BinocularDisparity(const HImage& Image2, HImage* Score, const HTuple& Method, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& TextureThresh, const HTuple& MinDisparity, const HTuple& MaxDisparity, const HTuple& NumLevels, const HTuple& ScoreThresh, const HTuple& Filter, const HTuple& SubDisparity) const
void BinocularDisparity(const HObject& Image1, const HObject& Image2, HObject* Disparity, HObject* Score, const HTuple& Method, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& TextureThresh, const HTuple& MinDisparity, const HTuple& MaxDisparity, const HTuple& NumLevels, const HTuple& ScoreThresh, const HTuple& Filter, const HTuple& SubDisparity)
HImage HImage::BinocularDisparity(const HImage& Image2, HImage* Score, const HString& Method, Hlong MaskWidth, Hlong MaskHeight, const HTuple& TextureThresh, Hlong MinDisparity, Hlong MaxDisparity, Hlong NumLevels, const HTuple& ScoreThresh, const HTuple& Filter, const HString& SubDisparity) const
HImage HImage::BinocularDisparity(const HImage& Image2, HImage* Score, const HString& Method, Hlong MaskWidth, Hlong MaskHeight, double TextureThresh, Hlong MinDisparity, Hlong MaxDisparity, Hlong NumLevels, double ScoreThresh, const HString& Filter, const HString& SubDisparity) const
HImage HImage::BinocularDisparity(const HImage& Image2, HImage* Score, const char* Method, Hlong MaskWidth, Hlong MaskHeight, double TextureThresh, Hlong MinDisparity, Hlong MaxDisparity, Hlong NumLevels, double ScoreThresh, const char* Filter, const char* SubDisparity) const
void HOperatorSetX.BinocularDisparity(
[in] IHUntypedObjectX* Image1, [in] IHUntypedObjectX* Image2, [out] IHUntypedObjectX** Disparity, [out] IHUntypedObjectX** Score, [in] VARIANT Method, [in] VARIANT MaskWidth, [in] VARIANT MaskHeight, [in] VARIANT TextureThresh, [in] VARIANT MinDisparity, [in] VARIANT MaxDisparity, [in] VARIANT NumLevels, [in] VARIANT ScoreThresh, [in] VARIANT Filter, [in] VARIANT SubDisparity)
IHImageX* HImageX.BinocularDisparity(
[in] IHImageX* Image2, [out] IHImageX** Score, [in] BSTR Method, [in] Hlong MaskWidth, [in] Hlong MaskHeight, [in] VARIANT TextureThresh, [in] Hlong MinDisparity, [in] Hlong MaxDisparity, [in] Hlong NumLevels, [in] VARIANT ScoreThresh, [in] VARIANT Filter, [in] BSTR SubDisparity)
static void HOperatorSet.BinocularDisparity(HObject image1, HObject image2, out HObject disparity, out HObject score, HTuple method, HTuple maskWidth, HTuple maskHeight, HTuple textureThresh, HTuple minDisparity, HTuple maxDisparity, HTuple numLevels, HTuple scoreThresh, HTuple filter, HTuple subDisparity)
HImage HImage.BinocularDisparity(HImage image2, out HImage score, string method, int maskWidth, int maskHeight, HTuple textureThresh, int minDisparity, int maxDisparity, int numLevels, HTuple scoreThresh, HTuple filter, string subDisparity)
HImage HImage.BinocularDisparity(HImage image2, out HImage score, string method, int maskWidth, int maskHeight, double textureThresh, int minDisparity, int maxDisparity, int numLevels, double scoreThresh, string filter, string subDisparity)
binocular_disparitybinocular_disparityBinocularDisparitybinocular_disparityBinocularDisparityBinocularDisparity computes pixel-wise correspondences
between two rectified images using correlation techniques. Different from
binocular_distancebinocular_distanceBinocularDistancebinocular_distanceBinocularDistanceBinocularDistance the results are not transformed into
distance values.
The algorithm requires a reference image Image1Image1Image1Image1Image1image1 and a search
image Image2Image2Image2Image2Image2image2 which must be rectified, i.e.,
corresponding epipolar lines are parallel and lie on identical image
rows ( r1=r2 ). In case this assumption is
violated the images can be rectified by using the operators
calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras,
gen_binocular_rectification_mapgen_binocular_rectification_mapGenBinocularRectificationMapgen_binocular_rectification_mapGenBinocularRectificationMapGenBinocularRectificationMap, and
map_imagemap_imageMapImagemap_imageMapImageMapImage. Hence, given a pixel in the reference image
Image1Image1Image1Image1Image1image1 the homologous pixel in Image2Image2Image2Image2Image2image2 is selected
by searching along the corresponding row in Image2Image2Image2Image2Image2image2 and
matching a local neighborhood within a rectangular window of size
MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth and MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight. The pixel
correspondences are returned in the single-channel
DisparityDisparityDisparityDisparityDisparitydisparity image d(r1,c1) which
specifies for each pixel (r1,c1) of the reference image Image1Image1Image1Image1Image1image1 a
suitable matching pixel (r2,c2) of Image2Image2Image2Image2Image2image2 according to the equation
c2 = c1 + d(r1,c1) . A
quality measure for each disparity value is returned in
ScoreScoreScoreScoreScorescore, containing the best result of the matching function
S of a reference pixel. For the matching, the gray values of the
original unprocessed images are used.
The used matching function is defined by the parameter
MethodMethodMethodMethodMethodmethod allocating three different kinds of correlation:
-
'sad'"sad""sad""sad""sad""sad": Summed Absolute Differences
S(r1,c1,d) := SUM(|g1(r1',c1')-g2(r1',c1'+d)|), 0=<=S<=255,
-
'ssd'"ssd""ssd""ssd""ssd""ssd": Summed Squared Differences
S(r1,c1,d) := SUM((g1(r1',c1')-g2(r1',c1'+d))²), 0<=S<=65025,
-
'ncc'"ncc""ncc""ncc""ncc""ncc": Normalized Cross Correlation
S(r1,c1,d) :=
SUM(g1(r1',c1')-gm1(r1,c1))*(g2(r1',c1'+d)-gm2(r1,c1+d)))/
SQRT(SUM((g1(r1',c1')-gm1(r1,c1))²)*
SUM((g2(r1',c1+d)-gm2(r1,c1+d))²)),
-1.0<=S<=1.0,
with
r1, c1, r2, c2: row and column coordinates of the corresponding pixels of
the two input images,
g1, g2: gray values of the unprocessed input images,
N=(2m+1)(2n+1): size of correlation window
SUM(x): mean value within the correlation window of width 2m+1 and
height 2n+1.
Note that the methods 'sad'"sad""sad""sad""sad""sad" and 'ssd'"ssd""ssd""ssd""ssd""ssd" compare the gray
values of the pixels within a mask window directly, whereas 'ncc'"ncc""ncc""ncc""ncc""ncc"
compensates for the mean gray value and its variance within the mask
window. Therefore, if the two images differ in brightness and contrast, this
method should be preferred. For images with similar brightness and contrast
'sad'"sad""sad""sad""sad""sad" and 'ssd'"ssd""ssd""ssd""ssd""ssd" are to be preferred as they are faster
because of less complex internal computations.
It should be noted, that the quality of correlation for rising S is
falling in methods 'sad'"sad""sad""sad""sad""sad" and 'ssd'"ssd""ssd""ssd""ssd""ssd" (the best
quality value is 0) but rising in method 'ncc'"ncc""ncc""ncc""ncc""ncc" (the best
quality value is 1.0).
The size of the correlation window, referenced by 2m+1
and 2n+1, has to be odd numbered and is
passed in MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth and MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight. The search
space is confined by the minimum and maximum disparity value
MinDisparityMinDisparityMinDisparityMinDisparityMinDisparityminDisparity and MaxDisparityMaxDisparityMaxDisparityMaxDisparityMaxDisparitymaxDisparity. Due to pixel values
not defined beyond the image border the resulting domain of
DisparityDisparityDisparityDisparityDisparitydisparity and ScoreScoreScoreScoreScorescore is not set along the
image border within a margin of height (MaskHeightMaskHeightMaskHeightMaskHeightMaskHeightmaskHeight-1)/2 at the
top and bottom border and of width (MaskWidthMaskWidthMaskWidthMaskWidthMaskWidthmaskWidth-1)/2 at the left
and right border. For the same reason, the maximum disparity range
is reduced at the left and right image border.
Since matching turns out to be highly unreliable when dealing with
poorly textured areas, the minimum statistical spread of gray values
within the
correlation window can be defined in TextureThreshTextureThreshTextureThreshTextureThreshTextureThreshtextureThresh. This
threshold is applied on both input images Image1Image1Image1Image1Image1image1 and
Image2Image2Image2Image2Image2image2. In addition, ScoreThreshScoreThreshScoreThreshScoreThreshScoreThreshscoreThresh guarantees the
matching quality and defines the maximum
('sad'"sad""sad""sad""sad""sad",'ssd'"ssd""ssd""ssd""ssd""ssd") or, respectively, minimum
('ncc'"ncc""ncc""ncc""ncc""ncc") score value of the correlation
function. Setting FilterFilterFilterFilterFilterfilter to 'left_right_check'"left_right_check""left_right_check""left_right_check""left_right_check""left_right_check",
moreover, increases the robustness of the returned matches, as the
result relies on a concurrent direct and reverse match, whereas
'none'"none""none""none""none""none" switches it off.
The number of pyramid levels used to improve the time response of
binocular_disparitybinocular_disparityBinocularDisparitybinocular_disparityBinocularDisparityBinocularDisparity is determined by
NumLevelsNumLevelsNumLevelsNumLevelsNumLevelsnumLevels. Following a coarse-to-fine scheme disparity
images of higher levels are computed and segmented into
rectangular subimages of similar disparity to reduce the disparity
range on the next
lower pyramid level. TextureThreshTextureThreshTextureThreshTextureThreshTextureThreshtextureThresh and ScoreThreshScoreThreshScoreThreshScoreThreshScoreThreshscoreThresh
are applied on every level and the returned domain of the
DisparityDisparityDisparityDisparityDisparitydisparity and ScoreScoreScoreScoreScorescore images arises from the
intersection of the resulting domains of every single
level. Generally, pyramid structures are the more advantageous the
more the disparity image can be segmented into regions of homogeneous
disparities and the bigger the disparity range is
specified. As a drawback, coarse pyramid levels might loose
important texture information which can result in deficient
disparity values.
Finally, the value 'interpolation'"interpolation""interpolation""interpolation""interpolation""interpolation" for parameter
SubDisparitySubDisparitySubDisparitySubDisparitySubDisparitysubDisparity performs subpixel refinement of
disparities. It is switched off by setting the parameter to
'none'"none""none""none""none""none".
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Automatically parallelized on internal data level.
Rectified image of camera 1.
Rectified image of camera 2.
Evaluation of the disparity values.
Matching function.
Default value:
'ncc'
"ncc"
"ncc"
"ncc"
"ncc"
"ncc"
List of values: 'ncc'"ncc""ncc""ncc""ncc""ncc", 'sad'"sad""sad""sad""sad""sad", 'ssd'"ssd""ssd""ssd""ssd""ssd"
Width of the correlation window.
Default value: 11
Suggested values: 5, 7, 9, 11, 21
Restriction: 3 <= MaskWidth && odd(MaskWidth)
Height of the correlation window.
Default value: 11
Suggested values: 5, 7, 9, 11, 21
Restriction: 3 <= MaskHeight && odd(MaskHeight)
Variance threshold of textured image regions.
Default value: 0.0
Suggested values: 0.0, 10.0, 30.0
Restriction: 0.0 <= TextureThresh
Minimum of the expected disparities.
Default value: -30
Typical range of values: -32768
≤
MinDisparity
MinDisparity
MinDisparity
MinDisparity
MinDisparity
minDisparity
≤
32767
Maximum of the expected disparities.
Default value: 30
Typical range of values: -32768
≤
MaxDisparity
MaxDisparity
MaxDisparity
MaxDisparity
MaxDisparity
maxDisparity
≤
32767
Number of pyramid levels.
Default value: 1
Suggested values: 1, 2, 3, 4
Restriction: 1 <= NumLevels
Threshold of the correlation function.
Default value: 0.5
Suggested values: -1.0, 0.0, 0.3, 0.5, 0.7
Downstream filters.
Default value:
'none'
"none"
"none"
"none"
"none"
"none"
List of values: 'left_right_check'"left_right_check""left_right_check""left_right_check""left_right_check""left_right_check", 'none'"none""none""none""none""none"
Subpixel interpolation of disparities.
Default value:
'none'
"none"
"none"
"none"
"none"
"none"
List of values: 'interpolation'"interpolation""interpolation""interpolation""interpolation""interpolation", 'none'"none""none""none""none""none"
* read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
* compute the mapping for rectified images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'geometric', 'bilinear', CamParamRect1,CamParamRect2, Cam1PoseRect1, \
Cam2PoseRect2,RelPoseRect)
* compute the disparities in online images
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check','interpolation')
endwhile
* read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
* compute the mapping for rectified images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'geometric', 'bilinear', CamParamRect1,CamParamRect2, Cam1PoseRect1, \
Cam2PoseRect2,RelPoseRect)
* compute the disparities in online images
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check','interpolation')
endwhile
* read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
* compute the mapping for rectified images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'geometric', 'bilinear', CamParamRect1,CamParamRect2, Cam1PoseRect1, \
Cam2PoseRect2,RelPoseRect)
* compute the disparities in online images
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check','interpolation')
endwhile
// read the internal and external stereo parameters
read_cam_par("cam_left.dat",CamParam1);
read_cam_par("cam_right.dat",CamParam2);
read_pose("relpos.dat",RelPose);
// compute the mapping for rectified images
gen_binocular_rectification_map(&Map1,&Map2,CamParam1,CamParam2,RelPose,1,
"geometric","bilinear",&CamParamRect1,
&CamParamRect2,&CamPoseRect1,&CamPoseRect2,
&RelPosRect);
// compute the disparities in online images
while (1)
{
grab_image_async(&Image1,AcqHandle1,-1);
map_image(Image1,Map1,&ImageMapped1);
grab_image_async(&Image2,AcqHandle2,-1);
map_image(Image2,Map2,&ImageMapped2);
binocular_disparity(ImageMapped1,ImageMapped2,&Disparity,&Score,"sad",
11,11,20,-40,20,2,25,"left_right_check",
"interpolation");
}
* read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
* compute the mapping for rectified images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'geometric', 'bilinear', CamParamRect1,CamParamRect2, Cam1PoseRect1, \
Cam2PoseRect2,RelPoseRect)
* compute the disparities in online images
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check','interpolation')
endwhile
* read the internal and external stereo parameters
read_cam_par ('cam_left.dat', CamParam1)
read_cam_par ('cam_right.dat', CamParam2)
read_pose ('relpos.dat', RelPose)
* compute the mapping for rectified images
gen_binocular_rectification_map (Map1, Map2, CamParam1, CamParam2, RelPose, \
1, 'geometric', 'bilinear', CamParamRect1,CamParamRect2, Cam1PoseRect1, \
Cam2PoseRect2,RelPoseRect)
* compute the disparities in online images
while (1)
grab_image_async (Image1, AcqHandle1, -1)
map_image (Image1, Map1, ImageMapped1)
grab_image_async (Image2, AcqHandle2, -1)
map_image (Image2, Map2, ImageMapped2)
binocular_disparity(ImageMapped1, ImageMapped2, Disparity, Score, 'sad', \
11, 11, 20, -40, 20, 2, 25, 'left_right_check','interpolation')
endwhile
binocular_disparitybinocular_disparityBinocularDisparitybinocular_disparityBinocularDisparityBinocularDisparity returns 2 (H_MSG_TRUE) if all parameter values
are correct. If necessary, an exception is raised.
map_imagemap_imageMapImagemap_imageMapImageMapImage
thresholdthresholdThresholdthresholdThresholdThreshold,
disparity_to_distancedisparity_to_distanceDisparityToDistancedisparity_to_distanceDisparityToDistanceDisparityToDistance,
disparity_image_to_xyzdisparity_image_to_xyzDisparityImageToXyzdisparity_image_to_xyzDisparityImageToXyzDisparityImageToXyz
binocular_disparity_mgbinocular_disparity_mgBinocularDisparityMgbinocular_disparity_mgBinocularDisparityMgBinocularDisparityMg,
binocular_distancebinocular_distanceBinocularDistancebinocular_distanceBinocularDistanceBinocularDistance,
binocular_distance_mgbinocular_distance_mgBinocularDistanceMgbinocular_distance_mgBinocularDistanceMgBinocularDistanceMg
map_imagemap_imageMapImagemap_imageMapImageMapImage,
gen_binocular_rectification_mapgen_binocular_rectification_mapGenBinocularRectificationMapgen_binocular_rectification_mapGenBinocularRectificationMapGenBinocularRectificationMap,
binocular_calibrationbinocular_calibrationBinocularCalibrationbinocular_calibrationBinocularCalibrationBinocularCalibration
3D Metrology