# Create2dHeightMapFromPointCloud

The Create2dHeightMapFromPointCloud function Functions are tools that are available in Spreadsheet for processing and analyzing acquisitions or other results. You can add functions to your Spreadsheet job to create tool chains and produce results for specific applications. allows you to create a relative height map of all points within a Region of Interest (RoI) in the point cloud A point cloud is a 3D structure that consists of the data points collected by a 3D vision system during acquisition.. The height map translates the relative height of each point in the RoI to a greyscale value between 0 and 255, allowing you to visualize the differences in height between the points. The function returns an Image structure containing a 2D height map image.

The Create2dHeightMapFromPointCloud function is particularly useful in OCR applications, as it is capable of clearly highlighting the small features of embossed or engraved characters.

Input Point Cloud | Output Height Map

Inputs

The Create2dHeightMapFromPointCloud function has the following syntax:

Create2dHeightMapFromPointCloud(PointCloud A point cloud is a 3D structure that consists of the data points collected by a 3D vision system during acquisition.,Fixture3D,ExternalFixture,Region3D,ExternalRegion,FeatureWidth,FeatureHeight,ProjectionMode,AutoAdjustBoxZRange,MatchInputResolution,RequestedPixelResolutionX,RequestedPixelResolutionY,DefaultMissingPixelHeight,Show)

Parameter | Description
PointCloud | Reference to a cell containing a point cloud. The default value is $A$0.
Fixture3D | Specifies the point cloud coordinate system in which the 3D fixture A fixture is a coordinate location on the image that keeps the tool in the place determined by the fixture. is defined. It is offset from the PointCloud origin in the following format with the following arguments: {X, Y, Z, Rotation, Tilt, TiltDirection}
X | Offset on the X-axis from the PointCloud origin.
Y | Offset on the Y-axis from the PointCloud origin.
Z | Offset on the Z-axis from the PointCloud origin.
Rotation | Specifies the in-plane rotation in degrees around the PointCloud Z-axis. The value range is -180 to 180. The tool normalizes external references with values outside the allowed range to the allowed range.
Tilt | Specifies the tilt angle in degrees from the PointCloud Z-axis after rotation. The value range is 0-180. External references with values outside the allowed range result in an error.
Tilt Direction | Specifies the direction of tilt in degrees from the rotated PointCloud X-axis of the tool, around the PointCloud Z-axis of the tool. The value range is -180 to 180. The tool normalizes external references with values outside the allowed range to the allowed range.
Note: The Fixture3D parameter is only available if you set External Fixture to 0. Note: You can use the Fixture3D parameter to set the ROI fixture.
External Fixture | Specifies a reference to a Fixture3D structure defined in another cell. The function uses the referenced cell as the fixture of the function. Set to 0 (OFF) to use the internal fixture of the function instead.
Match Grey Image Size | Match the height map image size to the greyscale image size.
Box3D | Specifies the dimensions, offset and angle for the 3D rectangle of the function. It is offset from the PointCloud origin in the following format with the following arguments: {SizeX, SizeY, X, Y, Z, Rotation, Tilt, TiltDirection}
SizeX | The size of the box along the X-axis of the PointCloud. The value range is 0.001 to inf., and the default value is 100.
SizeY | The size of the box along the Y-axis of the PointCloud. The value range is 0.001 to inf., and the default value is 100.
SizeZ | The size of the box along the Z-axis of the PointCloud. The value range is 0.001 to inf., and the default value is 100.
X | Offset on the X-axis from the PointCloud origin. The value range is -inf. to inf., and the default value is 0.
Y | Offset on the Y-axis from the PointCloud origin. The value range is -inf. to inf., and the default value is 0.
Z | Offset on the Z-axis from the PointCloud origin. The value range is -inf. to inf., and the default value is 0.
Rotation | Specifies the in-plane rotation of the box (in degrees) about the PointCloud Z-axis of the tool. The value range is -360 to 360. External references with values outside the allowed range will be normalized to the allowed range.
Tilt | Specifies the tilt angle of the box (in degrees) from the PointCloud Z-axis of the tool. The value range is 0 - 180. External references with values outside the allowed range will result in an error.
Tilt Direction | Specifies the tilt direction of the box (in degrees) from the rotated PointCloud X-axis of the tool, about the PointCloud Z-axis of the tool. The value range is -360 to 360. External references with values outside the allowed range will be normalized to the allowed range.
Note: This parameter is available only if External Box is set to 0.
External Box | Specifies a reference to a 3D region defined in another cell. The function uses the referenced cell as the Region of Interest of the function. Set to 0 (OFF) to use the internal Box3D structure of the function as the ROI.
Projection Mode | Specifies the method of calculating the relative height of the points in the point cloud. The available values are the following: Flex Inspect - calculates the height of points relative to the surrounding points in the point cloud. This setting is useful when extracting characters on an uneven surface. Plane Inspect - calculates the height of points relative to a local plane using the surrounding planar points in the point cloud. This setting is useful when extracting characters on a flat surface, such as VIN characters on an engine block. Curve Inspect - calculates the height of points relative to a curved surface. The function calculates an expected curve from the point cloud data, using that curve as a reference for point height calculation. This setting is useful when extracting characters on a curved surface, such as characters on a tire for TireDOT reading. Height Map - calculates the height of points relative to the bottom plane of the Region of Interest.
Feature Width | Specifies the expected width in millimeters of a typical feature of interest. The Feature Width parameter defines the resolution of the height map. Note: For OCR applications, the character stroke width defines the Feature Width setting. For example, if the character stroke is 1 mm, set the Feature Width to at least 0.25 mm in order to get good character resolution in the height map.
Feature Height | Specifies the expected height in millimeters of a typical feature of interest. The Feature Height parameter defines the sensitivity of the height map.
Auto Adjust Box Z Range | Specifies whether to automatically adjust the Z range of the RoI box to start with the height of the lowest point. This setting only applies when using Bottom of Region as the value for Projection Mode.
Match Input Resolution | Specifies whether to match the height map pixel size to the native resolution of the point cloud. Enabling this setting disables the Requested Pixel Resolution X and Requested Pixel Resolution Y settings.
Requested Pixel Resolution X | Specifies the number of pixels corresponding to the Feature Width value on the X axis. For example, if Feature Width is defined as 1 mm, and Requested Pixel Resolution X is defined as 5, then the output height map will have 5 pixels for 1 mm on the X axis. Note: If you change the value for Requested Pixel Resolution X, make sure to adjust the Requested Pixel Resolution Y parameter as well. Otherwise, the aspect ratio of the image is distorted.
Requested Pixel Resolution Y | Specifies the number of pixels corresponding to the Feature Width value on the Y axis. For example, if Feature Width is defined as 1 mm, and Requested Pixel Resolution Y is defined as 5, then the output height map will have 5 pixels for 1 mm on the Y axis. Note: If you change the value for Requested Pixel Resolution Y, make sure to adjust the Requested Pixel Resolution X parameter as well. Otherwise, the aspect ratio of the image is distorted.
Default Missing Pixel Value | Specifies the default height map value for pixels without any point cloud data. For example, if the Default Missing Pixel Value is 0, any pixels that do not contain point cloud data are shown as black.
Height Mode | Specifies whether the height map pixel value represents the Average, Minimum, or Maximum point value.
Show | Selects the type of graphics to overlay on the image.
0 = hide all (default) | All graphics are hidden, except when the cell containing the function is highlighted in the spreadsheet.
1 = result graphics only | The result graphics of the function are displayed at all times.
2 = input and result graphics | The region of interest, the input data and the results are displayed at all times.

Outputs

The Create2dHeightMapFromPointCloud function returns an Image structure containing a 2D height map image.

How to convert 2D height map images to pixel coordinates

The Create2DHeightMapFromPointCloud function can produce inconsistent results depending on whether the Tilt input parameter takes a zero or non-zero value. If the Tilt value is 0, the function returns a calibrated image. Otherwise, the image is uncalibrated and operates in pixel coordinates.

Use the CalibrateImage function that references the 2D height map image with a 0 value for the Calib parameter to convert calibrated images to pixel coordinates. Uncalibrated images are unaffected. This way, CalibrateImage always returns an uncalibrated image, which operates in pixel coordinates.

Converting calibrated images to pixel coordinates ensures that the results are consistent when you use another 2D function with the 2D height map image. The following example and image demonstrates how to use the CalibrateImage function:

- The B3 cell contains a 2D height map created from the Point Cloud in A0.

- The B5 cell contains: CalibrateImage(B3,0)

- The B8 cell contains a DetectBlobs function that references the B5 cell with the uncalibrated image.

- The B12 cell contains a DetectBlobs function that references the B3 cell with the 2D height map image that can be either calibrated or uncalibrated.

- The area of the blobs that reference the B5 cell with the CalibrateImage function are always in pixel coordinates. These are in the F8 and F9 cells.

- The area of the blobs that reference the B3 cell are either in pixel coordinates or calibrated world coordinates, depending on the Tilt of the Box3D parameter of the 2D height map image. These are in the F12 and F13 cells.

Note: If you want to transform 2D regions to 3D regions from a 2D height map image, ensure that the Tilt value is 0. You can only create 3D regions from calibrated images.