Image Processing with Python OpenCV in LabVIEW

Updated Jun 23, 2025

Reported In

Software

  • LabVIEW

Issue Details

Customer is trying to perform image analysis using Python OpenCV and he would like to display the image in LabVIEW with Python node.

Solution

OpenCV types in Python typically map to numpy arrays. You can use below command to achieve the objective.

def process_image(image_path):
image = cv2.imread(image_path)
processed_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
return processed_image

 

Here the processed image is returned in the form of a numpy 2D array with type np.uint8, assuming the original image was 2D as well. As shown in below example, in LabVIEW you would just use a 2D uint8 array as return type for the Python node. You can then use Flatten Pixmap.VI to convert the image data to an image data cluster. You would also need to define a grayscale colormap with RGB to Color.VI