05-14-2003 12:10 PM
05-14-2003 03:04 PM
05-14-2003 07:21 PM
05-14-2003 07:58 PM
05-15-2003 02:34 PM
05-15-2003 02:40 PM
05-15-2003 03:18 PM
04-07-2023 06:47 PM
In the new era of AI and Python, it is easy to do things like this. I looked up this very question here first, but no help. I then asked for the python code from chatGPT, and voila, problem solved. (In my LabVIEW 2019, I also updated the allowed version of python, to 3.10, but it works fine.) Just passing along a useful tip for those still looking!
07-28-2023 08:10 AM - edited 07-28-2023 08:12 AM
@Rod.Loewen wrote:
In the new era of AI and Python, it is easy to do things like this. I looked up this very question here first, but no help. I then asked for the python code from chatGPT, and voila, problem solved. (In my LabVIEW 2019, I also updated the allowed version of python, to 3.10, but it works fine.) Just passing along a useful tip for those still looking!
For those trying out @Rod.Loewen's code, LV2018 does not support numpy.ndarray as a return type (maybe newer versions do). You'll get following error:
Python returned the following error: <class 'SystemError'> g:\a\3\s\objects\listobject.c:189: bad argument to internal function site:forums.ni.com
I think that's what Rod is trying to achieve in the second part of his python code, but that just copies the first numpy.ndarray to a new numpy.ndarray.
Working and verified code:
import numpy as np
from matplotlib import pyplot as plt
def read_png(path: str):
# Load the PNG image using matplotlib.
img = plt.imread(path)
# Convert the image to a 16-bit integer array using numpy.
img_16bit = (img * 65535).astype(np.uint16)
# LabVIEW (2018 at least) doesn't support np.ndarray.
# Convert to list of lists.
return img_16bit.tolist()