07-15-2009 09:43 AM
I am trying to pass an image into matlab from labview. To be exact, I am trying to take the image from labview, pass it into matlab, put it through a piece of matlab code which does some processing, and send the solution back to be displayed into labview. I know about the matlab script node, but I dont know how to send the image into it. So i guess my questions are
1) How do I pass the image into the matlab script node?
2) Does the image have to be saved in order to pass it in, or can I do it live also?
Attached is the VI I am using to grab the images, and the matlab code I am using to process the image.
07-15-2009 10:22 AM
Matlab expects to deal with arrays, so if you plan on using the Matlab script node inside your LabVIEW code then you need to convert the image to an array of data, and you also need to make sure it's in the format expected by that function that you have. I don't know if you have just NI-IMAQ, or the full-blown NI Vision. You should check the documentation for what you have for converting an image to an array.
Alternatively, since you are saving the image to file, you can have the Matlab script read the file with the IMREAD function.
07-15-2009 10:25 AM
07-15-2009 10:48 AM
07-15-2009 11:06 AM
Ok i put a line of code in the matlab script and nothing happens. I probed it and the image is going into the node but nothing happens.
07-15-2009 11:19 AM
Here is just a simple snap that I am experimenting with. I attached the VI (which is not working). To get this straight though, as long as the function is saved on the computer, the code should work in the script node right?
07-15-2009 11:23 AM
07-15-2009 11:40 AM
bonesaw,
I assume your SpotAnalyzer is your own function, meaning you must save it to the default directory in MATLAB or set MATLAB to include it in its search path.
Most importantly, your code will not work because the name of the input variable to the MATLAB script node is 'image', and in your parameter to your function, there is no mentin of the variable 'image', though I am not exactly sure if your function SpotAnalyzer is a script file or a function.
One more important thing is that MATLAB uses double as defualt, so you must pass a double array to the MATLAB script, and vice versa.