05-12-2025 01:37 AM
Hi everyone,
I'm working in LabVIEW using the Vision Development Module (VDM) and I want to use the Load Pretrained Model (.pb) option to perform inference with a TensorFlow model.
The model expects an input in the form of a 3D array with the format:[Rows][Columns][3]
(i.e., a color image with 3 channels — RGB).
I can read and display images using IMAQ ReadFile, but I'm unsure how to convert this image into the required 3D array format suitable for deep learning model input.
What I Need:
How do I convert a color image into a 3D array with shape [Height][Width][3]
in LabVIEW?
What I’ve Tried:
Loaded the image using IMAQ ReadFile
.
Used IMAQ ColorImageToArray
, which gives a 2D array of clusters containing RGB values.
I need help splitting those RGB values and reconstructing a 3D array where the third dimension is the color channel.
If anyone has done this before or can suggest the best way to achieve this in LabVIEW (2019), I would appreciate detailed steps or a block diagram.
Thanks in advance!
Solved! Go to Solution.
05-12-2025 03:46 AM
05-14-2025 12:51 AM - edited 05-14-2025 12:52 AM
I am working with a deep learning model that takes a color image as input. Before feeding the image to the model, I normalize the pixel values to be in the range
[0, 1]
. The input format is flattened and fed to the model accordingly.After inference, the model returns a 1D array of float values, also normalized between 0 and 1. Each group of three values in this array represents the R, G, B components of a single pixel. For example:
output[0:3]
→ RGB values of the 1st pixel
output[3:6]
→ RGB values of the 2nd pixeland so on...
Now I want to reconstruct the image and display it in LabVIEW. What is the best way to:
Convert this 1D array into a 3D RGB image array (e.g.,
[height, width, 3]
)Scale the pixel values back to
[0, 255]
(U8 format)Display the image using standard LabVIEW image display tools (like IMAQ image)
Any guidance or example VIs would be greatly appreciated!
05-14-2025 11:13 PM - edited 05-14-2025 11:17 PM
Hello,
I have a 1D NumPy array of size 49152, which is the output from my deep learning model. This corresponds to an RGB image of size 128×128 with 3 channels (i.e., 128 × 128 × 3 = 49152).
The array is structured such that:
The first 3 values represent the RGB values of the first pixel,
The next 3 values are for the second pixel, and so on.
I would like to convert this 1D array back into a proper color image
How can I do this
Thanks in advance!
05-14-2025 11:17 PM
Hello,
I have a 1D NumPy array of size 49152, which is the output from my deep learning model. This corresponds to an RGB image of size 128×128 with 3 channels (i.e., 128 × 128 × 3 = 49152).
The array is structured such that:
The first 3 values represent the RGB values of the first pixel,
The next 3 values are for the second pixel, and so on.
I would like to convert this 1D array back into a proper color image
How can I do this
Thanks in advance!
05-15-2025 01:23 AM
Hi sasimitha,
@sasimitha wrote:
I have a 1D NumPy array of size 49152, which is the output from my deep learning model. This corresponds to an RGB image of size 128×128 with 3 channels (i.e., 128 × 128 × 3 = 49152).
The array is structured such that:
The first 3 values represent the RGB values of the first pixel,
The next 3 values are for the second pixel, and so on.
I would like to convert this 1D array back into a proper color image
How can I do this
What have you tried and where are you stuck?
05-15-2025 02:30 AM
According to the documentation of IMAQ DL Model Run VI, you use the dimension output to reshape the flat array. Then I imagine you use IMAQ ArrayToColorImage VI to convert it to an image, but I do not have experience with the vision module.
05-15-2025 12:58 PM
I threw this together (but didn't try it out). Let me know if it works.