Is there something equivalent to matlab's imtransform in C++? I'm having a hard time wrapping my head around the code for imtransform in matlab, and I'm trying to use or rewrite it in C++.
edit: Not built into C++, but any libraries that you may know of which would do the same thing would be great
Check out OpenCV. I don't remember whether it has that exact transform, but it has a lot of related code to take a look at (it's open source).
No. Neither ISO C nor ISO C++ define any kind of image manipulation functions or formats (even including C1X and C++0x). (Your platform or operating system might though)
Related
I am looking for a good way to compute a double integral numerically using pre-written C++ libraries. The basic integral I'm dealing with is this:
I've done some research and discovered a few libraries that might be useful, however I'm not sure which one to choose based on the problem I'm dealing with. The libraries I have looked at are
GSL - The problem here is it's written in C and so I would have to
find some kind of wrapper to make it compatible with my research
codes.
Cuba - This library seems very appropriate and well documented.
However I would like to avoid importing an entirely new library if I
can because I'm already importing Boost and Blitz and would like to
keep the hassle of compiling everything to a minimum.
Boost - From what I have read in their documentation Boost has
methods for integrating ODE's, but I could not find any libraries
for numerically integrating double integrals of functions. Am I
missing something? This would be the most convenient option as I
already use Boost in my codes and its already in C++.
So my question essentially boils down to this:
Which of these three libraries would be most useful for my purposes? Is it possible to conduct the integral I have specified using Boost? Additionally any tips on how to implement this integral using any of the above libraries would be greatly appreciated.
Take a look at these sources, calling c code from c++ is generally not problematic. It's going the other direction that can be.
How to mix C and C++
How to Call C Function in C++, C++ Function in C (Mix C and C++)
I have developed a MATLAB program with Visual C++. I am using IntelĀ® Integrated Performance Primitives because speed of program is important issue and I have done a lot of efforts for implementing some MATLAB functions. For example, for Min and Max functions over a vector i use ippsMaxIndx_32f; but, there is function in MATLAB like Find.
Here is a description of the Find method in MATLAB:
Description
I need a function which implements this find function of MATLAB with high speed.
Are there any functions inside Intel Ipp, that works like the Find function in MATLAB?
I've never heard of a comprehensive port of matlab functionality to C++. That being said, almost everything matlab does exists within a C/C++ library somewhere, some off the top of my head:
LAPACK, BLAS, and there are a few good implementations, the most notable (free) one being ATLAS.
FFT is implemented in matlab via the fftw library
There are loads of fast open-source image libraries out there, ie. interpolation, filtering.
There are really good OOP matrix libraries out there, boost has a nice one.\
After that, well figure out what you need and there is a good chance someone has implemented it in C/C++.
You can check to these to see if you can find the function you are looking for! As i am not sure for that.
I've used ippsFind_* and they have worked just fine.
I am implementing a sort and stream compaction algorithms in CUDA C. However I have just figured that it is not that simple to implement those algorithms by myself with good performance. Given that I am working with matrices I cannot use CUDPP, so, although I was avoiding it, I will have to work with thrust library(I know nothing of C++).
I have been programing in C, and I really just want to use C++ to work with thrust, so basically I want to know if I can have most of my code in C and then have little bits of C++ code(I am guessing I will have to use the "external" function) but I wanted to be sure if it's feasible in CUDA.
Thanks in advance.
On the host code side, thrust is simple to integrate. Even though you might think that your host side code in any .cu file you compile is C, it is compiled using a C++ compiler anyway (most of CUDA internally relies on C++ features to compile). So you are actually working in C++ now without realizing it.
Yes, might complicate your build process but otherwise works fine. We use it all the time to wrap up some CUDA functions into C++ class which (and this is the REAL kicker) are then wrapped up with JNI for use in Java. If we can do it, you can do it! Have at it!
I am a newbie as far as it comes to embedded systems programming. I have to write lots of simple C or C++ programs like atoi, itoa, oct_to_dec, etc., which would have been easy to write in normal C.
But my hardware unit does not have the usual header functions and hence I cannot use standard library functions. :(
Could someone help me with some pointers to this? Any sampler or notes also would be of great help.
Thanks!
Most embedded compilers do indeed have an implementation of at least a subset of the standard C libraries, including functions like itoa and atoi. Depending on the compiler and the type of microcontroller that you are using, you might not have to rewrite any of the functions.
Seeing that this is homework, however, that might be the point.
If you give more details on the MCU and compiler that you are using, as well as a specific problem that you are having, then I could edit my answer to make it more relevant to your needs.
General Pointers
Writing embedded code deals much more with the microcontroller's architecture than with library functions. You probably won't be using much in the way of printf or cout, but will be doing a lot of bit shifting and writing to registers. So brush up up your bitwise operators. That said, the most important thing you can do when learning to write embedded software is to master the architecture. I cannot stress this enough. You will spend a lot of time with your data sheet, so get a jump on your class and start reading the data sheet for your microcontroller.
Also, if this is your first embedded class, you shouldn't worry about strings, because you probably won't be using them at all. Most of your work will probably be centered around writing code to interface with hardware.
Why would anybody in this day and age write atoi, itoa etc except as a learning exercise?
Source code for these has been freely available for decades.
http://www.uclibc.org/ is a good place to go for an embedded systems c library - much smaller than glibc. It can also be used for closed source software (Lesser GPL licensed) and the source code is available. http://git.uclibc.org/uClibc/tree/
look at an ascii table, look for patterns. For instance, converting atoi consists of finding out how many characters are in a string, and then converting each character to it's digit equivalent, and then multiplying it by the correct power of 10
A simple possibility is to download something like GLibC code and then pick out the functions that you want. Just note that the code is GPL and will require you to distribute source code with the application.
Another possibility is to use the Android C library although there is a bit of ARM assembler for functions like memcpy. (Android has a more liberal licence)
Unfortunately anything that required a system call cannot be used on your system so there you are on your own.
I just heard from somewhere that for numerical computation, "MATLAB does offer some user-friendly APIs. If you call these APIs in your C/C++ code, you can speed up computation dramatically."
But I did not find such information in MATLAB documents like http://www.mathworks.com/support/tech-notes/1600/1622.html and http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_external/bp_kqh7.html. All I learned from these websites is that MATLAB can be called in C and C++ by Matlab engine or by compiling M-files into libraries by mcc. They don't mention any built-in numerical MATLAB APIs that can be called in C/C++.
Can someone please clarify?
Thanks and regards!
You want the "Engine" routines. This allows you to start up a background MATLAB process from C and execute calculations on it: relevant MATLAB documentation.
It works pretty well, have a look at the examples. I would say the most annoying thing getting it working is marshaling the data between C and MATLAB. But that's always a problem when doing this kind of thing.
It sounds like you're looking for the code generation tools in the embedded matlab toolbox or real time workshop.
Do doc eml and look for a the LMS (least mean square) equalizer demo.
The code generator is quite good, it will give you a make file that will build a static library. It's easy to use with your stand alone C/C++ code.
There could be a few things that quote is referencing, I assume that it is referring to the MATLAB Compiler. So going from MATLAB -> C++ you can use the compiler to build standalone "faster" applications. However, when speed testing the improvement, I've noticed it to be negligible. Honestly, you're probably far better off coding your work in C from the get-go, the code that the compiler generates is spaghetti and non-object oriented. I should also mention that this is an expensive extension to Matlab.
You can use the MCR in your own c++ project as a stand-alone library (details)... but you might get similar results using Numerical Recipes.
Disclaimer: I used this product 2-3 years ago, things could be different now.