All times are in GMT -8 (DST) :: The time is now 8:02 pm.

Create an account and register your LMI products to gain access to useful resources.

Register Account

Knowledge Base
Article Data
Article Ref
2805-AJXC-3144
Date Created
Mon, 30th Apr 2018
Date Modified
Mon, 30th Apr 2018
Ticket Actions

## How do I get the Height value of a point in an image coming from a Gocator?

The process of getting the height information for a given pixel is the same as for the Gocator itself, and this works for X, Y and Z. The function is:

WorldValue = PixelValue * Resolution + Offset

In the case of Height, you get

Height = ZPixel * ZResolution + ZOffset

In HexSight, the XY values can be gotten directly with the ImageToWorld function, which uses the image calibration to compute it. For the Height, though, you first need to get the ZOffset and ZResolution, and then you can compute the Z value. We have this snippet that you can use, in C#:

```            HSImage lImage = mApplicationControl.Database.get_Image("Acquisition", "Image");
if (lImage != null)
{
// Retrieve calibration information
HSCalibration cal = lImage.Calibration;
float zo = 0;
float zr = 0;
for (short i = 0; i < cal.ParameterCount; ++i)
{
string s = (string)cal.get_ParameterName(i).ToString();
if (s == "ZOffset") zo = cal.get_Parameter(i);
if (s == "ZResolution") zr = cal.get_Parameter(i);
}

// Compute Height value for each pixel
for (int y = 0; y < lImage.Height; ++y)
{
for (int x = 0; x < lImage.Width; ++x)
{
int z = lImage.get_Pixel(x, y);
if (z != 0)
{
float X = x;
float Y = y;
cal.ImageToWorld(ref X, ref Y);

float Z = z * zr + zo;

// Do process
}
}
}
}```

You may notice that the ZOffset is different in the HexSight calibration than in the Gocator itself. This is due to how the image is presented. In the Gocator, the image contains values as a 16bit signed value (-32768 to 32767), while in HexSight, the image is represented as a 16bit unsigned value (0 to 65535). 