LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab script image support?

Hi there,
I'm trying to use the imread function in the matlab script node to translate an 8-bit image into a intensity-value matrix. It works in normal matlab, but not in the node. I can't find the imread function in any of the labview help menus, so I was wondering if labview supports that function at all. If not, does anyone have any suggestions for automating getting the image into matrix form? Thank you,
Stephanie

0 Kudos
Message 1 of 7
(9,570 Views)

I'll qualify my response by saying I'm not a MathScript or Matlab expert, but I'm pretty sure the imread function in Matlab is part of the Image Processing Toolbox.  You probably have this toolbox installed for Matlab and may not have even realized it.  I don't think MathScript natively supports functions in addons of this sort.  Perhaps someone else will have some ideas on how you might still be able to use MathScript, but if you need imread I'm not sure if MathScript will work for you or not.

Good luck!

0 Kudos
Message 2 of 7
(9,564 Views)
Hello Stephanie,

Are you using the same script in the node as you use in the MATLAB® software?  What is the error returned by the node?  Are you running the VI on the same machine where you tested the script in the MATLAB software?  The imread function does seem to be part of the Image Processing Toolbox, so you will need to ensure that this toolbox is installed on any machine that you intend to use to run your VI.

The LabVIEW MathScript node is a textual node and its syntax is generally compatible with the m-script syntax used by other technical computing software.  Jeff is correct in that LabVIEW MathScript does not currently support the imread function.  However, it will likely be added in a future version of LabVIEW.  If you are looking for a solution in graphical code, LabVIEW does provide some VIs for reading and writing PNG, JPEG, and BMP files.  You can find the VIs in the Programming >> Graphics & Sound >> Graphics Formats palette.  You can then use the Unflatten Pixmap VI to get a matrix representation of your image.

National Instruments also produces a Vision Development Module for LabVIEW that includes more advanced image acquisition (IMAQ) and image processing functionality.  This module is more for industrial and scientific use than for duplicating what might be provided in desktop image manipulation programs.

MATLAB® is a registered trademark of The MathWorks, Inc.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
Message 3 of 7
(9,558 Views)
Thank you both for your help! I tried using the unflatten pixmap.vi and now I am getting "Error message 1: NI-488:  Command requires GPIB Controller to be Controller in Charge." I know this is now outside the scope of this thread, but any advice for that? I'm not taking in images from a camera, but using them from files, so I don't know how a GPIB is involved. Thank you,
Stephanie
0 Kudos
Message 4 of 7
(9,531 Views)
I forgot to mention that I'm using it in tandem with the Read JPEG File.vi
Stephanie
0 Kudos
Message 5 of 7
(9,530 Views)
Hi Stephanie,

Do you know which VI is creating that error.  The unflatten pixmap.VI doesn't have any error handling associated with it.  So, if that VI is creating the error, then that would explain why the message is so generic.  I was able to use the VI without any problem.  Would you be able to post an image that is causing this issue, and I could try it out?

Thanks,
0 Kudos
Message 6 of 7
(9,527 Views)

Hello Stephanie,

Historically, some error codes were (unfortunately) overloaded to give different error messages in different situations.  I presume that the error is coming out of the "Read JPEG File.vi"?  Clearly, as you've noticed, this shouldn't generate a GPIB error.  🙂  The LabVIEW error message for error 1 should read something like "An input parameter is invalid..."

Now if you'd sent the read function an invalid path, you should have gotten a more helpful error 7, file not found.  Error 1, if being returned by "Read JPEG File.vi", might indicate that there was a problem reading the file at the path you specified.  Perhaps it is not really a JPG file, or maybe it is a variant of the JPG format that LabVIEW doesn't understand, I'm not sure.

Anyway, as JeffreyP said, if you can post an example VI (including the JPG file you're trying to read) we could give a more definitive answer.

Good luck!

0 Kudos
Message 7 of 7
(9,521 Views)