LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview 8.5.1's MathScript window failed running imread with an error "A problem occurred in a subVI call."

Hi,

I am trying to port a Matlab program into a MathScript script.  Following is the first few lines of the script:

clear;
image1=imread('C:\LV_VertAlign\DSC_0104.jpg','jpg');
image_double1=im2double(image1);
image_gray11=rgb2gray(image_double1);

In the first line, imread is supposed to read in a photo taken from a DSLR camera, so I think it's a 32-bit image.  And this is the error I got when trying to run this script in the Labview 8.5.1's Mathscript windows:

"Error in function imread at line 2.  A problem occurred in a subVI call."

What is the problem here?  and why does it complain about a subVI call?

Thanks for any help to point me in the right direction.

-Anh
0 Kudos
Message 1 of 4
(3,286 Views)
Hi Anh,
 
             We have documentation on many of the MathScript functions available in LabVIEW.  You can look at a document here that describes how to use the imread function.  This is searchable from ni.com by entering the function name.  If you read this document you will see the second parameter of the function only accepts the following arguments : 'BMP', 'JPEG', 'PNG'.  If you change your line 2 to : image1=imread('C:\LV_VertAlign\DSC_0104.jpg','JPEG');  you should have no problem.  Have a great day.
Regards,
Jim M
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,268 Views)
Hello Anh,

As you may know, LabVIEW MathScript is implemented on top of LabVIEW.  The error message you received indicates that a problem occurred in one of the LabVIEW subVIs that MathScript calls.  As Jim indicated, the problem is in the file type specifier you passed to the function.  MathScript requires the use of 'JPEG' and not 'jpg' or even 'jpeg.'  In this case, we could return a better error message.  I have filed a bug report (115804) for this issue.

You will find that once you fix this, the im2double and rgb2gray functions are not supported.  In LabVIEW MathScript, you generally can execute scripts written in the MATLAB® language syntax.  However, the MathScript engine executes the scripts, and the MathScript engine does not support some functions that the MATLAB software supports.

We will look into adding these functions in a future release of LabVIEW MathScript.  If you need this functionality now, these functions are very simple to write yourself.  If you are performing additional image analysis in your script, you may wish to purchase the IMAQ toolkit.  It doesn't add any functions to MathScript at this time, but you could continue your analysis outside of MathScript with LabVIEW VIs.

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

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 3 of 4
(3,263 Views)
Thanks Jim and Grant for the info.  It works fine after changing the file type to JPEG.

Too bad I wont be able to use imread to read in my photo which is about 3 megapixels, since imread caps out at 1 megapixel.

-Anh
0 Kudos
Message 4 of 4
(3,244 Views)