ROI hand vein detection in Visual C code into Matlab codeHi all,
Anyone could help me on translate this programming ROI detection written in Visual C into Matlab?
Actually this code about hand vein ROI extraction.
Thank you
//********************************ROI DETECTION***************************/
//surfaceIn-filled image (extracted finger region)
//surfaceOriGray-original grayscale image
//surfaceOut0-align filled image
//surfaceOut-align segmented grayscale image
void putBackAlignResize(SDL_Surface *surfaceIn, SDL_Surface *surfaceOriGray, SDL_Surface *surfaceOut0,SDL_Surface *surfaceOut, unsigned int refPointX, unsigned int refPointY)
{
//size of original image (320*240)
unsigned int width = surfaceIn->w;
unsigned int height= surfaceIn->h;
//size of resize image (320*150)
unsigned int widthResize = surfaceOut->w;
unsigned int heightResize= surfaceOut->h;
//looping parameter
unsigned int i=0, x=0, y=0;
int x1=0,y1=0; //negative, use int (cant reuse x & y)
//find reference point for finger
unsigned int fTipCoorX=0, coorY[2]={0,0},middleX=0, middleY=0;
//delta x & y for alignment
int tx, ty;
unsigned int **arraySurfaceIn, **arraySegment;
unsigned int **arraySurfaceInAligned, **arraySegmentAligned;
arraySurfaceIn= (unsigned int **) malloc ( (width)*sizeof(unsigned int) );
arraySegment= (unsigned int **) malloc ( (width)*sizeof(unsigned int) );
arraySurfaceInAligned= (unsigned int **) malloc ( (width)*sizeof(unsigned int) );
arraySegmentAligned= (unsigned int **) malloc ( (width)*sizeof(unsigned int) );
90
for ...
how to convert Matlab code to C codeHi everyone,
Can any one tell me how to convert matlab to c??
Regards.
On 5/8/2012 4:36 PM, WMS wrote:
> Hi everyone,
> Can any one tell me how to convert matlab to c??
>
> Regards.
http://www.mathworks.com/products/matlab-coder/
"MATLAB Coderâ„¢ generates standalone C and C++ code from MATLAB code"
...
converting matlab code to C codewhen i tried to convert the matlab code into c code using matlab coder i got below mentioned error, I am using R2011b(7.13.0.534) my program uses image as an input parameter.
ERROR:
>> coder -build len.prj ??? This text contains non-empty top-level expressions. It appears to be a script. Error in ==> length_of_line Line: 1 Column: 1 Code generation failed: Open error report.
CODE:
I=imread('pic29rkey.jpg');
imshow(I);pause
hold on
[x,y] = ginput(2);
line(x,y,'color','r','LineWidth',5);
Ired_length = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2);
[x,y] = ginput(2);
line(x,y,'color','g','LineWidth',5);
lineLength = sqrt ((x(2)-x(1))^2 + (y(2)-y(1))^2);
Igreen_length= lineLength/Ired_length*10;
disp(Igreen_length);
msgbox(sprintf('Length of the Key is %f cm',Igreen_length));
How to solve this issue? this is the first time i am using this code conversiuon tool thats why! Thanks in advance...
"arunkumar " <arun.pk2k3@gmail.com> wrote in message
news:jnm1kd$pog$1@newscl01ah.mathworks.com...
> when i tried to convert the matlab code into c code using matlab coder i
> got below mentioned error, I am using R2011b(7.13.0.534) my program uses
> image as an input parameter.
>
> ERROR:
>>> coder -build len.prj ??? This text contains non-empty top-level
>>> expressions. It appears to be a script. Error in ==> length_of_line
>>> Lin...
Shall i use the misrosoft Visual c++ code from a m-file generated from matlab in Visual C++ with out matlab runtime environmentundefined
...
histrogram in matlab using c or c++ codehi
i am looking for a c or c++ code in matlab for creating a histogram of a grayscale image.
thanks
"shaizy" wrote in message <j56br3$3dp$1@newscl01ah.mathworks.com>...
> hi
> i am looking for a c or c++ code in matlab for creating a histogram of a grayscale image.
>
> thanks
If you have the Image Processing Toolbox, see imhist.
I'm not sure I understand what you mean by you are looking for C or C++ code in MATLAB.
Wayne
...
Help me to convert the C++ code to Matlab codeSome one Help me to convert the following C++ code to Matlab code
for(init x=-5; x++ ; x<=10) {
if (x<=0)
y=2;
else
y=3 * x;
plot (x,y)
}
...
Sending data to MATLAB from C/C++ code running in the backgroundHello,
I'd like to run a purpose-designed C/C++ program at the same time a MATLAB script is running and have MATLAB receive data (in my case, numbers) from the program in a streaming fashion. For example, say the C program (I'm going to write C instead of C/C++ from now on) continually recalculates 8 numbers over and over again: the usage of the program in conjunction with the MATLAB script would ideally be something like this:
1. The MATLAB script is started.
2. The C program is started by the MATLAB code (e.g. through a console command). Once the C program initializes, it continually calculates and recalculates 8 numbers in an endless loop until stopped manually by the user.
3. The MATLAB script continues executing until it reaches a point where it requires the 3 numbers from the C program. What I'd like at this stage is for the MATLAB script to be able to acquire the values of the 8 numbers that were most recently output by the C program. This would occur multiple times, so the C program would essentially be streaming the 3 values to MATLAB constantly, with the MATLAB script choosing when to sample them.
Unfortunately, the nature of the C program is such that it takes a few seconds to initialize and so transforming it into a MEX file to be called repeatedly by the MATLAB script would not work (the response wouldn't be fast enough since the initialization delay would occur every time the program was run).
As such, how might I go about getting the C pro...
Conversion from a MATLAB code to a C code used by a DSP processorHello, I need to implement image processing in a Digital Signal Processor. I have a code ready in MATLAB, I have tried using MATLAB Coder, but its unable to go past the first line: the imread() function. I have installed the C compiler from MATLAB and that is all. How do I go about the whole of the conversion process? Do I need to install something else?
...
GPS C/A code + DFT = ? matlab code help me plsI have CA code of GPS, and I want to do DFT on the code in matlab and plot please help me
On 5/30/2011 1:42 AM, Lk Khurelbaatar wrote:
> I have CA code of GPS, and I want to do DFT on the code in matlab and plot please help me
doc fft
--Nasser
On May 30, 8:42=A0pm, "Lk Khurelbaatar" <hourgla...@yahoo.com> wrote:
> I have CA code of GPS, and I want to do DFT on the code in matlab and plo=
t please help me
And I want to spin straw into gold, help me please.
...
compiling matlab .m / generating .c (c code) from .mHi everyone,
When I compile a matlab .m file (with mcc command), I get an
executable, that works well, and it also generates a C code (2 .c
files), and some other files (a .ctf, some .m files that do not have
matlab codes, but non readable codes, and others).
As I want to integrate the program with a C project, I don't want it
to be a black box, that I cant' debug. I tried to compile the .c files
in an external compiler, and it did not work. I tried in DevC++ and
also in Microsoft Visual C++. They show errors like "unexpected end of
file while looking for precompiled header directive", and I don't know
exactly what is missing. I was suspecting of #include "mclmcr.h", on
the .c files. I found some suggestions to change that to #include
"mclmcrrt.h", but it did not work. I found a mclmcr.h on the Matlab
folders, but it has other includes that I haven't found.
- Does anyone know if that .c files are usable or are only some
intermediate step while Matlab is building that exe?
- If I need those .h, how can I get them?
- Do I need to use that other files (other than those .c) generated
while compiling?
- If I am in the wrong way, what's the best way to get C files from .m
files?
Thank you in advance.
renatoab <barbosarenato@gmail.com> wrote in message <0276d457-a463-42a9-86b5-ad3abfc9c351@z10g2000yqb.googlegroups.com>...
> Hi everyone,
>
> When I compile a matlab .m file (with mcc command), I get an
> exe...
running a c code in matlabhey i am wondering how to convert a code written in c into matlab code.OR how can i run a code written in c from matlab.
"Avishek " <trust_abhishek@hotmail.com> wrote in message <iok91j$p1l$1@fred.mathworks.com>...
> hey i am wondering how to convert a code written in c into matlab code.OR how can i run a code written in c from matlab.
Hi Look at the External Interfaces of the MATLAB User's Guide.
Wayne
...
Run C code in MatlabHi everyone,
I have never used/compiled C codes before and I am trying to run one in Matlab at the moment. Here's how I did it in a Mac OS:
Input "mex -setup" at the command line
I got the following options:
The options files available for mex are:
1: /Applications/MATLAB_R2010aSV.app/bin/gccopts.sh :
Template Options file for building gcc MEX-files
2: /Applications/MATLAB_R2010aSV.app/bin/mexopts.sh :
Template Options file for building MEX-files via the system ANSI compiler
0: Exit with no changes
Enter the number of the compiler (0-2):
2
Overwrite /Users/username/.matlab/R2010a/mexopts.sh ([y]/n)?
y
Then I wrote the following in the command line
mex filename.c
and got
??? Error using ==> mex at 222
Unable to complete successfully.
I tried running it with option 1 but got the same error message. Any idea if this is a compiling error or if it is actually an error within the code. The code is very long and hence it is not a good idea to post it here. If anyone has the time to assist with this query I can email the code instead.
I appreciate any input thanks
Emma
"Emma Robertson" wrote in message <j3tfg5$l10$1@newscl01ah.mathworks.com>...
> Hi everyone,
>
> I have never used/compiled C codes before and I am trying to run one in Matlab at the moment. Here's how I did it in a Mac OS:
>
> Input "mex -setup" at the command line
>
> I ...
matlab code for c-means algorithmplease sent me matlab coding for fuzzy c-means algorithm
http://www.mathworks.com/products/fuzzylogic/demos.html?file=/products/demos/shipping/fuzzy/fcmdemo_codepad.html
"poonkothai sundaram" <kothai_tbt@yahoo.com> wrote in message <hmg0vt$c0n$1@fred.mathworks.com>...
> please sent me matlab coding for fuzzy c-means algorithm
On Monday, March 1, 2010 4:22:05 AM UTC-5, poonkothai sundaram wrote:
> please sent me matlab coding for fuzzy c-means algorithm
This code is for Gray image. Could you please suggest the same for color image segmentation.
Thanks & regards
...
need help for matlab c++ codehi friends ,
1)i have a C++ program for resource allocation for real time services
in ofdm systems.I need to call this program to return the capacity for
each user to draw a graph in matlab can anybody elucidate the steps
how to embed the particular program in matlab.
2)i need to take input from rayleigh fading function in matlab to the c
+ program could somebody tell how to do that tooo
On 20 Feb, 05:07, "sharad kumar.j" <aryansmit3...@gmail.com> wrote:
> hi friends ,
> 1)i have a C++ program for resource allocation for real time services
> in ofdm systems.I need to call this program to return the capacity for
> each user to draw a graph in matlab can anybody elucidate the steps
> how to embed the particular program in matlab.
> 2)i need to take input from rayleigh fading function in matlab to the c
> + program could somebody tell how to do that tooo
Check out the External Interfaces part of the
matlab documentation.
Rune
...
use a C code in matlab (Linux)Hi,
I try to use C code as a function in my matlab code... This code was originally created for Windows users and compiled in .dll .
In fact I just want to know how to create a equivalent of a .dll file in linux.
thx
On 15 Feb, 09:31, "Pierre " <pi.b...@gmail.com> wrote:
> Hi,
> I try to use C code as a function in my matlab code... This code was orig=
inally =A0created for Windows users and compiled in .dll .
> In fact I just want to know how to create a equivalent of a .dll file in =
linux.
The question is trivial, but the solution might not be.
Well, it almost certainly is not.
Windows and linux are two different operating systems (OSs).
That is, two different ways to handle the interface between the
hardware inside the computer, and the software that is supposed
to run on the computer.
Even if the two OSs run on the same hardware platform, the
solutions chosen for a number of common tasks - like how to
organize and integrate libraries - can differ very substantially.
In other words: You need to re-compile the library from the C
source code.
Even if you get hold of that source code you are not done.
At a bare minimum you will have to change certain library
interface issues - the ways functionality inside the library
is exposed to the calling programs.
But this is not all - you will almost certainly need to do more:
C and C++ are standardized languages in the sense that a standard
defines a *minimum* supported set of functions, keywords and ...
copyright on C code generated by MatlabThe recent release of Matlab version 2011a has a new code generation product called Matlab Coder. It is a new product which generates portable C/C++ code directly from Matlab code.
Its license fee is already covered by the site-license from my university. Lets say the C code works as I think, can MathWorks claim copyright on: 1) the C code generated from Matlab code, or 2) tools that based on that piece of C code?
If finally everything written in Matlab can be transformed to C/C++ code, and it works, then the final code will be not only faster but also freely available to anyone including those who do not have Matlab installed? Am I too optimistic?
Link to some 1-2 mins 'Apple style' advertisements:
http://www.mathworks.com/products/new_products/latest_features.html
Jian
"Jian " <ren.jian@msn.com> wrote in message
news:iopje3$pth$1@fred.mathworks.com...
> The recent release of Matlab version 2011a has a new code generation
> product called Matlab Coder. It is a new product which generates portable
> C/C++ code directly from Matlab code.
>
> Its license fee is already covered by the site-license from my university.
> Lets say the C code works as I think, can MathWorks claim copyright on: 1)
> the C code generated from Matlab code, or 2) tools that based on that
> piece of C code?
>
> If finally everything written in Matlab can be transformed to C/C++ code,
> and it works, then the final code will be not onl...
'Matlab Code' to 'Embedded Matlab fun code'Dear friends,
I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simulink and I want to use it in 'Embedded Matlab fun block' so i need to transform 'Matlab code' to 'Embedded Matlab fun code' to perform the task.
The Matlab code is as follows:
%%%%%%%%%%%%%%%%%%%%%
u_abs = abs(u);
major_th = 1.5e-1;
minor_th = 1.8e-2;
major_peak_value = [];
minor_peak_value = [];
pos = 1;
pos_max = 1;
while ~isempty(pos)
[m pos_max(end+1)] = max( u_abs( pos : pos + 10) );
pos_max(end) = pos_max(end) + pos - 1;
if m > major_th
major_peak_value(end+1) = m;
else
minor_peak_value(end+1) = m;
end
% exit the peak
pos = find(u_abs(pos:end) < minor_th, 1 , 'first') + pos-1;
% Find the beginning of the next peak
pos = find(u_abs(pos:end) > minor_th, 1 , 'first') + pos-1;
end
pos_max(2) = [];
plot(u); hold on;
plot(pos_max,u(pos_max),'ro');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I think i don't need this plot command as I will see the result in the scope directly.
Any suggestion will be very useful.
Thanking you!
Prashant
"Prashant Sandhi" wrote in message <jafvj8$soq$1@newscl01ah.mathworks.com>...
> Dear friends,
>
> I have a Matlab code to process a pure analog signal 'u'. Now I want to implement it in Simu...
[tao-bugs] generated C++ code : warnings in C++ code generated from IDL--=====================_464876386==.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed
TAO VERSION: 1.4
ACE VERSION: 5.4
HOST MACHINE and OPERATING SYSTEM:
Dell Dimension 4100, PIII 733MHz
Windows XP Home SP1
WS2_32.DLL version == 5.1.2600.1240
TARGET MACHINE and OPERATING SYSTEM, if different from HOST: same
COMPILER NAME AND VERSION (AND PATCHLEVEL):
Microsoft Development Environment 2003 v7.1.3088
Microsoft Visual C++ .NET
AREA/CLASS/EXAMPLE AFFECTED:
for ZZZ.idl, the following generated files get warnings.
ZZZS.cpp
ZZZC.cpp
DOES THE PROBLEM AFFECT:
COMPILATION? YES
LINKING? NO
EXECUTION? NO
OTHER (please specify)?
SYNOPSIS:
for ZZZ.idl, the following files get warnings.
ZZZS.cpp
ZZZC.cpp
DESCRIPTION:
the above mentioned generated files get warnings during
compilation. the compilation succeeds and everything appears to work fine,
so this isn't really a big deal, but I thought I'd report it. Its more of
a minor nuisance.
compiler output is included at the end of this Email.
REPEAT BY:
SAMPLE FIX/WORKAROUND:
======================================
Compiling...
ZZZS.cpp
ZZZS.cpp(627) : warning C4267: 'argument' : conversion from 'size_t' to
'const unsigned int', possible loss of data
ZZZC....
RE: [tao-bugs] generated C++ code : warnings in C++ code generated from IDLHi,
Then you probably don't use Corba Any's. If you use them you are in problems
without enabling RTTI, but the best is to enable it as we advice.
Johnny
> Thanks! Enabling RTTI took the warnings away. Note, though,
> that even
> with the warnings, my TAO code did build and appeared to run
> correctly.
>
> At 07:10 AM 2/28/2004, Johnny Willemsen wrote:
> >Hi,
> >
> >Thanks for using the PRF form.
> >
> >You must enable RTTI in your project files. This is now
> required when using
> >TAO (not when using only ACE). This warning should be read
> as error, if you
> >don't fix it your TAO app will not build
> >
> >Regards,
> >
> >Johnny Willemsen
> >Remedy IT
> >Leeghwaterstraat 25
> >2811 DT Reeuwijk
> >The Netherlands
> >www.theaceorb.nl / www.remedy.nl
> >
> > > TAO VERSION: 1.4
> > > ACE VERSION: 5.4
> > >
> > > HOST MACHINE and OPERATING SYSTEM:
> > > Dell Dimension 4100, PIII
> > > 733MHz
> > > Windows XP Home SP1
> > > WS2_32.DLL version ==
> > > 5.1.2600.1240
> > >
> > > TARGET MACHINE and OPERATING SYSTEM, if different from
> > > HOST: same
> > >
> > > COMPILER NAME AND VERSION (AND PATCHLEVEL):
> > > Microsoft Development
> > > Envi...
How to pass C pointers when interfacing Matlab MCR from C/C++We have a signal processing application for doing frequency analysis of acoustic signals.
The original signal is captured in a C struct:
--------------------------------------------
typedef struct _sig
{
unsigned long length;
float *data;
} Sig;
--------------------------------------------
Typical length is 10M, so the size of the data is 10M*sizeof(float)=40M.
We want to apply FIR filter on this signal using Matlab MCR.
I have built a Matlab DLL using the deploytool from the Compiler toolbox.
In the Matlab DLL there is Filt.m that includes something like:
-----------------------------------------
function res = FiltSig(SigPacket)
len = SigPacket.length;
coeff = fir1(150, f); % ‘f’ is already set
FiltSigPacket = filtfilt(coeff, 1, SigPacket.data);
res = sum(FiltSigPacket);
end
So I created a Matlab structure using mx API mxCreateStructMatrix and add the length and data fields:
Sig sig; // sig is set somewhere
char *SigFields[] = {
"length",
"data"
};
mxiSig = mxCreateStructMatrix(1, 1, sizeof(SigFields)/sizeof(char *), SigFields);
mxi_length = mxCreateNumericMatrix(1, 1, mxUINT32_CLASS, mxREAL);
*(DWORD *)mxGetData(mxi_length) = sig.length;
mxSetField(mxiSig, 0, "length", mxi_length);
mxi_data = mxCreateNumericMatrix(sig.length, 1, mxSINGLE_CLASS, mxREAL);
memcpy((float *)mxGetData(mxi_data), sig.data, ...
Errors when integrating MatLab code into C# programHello,
I'm trying to learn how to integrate MatLab code into C#. I'm using Matlab R2010a and Visual Studio 2010. I downloaded the following tutorial and executed the MatLab side of the code:
http://www.mathworks.se/matlabcentral/fileexchange/12987
However, when I tried to compile the C# code in visual studio, I got the following error:
Could not load file or assembly 'MWArray, Version=2.9.1.0, Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its dependencies. The system cannot find the file specified.
A quick google search led me to this page, which instructed me to change the target processor to x86:
http://www.mathworks.com/support/solutions/en/data/1-B0JOFC/index.html?solution=1-B0JOFC
However, as soon as I did so, I received a new error:
System.BadImageFormatException was unhandled
Message="Could not load file or assembly 'MWArray, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=e1d84a0da19db86f' or one of its
dependencies. An attempt was made to load a program with an incorrect
format."
Another google search led me to this page, which said that components generated by MatLab builder x86 are not supported on x64 machines:
http://www.mathworks.com/support/solutions/en/data/1-7457HL/index.html?product=MN&solution=1-7457HL
My MatLab version is 64 bit, but I am still encountering this problem. Is there a workaround?
HI,
I am trying something similar to what you did, but with matlab 20...
C code generation from Matlab (m-file)Can i generate c code from matlab m-files
I believe that c code can be generated from simulink models using rea
time workshop but can the same be done using m-files instead of simulink.
"arslan" <arsl_khalid@yahoo.com> wrote in message
news:_KSdnfsQqo6d0srVnZ2dnUVZ_hSdnZ2d@giganews.com...
> Can i generate c code from matlab m-files
> I believe that c code can be generated from simulink models using real
> time workshop but can the same be done using m-files instead of simulink.
Look at MCS from AgilityDS
http://www.agilityds.com/products/default.aspx
Hans
www.ht-lab.com
arslan wrote:
> Can i generate c code from matlab m-files
> I believe that c code can be generated from simulink models using real
> time workshop but can the same be done using m-files instead of simulink.
Yes, if you have the matlab Compiler product.
Otherwise you have to code by hand.
There are third party converter products, but they aren't cheap.
http://www.ancad.com/codeConverter.php
On Jun 17, 1:43=A0am, "arslan" <arsl_kha...@yahoo.com> wrote:
> Can i generate c code from matlab m-files
> I believe that c code can be generated from simulink models using real
> time workshop but can the same be done using m-files instead of simulink.
Yes, I do it all the time, you have to first drag an embedded matlab
block into simulink, then put your m code inside it, there are some
limitations as far as what functions you can and cannot use...
Using Coder to convert Matlab code to CHi,
I'm trying to use Coder to covert my Matlab code infested by inevitable for-loops into C
to make it faster. I'm getting errors:
" Undefined function or variable 'laml'. The first assignment to a local variable determines its class."
more details:
I use vector laml(1:100) inside a function which is called from main and do not pre-allocate
memory (it grows within the cycle). Coder documentation claims to be able to handle this..
How can I declare it for C ?
I tried preallocating within the function like this:
lalm(1:100) = double(0);
But this didn't help.
Help please! :)
best,
lena
This may be of no help at all, but I would experiment without doing any pre-allocation in Matlab that is, and see, then if worked, pre-allocate correctly
...
Matlab Code to C++Hello,
i am currently involved in developing a solver in c and prototyped the code in matlab. At the moment i am beginning to port the code from matlab to c. My code relies on matlab functions for interpolation and fft. How should i go about porting this functionality to c?
1) Find some opensource libraries whose license agrees with my project and implement them?
2) Having my program acces matlab and runing this functions in matlab? (Performance hit?)
3) Rewrite the matlab functions in c? What does matlab license / copyright say about this? i have already modify the .m files in matlab to suit my needs but i am not sure if matlab's license allows it.
4) compile this functions to c directly from matlab and link them in my program some how?
5) other alternatives?
Thanks!
"Paco MG" <justp.ako@gmail.com> wrote in message
news:iug6f1$ssu$1@newscl01ah.mathworks.com...
> Hello,
>
> i am currently involved in developing a solver in c and prototyped the
> code in matlab. At the moment i am beginning to port the code from matlab
> to c. My code relies on matlab functions for interpolation and fft. How
> should i go about porting this functionality to c?
>
> 1) Find some opensource libraries whose license agrees with my project and
> implement them?
> 2) Having my program acces matlab and runing this functions in matlab?
> (Performance hit?)
> 3) Rewrite the matlab functions in c? What does matlab license / copyright
&...