ClassesClassesClassesClasses | | | | Operators

image_to_world_planeT_image_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane (Operator)

Name

image_to_world_planeT_image_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane — Rectify an image by transforming it into the plane z=0 of a world coordinate system.

Signature

image_to_world_plane(Image : ImageWorld : CameraParam, WorldPose, Width, Height, Scale, Interpolation : )

Herror T_image_to_world_plane(const Hobject Image, Hobject* ImageWorld, const Htuple CameraParam, const Htuple WorldPose, const Htuple Width, const Htuple Height, const Htuple Scale, const Htuple Interpolation)

Herror image_to_world_plane(Hobject Image, Hobject* ImageWorld, const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& Width, const HTuple& Height, const HTuple& Scale, const HTuple& Interpolation)

HImage HImage::ImageToWorldPlane(const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& Width, const HTuple& Height, const HTuple& Scale, const HTuple& Interpolation) const

HImageArray HImageArray::ImageToWorldPlane(const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& Width, const HTuple& Height, const HTuple& Scale, const HTuple& Interpolation) const

void ImageToWorldPlane(const HObject& Image, HObject* ImageWorld, const HTuple& CameraParam, const HTuple& WorldPose, const HTuple& Width, const HTuple& Height, const HTuple& Scale, const HTuple& Interpolation)

HImage HImage::ImageToWorldPlane(const HTuple& CameraParam, const HPose& WorldPose, Hlong Width, Hlong Height, const HTuple& Scale, const HString& Interpolation) const

HImage HImage::ImageToWorldPlane(const HTuple& CameraParam, const HPose& WorldPose, Hlong Width, Hlong Height, const HString& Scale, const HString& Interpolation) const

HImage HImage::ImageToWorldPlane(const HTuple& CameraParam, const HPose& WorldPose, Hlong Width, Hlong Height, const char* Scale, const char* Interpolation) const

void HOperatorSetX.ImageToWorldPlane(
[in] IHUntypedObjectX* Image, [out] IHUntypedObjectX*ImageWorld, [in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] VARIANT Width, [in] VARIANT Height, [in] VARIANT Scale, [in] VARIANT Interpolation)

IHImageX* HImageX.ImageToWorldPlane(
[in] VARIANT CameraParam, [in] VARIANT WorldPose, [in] Hlong Width, [in] Hlong Height, [in] VARIANT Scale, [in] BSTR Interpolation)

static void HOperatorSet.ImageToWorldPlane(HObject image, out HObject imageWorld, HTuple cameraParam, HTuple worldPose, HTuple width, HTuple height, HTuple scale, HTuple interpolation)

HImage HImage.ImageToWorldPlane(HTuple cameraParam, HPose worldPose, int width, int height, HTuple scale, string interpolation)

HImage HImage.ImageToWorldPlane(HTuple cameraParam, HPose worldPose, int width, int height, string scale, string interpolation)

Description

image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane rectifies an image ImageImageImageImageImageimage by transforming it into the plane z=0 (plane of measurements) in a world coordinate system. The resulting rectified image ImageWorldImageWorldImageWorldImageWorldImageWorldimageWorld shows neither radial nor perspective distortions; it corresponds to an image acquired by a distortion-free camera that looks perpendicularly onto the plane of measurements. The world coordinate system is chosen by passing its 3D pose relative to the camera coordinate system in WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose. In CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam you must pass the internal camera parameters (see write_cam_parwrite_cam_parWriteCamParwrite_cam_parWriteCamParWriteCamPar for the sequence of the parameters and the underlying camera model).

In many cases CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam and WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose are the result of calibrating the camera with the operator calibrate_camerascalibrate_camerasCalibrateCamerascalibrate_camerasCalibrateCamerasCalibrateCameras. See below for an example.

The pixel position of the upper left corner of the output image ImageWorldImageWorldImageWorldImageWorldImageWorldimageWorld is determined by the origin of the world coordinate system. The size of the output image ImageWorldImageWorldImageWorldImageWorldImageWorldimageWorld can be chosen by the parameters WidthWidthWidthWidthWidthwidth, HeightHeightHeightHeightHeightheight, and ScaleScaleScaleScaleScalescale. WidthWidthWidthWidthWidthwidth and HeightHeightHeightHeightHeightheight must be given in pixels.

With the parameter ScaleScaleScaleScaleScalescale you can specify the size of a pixel in the transformed image. There are two typical scenarios: First, you can scale the image such that pixel coordinates in the transformed image directly correspond to metric units, e.g., that one pixel corresponds to one micron. This is useful if you want to perform measurements in the transformed image which will then directly result in metric results. The second scenario is to scale the image such that its content appears in a size similar to the original image. This is useful, e.g., if you want to perform shape-based matching in the transformed image.

ScaleScaleScaleScaleScalescale must be specified as the ratio desired pixel size/original unit. A pixel size of 1um means that a pixel in the transformed image corresponds to the area 1um x 1um in the plane of measurements. The original unit is determined by the coordinates of the calibration object. If the original unit is meters (which is the case if you use the standard calibration plate), you can use the parameter values 'm'"m""m""m""m""m", 'cm'"cm""cm""cm""cm""cm", 'mm'"mm""mm""mm""mm""mm", 'microns'"microns""microns""microns""microns""microns", or 'um'"um""um""um""um""um" to directly set the unit of pixel coordinates in the transformed image.

The parameter InterpolationInterpolationInterpolationInterpolationInterpolationinterpolation specifies, whether bilinear interpolation ('bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear") should be applied between the pixels in the input image or whether the gray value of the nearest neighboring pixel ('nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor") should be used.

If several images have to be rectified using the same parameters, gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap in combination with map_imagemap_imageMapImagemap_imageMapImageMapImage is much more efficient than the operator image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane because the mapping function needs to be computed only once.

Attention

image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane can be executed on OpenCL devices if the input image does not exceed the maximum size of image objects of the selected device. There can be slight differences in the output compared to the execution on the CPU.

Parallelization

Parameters

ImageImageImageImageImageimage (input_object)  (multichannel-)image(-array) objectHImageHImageHImageHImageXHobject (byte / uint2 / real)

Input image.

ImageWorldImageWorldImageWorldImageWorldImageWorldimageWorld (output_object)  (multichannel-)image(-array) objectHImageHImageHImageHImageXHobject * (byte / uint2 / real)

Transformed image.

CameraParamCameraParamCameraParamCameraParamCameraParamcameraParam (input_control)  number-array HTupleHTupleHTupleVARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

Internal camera parameters.

Number of elements: CameraParam == 8 || CameraParam == 11 || CameraParam == 12

WorldPoseWorldPoseWorldPoseWorldPoseWorldPoseworldPose (input_control)  pose HPose, HTupleHTupleHTupleHPoseX, VARIANTHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong) (double / Hlong) (double / Hlong)

3D pose of the world coordinate system in camera coordinates.

Number of elements: 7

WidthWidthWidthWidthWidthwidth (input_control)  extent.x HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Width of the resulting image in pixels.

HeightHeightHeightHeightHeightheight (input_control)  extent.y HTupleHTupleHTupleVARIANTHtuple (integer) (int / long) (Hlong) (Hlong) (Hlong) (Hlong)

Height of the resulting image in pixels.

ScaleScaleScaleScaleScalescale (input_control)  number HTupleHTupleHTupleVARIANTHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double) (BSTR / Hlong / double) (char* / Hlong / double)

Scale or unit

Default value: 'm' "m" "m" "m" "m" "m"

Suggested values: 'm'"m""m""m""m""m", 'cm'"cm""cm""cm""cm""cm", 'mm'"mm""mm""mm""mm""mm", 'microns'"microns""microns""microns""microns""microns", 'um'"um""um""um""um""um", 1.0, 0.01, 0.001, 1.0e-6, 0.0254, 0.3048, 0.9144

InterpolationInterpolationInterpolationInterpolationInterpolationinterpolation (input_control)  string HTupleHTupleHTupleVARIANTHtuple (string) (string) (HString) (char*) (BSTR) (char*)

Type of interpolation.

Default value: 'bilinear' "bilinear" "bilinear" "bilinear" "bilinear" "bilinear"

List of values: 'bilinear'"bilinear""bilinear""bilinear""bilinear""bilinear", 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor"

Example (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.0006, WorldPose)
*  goal: rectify image
*  first determine parameters such that the entire image content is visible
*    and that objects have a similar size before and after the rectification
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  transform the image with the determined parameters
image_to_world_plane(Image, RectifiedImage, FinalCamParam, \
                     PoseForEntireImage, WidthRectifiedImage, \
                     HeightRectifiedImage, ScaleForSimilarPixelSize, \
                     'bilinear')

Example (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.0006, WorldPose)
*  goal: rectify image
*  first determine parameters such that the entire image content is visible
*    and that objects have a similar size before and after the rectification
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  transform the image with the determined parameters
image_to_world_plane(Image, RectifiedImage, FinalCamParam, \
                     PoseForEntireImage, WidthRectifiedImage, \
                     HeightRectifiedImage, ScaleForSimilarPixelSize, \
                     'bilinear')

Example (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.0006, WorldPose)
*  goal: rectify image
*  first determine parameters such that the entire image content is visible
*    and that objects have a similar size before and after the rectification
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  transform the image with the determined parameters
image_to_world_plane(Image, RectifiedImage, FinalCamParam, \
                     PoseForEntireImage, WidthRectifiedImage, \
                     HeightRectifiedImage, ScaleForSimilarPixelSize, \
                     'bilinear')

Example (C++ (HALCON 5.0-10.0))

HImage  Image, RectifiedImage;
HTuple  NX, NY, NZ, NRow, NCol;
HTuple  StartCamParam, NStartPose, FinalCamParam, NFinalPose, Errors;
HTuple  FinalPose1, WorldPose, PoseForEntireImage;
HTuple  Width, Height, Type, MinX, MinY, MaxX, MaxY;
HTuple  UpperLeftX, UpperLeftY, UpperRightX, UpperRightY;
HTuple  LowerLeftX, LowerLeftY, WorldLength1, WorldLength2;
HTuple  ScaleForSimilarPixelSize, ExtentX, ExtentY;
HTuple  WidthRectifiedImage, HeightRectifiedImage;

// perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, 'all',
                   &FinalCamParam, &NFinalPose, &Errors);
// world coordinate system is defined by calibration plate in first image
FinalPose1 = NFinalPose(0,6);
// compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.000073, &WorldPose);
// goal: rectify image
// first determine parameters such that the entire image content is visible
//   and that objects have a similar size before and after the rectification
// -> transform image boundary into world plane, determine smallest
//    rectangle around it
Image.GetImagePointer1(&Type, &Width, &Height);
HRegion  ImageRect = HRegion::GenRectangle1(0, 0, Height-1, Width-1);
HXLDCont ImageBorder = ImageRect.GenContourRegionXld("border");
Hobject  ImageBorderWCSObj;
contour_to_world_plane_xld(ImageBorder.Id(), &ImageBorderWCSObj,
                           FinalCamParam, WorldPose, 1);
HXLDArray ImageBorderWCS(ImageBorderWCSObj);
MinY = ImageBorderWCS.SmallestRectangle1Xld(&MinX, &MaxY, &MaxX);
// -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, &PoseForEntireImage);
// -> determine the scaling factor such that the center pixel has the same
//    size in the original and in the rectified image
//    method: transform corner points of the pixel into the world
//            coordinate system, compute their distances, and use their
//            mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2, Width/2,
                            1, &UpperLeftX, &UpperLeftY);
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2, Width/2+1,
                            1, &UpperRightX, &UpperRightY);
image_points_to_world_plane(FinalCamParam, PoseForEntireImage,
                            Height/2+1, Width/2,
                            1, &LowerLeftX, &LowerLeftY);
distance_pp(UpperLeftY, UpperLeftX, UpperRightY, UpperRightX,
            &WorldLength1);
distance_pp(UpperLeftY, UpperLeftX, LowerLeftY, LowerLeftX,
            &WorldLength2);
ScaleForSimilarPixelSize = (WorldLength1+WorldLength2)/2;
// -> determine output image size such that entire input image fits into it
ExtentX = MaxX-MinX;
ExtentY = MaxY-MinY;
WidthRectifiedImage = ExtentX/ScaleForSimilarPixelSize;
HeightRectifiedImage = ExtentY/ScaleForSimilarPixelSize;
// transform the image with the determined parameters
RectifiedImage =
  Image.ImageToWorldPlane(FinalCamParam, PoseForEntireImage,
                          WidthRectifiedImage, HeightRectifiedImage,
                          ScaleForSimilarPixelSize, "bilinear");

Example (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.0006, WorldPose)
*  goal: rectify image
*  first determine parameters such that the entire image content is visible
*    and that objects have a similar size before and after the rectification
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  transform the image with the determined parameters
image_to_world_plane(Image, RectifiedImage, FinalCamParam, \
                     PoseForEntireImage, WidthRectifiedImage, \
                     HeightRectifiedImage, ScaleForSimilarPixelSize, \
                     'bilinear')

Example (HDevelop)

*  perform camera calibration (with standard calibration plate)
camera_calibration(NX, NY, NZ, NRow, NCol, StartCamParam, NStartPose, \
                   'all', FinalCamParam, NFinalPose, Errors)
*  world coordinate system is defined by calibration plate in first image
FinalPose1 := NFinalPose[0:6]
*  compensate thickness of plate
set_origin_pose(FinalPose1, 0, 0, 0.0006, WorldPose)
*  goal: rectify image
*  first determine parameters such that the entire image content is visible
*    and that objects have a similar size before and after the rectification
*  -> transform image boundary into world plane, determine smallest
*     rectangle around it
get_image_pointer1(Image, Pointer, Type, Width, Height)
gen_rectangle1 (ImageRect, 0, 0, Height-1, Width-1)
gen_contour_region_xld (ImageRect, ImageBorder, 'border')
contour_to_world_plane_xld(ImageBorder, ImageBorderWCS, FinalCamParam, \
                           WorldPose, 1)
smallest_rectangle1_xld (ImageBorderWCS, MinY, MinX, MaxY, MaxX)
*  -> move the pose to the upper left corner of the surrounding rectangle
set_origin_pose(WorldPose, MinX, MinY, 0, PoseForEntireImage)
*  -> determine the scaling factor such that the center pixel has the same
*     size in the original and in the rectified image
*     method: transform corner points of the pixel into the world
*             coordinate system, compute their distances, and use their
*             mean as the scaling factor
image_points_to_world_plane(FinalCamParam, PoseForEntireImage, \
                            [Height/2, Height/2, Height/2+1], \
                            [Width/2, Width/2+1, Width/2], \
                            1, WorldPixelX, WorldPixelY)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[1], WorldPixelX[1], \
            WorldLength1)
distance_pp(WorldPixelY[0], WorldPixelX[0], WorldPixelY[2], WorldPixelX[2], \
            WorldLength2)
ScaleForSimilarPixelSize := (WorldLength1+WorldLength2)/2
*  -> determine output image size such that entire input image fits into it
ExtentX := MaxX-MinX
ExtentY := MaxY-MinY
WidthRectifiedImage := ExtentX/ScaleForSimilarPixelSize
HeightRectifiedImage := ExtentY/ScaleForSimilarPixelSize
*  transform the image with the determined parameters
image_to_world_plane(Image, RectifiedImage, FinalCamParam, \
                     PoseForEntireImage, WidthRectifiedImage, \
                     HeightRectifiedImage, ScaleForSimilarPixelSize, \
                     'bilinear')

Result

image_to_world_planeimage_to_world_planeImageToWorldPlaneimage_to_world_planeImageToWorldPlaneImageToWorldPlane returns 2 (H_MSG_TRUE) if all parameter values are correct. If necessary, an exception is raised.

Possible Predecessors

create_posecreate_poseCreatePosecreate_poseCreatePoseCreatePose, hom_mat3d_to_posehom_mat3d_to_poseHomMat3dToPosehom_mat3d_to_poseHomMat3dToPoseHomMat3dToPose, camera_calibrationcamera_calibrationCameraCalibrationcamera_calibrationCameraCalibrationCameraCalibration, hand_eye_calibrationhand_eye_calibrationHandEyeCalibrationhand_eye_calibrationHandEyeCalibrationHandEyeCalibration, set_origin_poseset_origin_poseSetOriginPoseset_origin_poseSetOriginPoseSetOriginPose

Alternatives

gen_image_to_world_plane_mapgen_image_to_world_plane_mapGenImageToWorldPlaneMapgen_image_to_world_plane_mapGenImageToWorldPlaneMapGenImageToWorldPlaneMap, map_imagemap_imageMapImagemap_imageMapImageMapImage

See also

contour_to_world_plane_xldcontour_to_world_plane_xldContourToWorldPlaneXldcontour_to_world_plane_xldContourToWorldPlaneXldContourToWorldPlaneXld, image_points_to_world_planeimage_points_to_world_planeImagePointsToWorldPlaneimage_points_to_world_planeImagePointsToWorldPlaneImagePointsToWorldPlane

Module

Calibration


ClassesClassesClassesClasses | | | | Operators