Image enhancement using LabVIEW - matlab

I'm trying to make a program to enhance an image in LabVIEW. I have already program in matlab codes, but its some built-in functions are not working in LabVIEW since it is not present in LabVIEW mathscript module. The algorithm used to enhance the image is written below
input image in RGB
Contrast stretching of the model
RGB to HSI
contrast stretching of S&I
display the RGB image
So please help to implement this algorithm in LabVIEW

MATLAB can make a dll from your m file (including all of your built-in functions) and then you can call that dll from your Labview. To do so, you need to install MATLAB Compiler Runtime (MCR) on your machine (You don't need that, if you have already installed MATLAB).
If you want to have standalone dll file (not using matlab runtime), you need to use MATLAB Coder (which probably you need to buy it).
I recommend to use MCR first because it is easier to start with and more flexible in using MATLAB features.

Related

How to call function from opnet [duplicate]

I have some code that plots triangles in MATLAB.
I need to be able to somehow execute this code from my C program which generates these points.
Is that possible? How can it be done?
Just a thought:
Can I somehow embed MATLAB code in C, so that it can compile on a C compiler?
The Mathworks site has full details; a demo video of calling the Matlab engine from C, and also the Matlab to C Compiler.
As mentioned previously by answerers, you can call a live copy of MATLAB from C via the MATLAB Engine interface.
If the end-product needs to be used where there is no live copy of MATLAB, you can deploy the application using MATLAB Compiler. However, MATLAB Compiler does not, as another answer has suggested, convert MATLAB programs into C code (and hasn't done for a few versions now). Instead, it archives and encrypts your MATLAB program, and packages it into an executable or shared library that executes against the MATLAB Compiler Runtime (shareable royalty-free). The executable or shared library can then be called from C.
Alternatively you could go the other way around, and call your C code from MATLAB, using either loadlibrary or MATLAB's MEX interface.
Update: As of release R2011a, you can also use MATLAB Coder to generate C code directly from a subset of the MATLAB language.
Look at this presentation about integrating MATLAB Algorithms in C or C++ Applications http://www.mathworks.com/videos/integrating-matlab-algorithms-in-c-or-c-applications-86431.html

Data from LabVIEW to Matlab for processing

I want to make a biometric identification system of the ECG/EKG.
Provided that Matlab does not perform Data Acquisition in Real Time (for monitoring), is there any way to make the monitoring and data acquisition in LabVIEW and then work simultaneously with Matlab for signal processing?
You could just get a matlab compatible daq and run everything in matlab. http://www.mathworks.com/products/daq/
You can indeed do some data acquisition with LabView and work simultaneously with Matlab for signal processing by calling the Matlab script node, which executes some Matlab code during vi execution.
You may have some performance issues, though, because both Labview and Matlab have to run on your machine simultaneously.
Question:
is there any way to make the monitoring and data acquisition on
LabView and then work simultaneously with Matlab for signal processing
Answers:
LabVIEW has "MathScript" node which is basic MatLab built into
an add-on. It is not the MatLab toolboxes. It runs native MatLab
code. It also runs slightly faster LabVIEW updates to the code. If
your code runs there, then LabVIEW will pass data natively
to your code. This box does not have direct MatLab toolbox access, so if
you use any special calls then that can cause a problem.
If you have MatLab on the box, then you can call the external MatLab
function/code using mathscript (link), and the MatLab will run
the function.
Clarification:
Real time just means "bounded time" (link), not "instant". If your idea of bounds are loose enough then many systems can work for them. You do not state it in your question - but what do you consider acceptable response time?
I've worked a lot with LabVIEW and Matlab. Personally, I would not use the Math Scripting node and would opt for using the Matlab Automation Server. You can call Matlab from LabVIEW using the ActiveX palette in LabVIEW (See Functions>>Connectivity>>ActiveX>>Automation Open) A couple reasons why I'd go for ActiveX and NOT the MathScript node:
The Math Script node does not allow you to change code dynamically. You must hardcode your data into the Math Script node and any future changes would require a change to LabVIEW's G code and therefore a recompile of your EXE
The Math Script node does not support all functions when compiled to an executable. Most notably graphing functions. See the help file here to read more on this.
Calling Matlab from ActiveX is going to give you a lot more flexibility in regards to how data is passed and processed.

Which version of Matlab Simulink Control System Toolbox include LQR

I have tried some matlab version (2011a, 2012b, and 2015a). The 2012b doesn't include the Control System Toolbox inside Simulink Library. The 2011a and 2015a do include the Control System Toolbox inside Simulink Library. But these Control System Toolboxes don't include LQR.
Do you know which version of Matlab that has the LQR in the Simulink Control System Toolbox?
Thank you!
For the MAthworks On-line Documentation, LQR is available in Matlab 2015a. Have a look at this
Edit31.03.2015
Well, what you can do is build it yourself. just drug and drop the basic blocks to build the control structure, create a subsystem and in the mask, you can initialize to to automatically calculate the LQR.
What you are saying doesn't make sense. There is no such thing (and never has been) as an LQR block. Can you show us which block you're talking about?
You need to compute your LQR controller in MATLAB using functions such as lqr, which have been part of the Control System Toolbox for ages, and then use the LTI block to include your controller into your Simulink model.
Note: what toolbox is and is not included in a release depends on your license, not on the release. What you are saying about R2012b not including the Control System Toolbox in Simulink doesn't make sense.

Distribute matlab functions without source

I have written a set of Matlab functions and I want to distribute it to few people for testing. But I do not want to reveal the source to them. All these people have matalb installed on their systems. So I don't want to make standalone executable from my functions. Ideally I want something like complied library files which the users can put in the matlab path & call the functions from their matlab prompt / matlab functions. Is it even possible ?
Edit: I have matlab compiler toolbox. But the users won't be having access to matlab compiler toolbox on their matlab.
The standard way is using pcode. Look in the docs and remember to keep a copy of the source code elsewhere!

convert matlab code to c code

is there s a way to convert simulink blocks or a matlab ".m" code to C code automatically ?
I'm not aware of any direct translation tool, but there are a few alternatives:
Matlab Compiler will let you create a shared library (callable from C code) from your .m code.
GNU Octave is an open source interpreter that has many of the same functions as Matlab. It is open source, and written in C. You might feasibly build a C library based on on this, although it would be a lot more heavy-weight than option (1).
To convert Simulink models or MATLAB m-code to C you need Real-Time Workshop.
It supports only subset of MATLAB language and oriented for embedded systems.
Look also at other MatWorks products for code generation and application deployment:
http://www.mathworks.com/products
With MATLAB Compiler you will not get a C code, but a binary code, executable or library (dll), which will run on machines without MATLAB installed, but with MATLAB Compiler Runtime (MCR) library. It quite large in size, and platform specific and I believe it has to match the MATLAB version of compiled code.
For the new coming release 2011a The MathWorks developed new code generation products: MATLAB Coder, Simulink Coder and Embedded Coder.