Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

image file as matrix

I need to treat an image file as a matrix where the elements are the grayscale values of each pixel. I have the following problem: given a measured image M, a constant matrix, L, and a unknow matrix K, their relationship is M.K = L, where K is the unknown matrix to be determine: K = M^-1.L

In order for me to do the above operations, I think I need to know how to convert a image file(jpg, bmp, tiff, etc) to an ASCII file of grayscale values(in a 2 dimensional matrix form). Please advice.
0 Kudos
Message 1 of 2
(3,048 Views)
I'm not sure what you are trying to do with it, but I can tell you how to do it.

If you are using IMAQ Vision, you need to use IMAQ Image to Array to convert the image to a 2D array. Once you have a 2D array, you can use array to spreadsheet string and write string to file to save it as an ascii file.

If you aren't using IMAQ Vision, you can use the picture controls to load the image. Unflatten the output of the load image vi to get a 2D matrix, and continue as before.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 2 of 2
(3,048 Views)