Skip to content
← All questions

How to obtain the width and height of an image in HALCON?

To obtain the width and height of an image in HALCON, you use the get_image_size operator. You pass the loaded image variable as an input, and declare Width and Height variables as outputs to receive the pixel dimensions.

Conditions

  • The image must already be loaded into a variable (e.g., using read_image).
  • The operator get_image_size is called in the HDevelop environment.

Reasoning, step by step

  1. Load an image into a variable, e.g., read_image (Image, 'printer_chip/printer_chip_01').
  2. Call the get_image_size operator: get_image_size (Image, Width, Height).
  3. Execute the code.
  4. Check the control variables panel to see the assigned values for Width and Height.

Example

The code editor displays get_image_size (Image, Width, Height). After running, the variable panel shows Width with value 1600 and Height with value 1200.

Common misconceptions

  • Assuming you need to manually calculate the dimensions from the image array.
  • Forgetting to declare the output variables Width and Height before calling the operator.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.