02-14-2014 07:04 PM - edited 02-14-2014 07:05 PM
I'm new to using LabVIEW for image applications and am trying to capture grayscale images. Because I'm feeding them into a queue, I need to convert the LabVIEW image file to a 2D array which I can pass into the queue.
The VI "IMAQ ImageToArray" seems ideal for this purpose, however, when I capture grayscale images in U16, I receive an error that the image I'm passing in is an invalid image type. Using "IMAQ ColorImageToArray" works when I'm capturing in U32 and U16, but is unnecessary as I don't need RGB, only grayscale. Ideally, I would be saving a simple 2D array of values from 0 to 255 which could easily be read into other programs.
When I save the U32 pixel data to a binary file and try to read it into Matlab (using fread(fid,[rows,columns])), about every fourth row of data is all zeros.
I've attached a simplified VI of what I'm doing, as well as what the image looks like in Matlab. Am I missing something in terms of U32/U16 data types? Any suggestions? Many thanks in advance.
02-17-2014 02:00 AM
Hi tm473,
Perhaps you could try something like the following link: https://decibel.ni.com/content/docs/DOC-32568.
After you convert the colour image to greyscale image, perhaps you can use the "IMAQ ImageToArray" to convert that grescale image back to array.
Hope that helps
Warmest regards,
Lennard.C
02-17-2014 07:07 PM
Hi Lennard,
Thanks very much for your response! Unfortunately the link isn't working for me.
While I didn't actively solve the image-->array-->image issue I was having, for reference for others, I changed my architecture to follow this example: https://decibel.ni.com/content/docs/DOC-25670
Best,
Tracy
02-17-2014 07:12 PM
Hi tm473,
Actually the reason why it can't work is because of the full stop at the end of the link (not sure why the forum thinks this is a part of the link). Try this amended link:
https://decibel.ni.com/content/docs/DOC-32568
Hope that helps
Warmest regards,
Lennard.C
02-17-2014 11:26 PM
Thanks, Lennard.
02-18-2014 12:34 AM
Hi tm473,
I was able to modify the examples from the link I have given as shown below:
However, I was only able to get U8 data array from the grey scale. I doubt converting it to U32 would make much of a difference either.
Hope that helps
Warmest regards,
Lennard.C