LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matlab speed optimization

Hello,
 I am using a pci - 1411 to do real time image processing. I am doing the processing in matlab and using labview to acquire the raw image data.
 
 My problem is that there is a huge time delay in the matlab portion of my code. I think perhaps invoking matlab is killing me.
 
 Any hints on how to speed this process up? Should I call labview from matlab?
 
Thanks,
Ruz
 
Please find attached labview file.
0 Kudos
Message 1 of 15
(4,003 Views)
As a follow up to my previous post. I believe converting my acquire image data vi into a mex file will speed the process up, but I am not 100% sure. Can  anyone shed any light on this.
 
Thanks,
Ruz
0 Kudos
Message 2 of 15
(3,979 Views)
Hello,

Is the acquired image data U8?

The conversion of the integer data to float data at the Matlab terminal costs time, specially when having huge arrays.

After that the array is converted again to U8, probably also takes a lot of time.

Try to get a way around that.

Regards,

André
Regards,
André (CLA, CLED)
Message 3 of 15
(3,957 Views)
 

Hi Ruz,

Thanks for posting to the NI forums!  Why don't you do the image processing with LabVIEW VIs?  That would remove the ActiveX transfer of data between programs, and reduce your execution time.  These VIs are available with the Vision Development Module.  Also, you could inline a .m script file with the MathScript functionality in LabVIEW, which would also remove the data transfer.

Regards,

 
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 4 of 15
(3,940 Views)

Hi. In response to...

"The conversion of the integer data to float data at the Matlab terminal costs time, specially when having huge arrays. "

Yes, I would agree with that. However, the Matlab Script Node in Labview does not have the ability to change the input type to an 8 bit type.

Unless you know of a way ?

 

 

0 Kudos
Message 5 of 15
(3,926 Views)
 

Hi Maclean.

You stated.

Thanks for posting to the NI forums!  Why don't you do the image processing with LabVIEW VIs?  That would remove the ActiveX transfer of data between programs, and reduce your execution time.  These VIs are available with the Vision Development Module.  Also, you could inline a .m script file with the MathScript functionality in LabVIEW, which would also remove the data transfer.

I am not using the image processing VI's because they have limited functionality and variety compared with matlab. In my case I am trying to do a histogram equalization, but labview only allow me to do a normal distribution one, whereas in matlab I can do an "tiled version" of histogram equalization which gives much better results.

Mathscript is nice, but I am trying to use built-in matlab functions. I could attempt to code the algorithm from scratch, but the function source code in matlab is not public.

What are your feelings on converting the labview acquisition of images in matlab to .mex functions? From what I am reading this can be done with the  Math Interface toolkit and claims to be able to speed up this sort of processing.

0 Kudos
Message 6 of 15
(3,921 Views)
Hi Ruz,

The increase in efficiency from using .mex functions is entirely dependent on your code.  I would try converting the acquisition step to .mex functions, and see if the speed improves.

Regards,
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 7 of 15
(3,880 Views)

Hi MacLean,

 Is it possible that I can give you the VIs to convert for me ? I want to test it out first before I purchase the math interface toolkit for 500.

Please advise,

Ruz

0 Kudos
Message 8 of 15
(3,855 Views)
Hi Ruz,

I can indeed convert them for you. Are you comfortable posting your code on the forum?
Maclean G.
Applications Engineering
National Instruments
0 Kudos
Message 9 of 15
(3,824 Views)
Hi MacLean,
   Yes, no problem posting my code. Please find the following files in the zip file.
 
   The original VI I created (original.vi) The VI starts an image acquisition grab within a while loop. Matlab is called from the script node.
 
   I am a little unsure about  how to call the VI from a text base environment so what I did was break the VI up into 3 vi's.
 
   I think the 3 vi's can then be called within matlab, and the image grab done from within a matlab while loop.
 
  I'll also do a little research on this myself regarding labview and mex files.
 
 Thanks
 Ruz
 408-754-2142
 
 
0 Kudos
Message 10 of 15
(3,817 Views)