LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Capturing grayscale images and writing U32 data to binary file?

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.

0 Kudos
Message 1 of 6
(3,978 Views)

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 

Learning new things everyday...
0 Kudos
Message 2 of 6
(3,919 Views)

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

0 Kudos
Message 3 of 6
(3,899 Views)

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

Learning new things everyday...
0 Kudos
Message 4 of 6
(3,894 Views)

Thanks, Lennard.

0 Kudos
Message 5 of 6
(3,878 Views)

Hi tm473,

 

I was able to modify the examples from the link I have given as shown below:
Greyscale.JPG

 

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

Learning new things everyday...
0 Kudos
Message 6 of 6
(3,869 Views)