Archive for the 'MATLAB, LABVIEW' Category

Labview MathScript Online demo

Wednesday, May 30th, 2007

Labview 1+1

The graphical programming tool, Labview, is great for scientific instrumentation, because it is easy to use and yet very powerful and feature rich. However, the graphical interface sometimes can be a hassle, especially when you want to do complicated mathematical operations. Like a look at the example here for adding up two 1′s. Drawing the wires can be a headache if you are doing many many more operations.

This is when you will need the MathScript in Labview. It is similar to MATLAB syntax and does a good job complimenting the all-graphical programming of Labview.

Today, I received an email saying that NI just released an online beta demo (link). With the demo, you can actually run MathScript programs without installing Labview! It can even output 2D or 3D plots. This is great for plotting function for any school project :)

Try some simple codes:

a= 0 : 0.1 : 2*pi
plot(a, sin(a))

sine plot

abilify mg
buying accutane
aciphex pills
acomplia overnight no rx
prices actonel
cheapest actos
aleve medication
allegra online
alli tablets
altace tablets
antibiotics no rx
aricept tablet
arimidex medication
ashwagandha withdrawal
discount astelin
atacand pills
cheap atarax no prescription
generic augmentin
avandia online
avapro vs
avodart order online shipping
bactrim rx
benadryl delivery
buying benicar
biaxin delivery
buspar vs
price of cardizem
celebrex no rx
cephalexin mg
cialis discounted
cheapest cipro
cla overnight no rx
clarinex coupon
claritin overnight no rx
no prescription clomid
clonidine canada
coreg discounted
buy coumadin online
cozaar tablets
cheapest cymbalta
cytotec no rx
buy depakote without a prescription
diclofenac overnight
differin tablet
diflucan canada
generic diovan
doxycycline delivery
no prescription effexor
cost of flomax
purchase glucophage online
hair loss
hoodia mg
lamictal product
lamisil pills
no prescription lasix
levaquin canada
levitra overnight
buy lexapro without a prescription
buying lipitor
price of lisinopril
purchase melatonin
purchase micardis
mobic no prescription
order motrin
neurontin withdrawal
price of nexium
nizoral coupon
nolvadex cost
omnicef rx
price of paxil
cheapest penis extender
cheapest plan b
cheap plavix
pravachol rx
buy prednisone without a prescription
premarin no rx
no prescription prevacid
prometrium overnight
propecia canada
provera information
prozac overnight no rx
reglan no rx
order rimonabant online
prices risperdal
rogaine no rx
seroquel tablets
singulair tablets
buying skelaxin
cheap stop smoking
strattera withdrawal
stress relief no prescription
synthroid mg
no prescription topamax
toradol delivery
cheap tramadol no prescription
price of trileptal
cheap ultracet
cheap valtrex no prescription
order viagra
discount voltaren
purchase vytorin
weight loss
zantac rx
zetia reviews
price of zestoretic
price of zithromax
zoloft rx
zovirax product
price of zyban
zyprexa overnight
online zyvox

Update on the normxcorr2_mex comparison

Monday, April 24th, 2006

I just found out that I didn’t do a fair enough comparison between the MATLAB built-in normxcorr2 function and the pre-compiled normxcorr2_mex in the previous post. The reason is that MATLAB is calculating the full normalized cross-correlation, while the pre-compiled MEX file only calculates the values for the “valid” region of the cross correlation. The idea of calculating only the “valid” region assumes that the feature/template that you are looking for is WITHIN the larger image. If the feature has several pixels sticking out of the larger image, this assumption will make the normxcorr_mex to give the wrong peak position.

So, to match the output of the normxcorr2 in matlab, one will need to pad the larger image with zeros before using the normxcorr2_mex. For example, instead of using
ncc = normxcorr2_mex(template, img);
The following code will give you exactly the same result as the output from the Matlab normxcorr2 function:
ncc=normxcorr2_mex(template, img_padded, 'valid');

By doing this, we are calculating more correlation values, thus trading off performance, as is indicated by the comparison plot below (still 10 times speed-up with large image sizes, compared with the matlab built-in function) :
normxcorr2_mex performance

Speed up your image registration (template matching) code in MATLAB

Friday, April 21st, 2006

Recently, I’ve encounter the problem of finding a template in an image, which is a common issue in image registration or computer vision.

With the built-in function “normxcorr2″ in MATLAB, it is rather easy to write a program to do this. However, the performance is not that great.

Luckily, I came across the following discussion by Daniel Eaton:
“How to do Normalized Cross-Correlation Fast”

By wrapping the C++ code from OpenCV project and making it available as a MATLAB MEX-file, Daniel claims that he achieved a huge performance boost.

I was a bit suspicious at first, but decided to give it a shot. As I am using a n Apple PowerMac G5, I found out that I need to compile the MEX-file on Mac OS X, which turns out not be a trivial task (see my dedicated post).

Anyway, the outcome really surprised me. I can assure you now, that it is well worth the time and trouble to compile the MEX-file!

By embedding a random grayscale pattern in a larger image, I was able to benchmark the performance on an Apple PowerMac G5 (Dual 2.5GHz PowerPC CPUs). Take a look:


The template stays the same (100×100 pixels), while the size of search image is increasing (from 200×200 to 800×800, indicated by the X-axis). The Y-axis shows the cpu time. Clearly, there is a speedup of 15x – 20x, using the compiled MEX-file over the built-in “normxcorr2″!

Life is better, right? :)

How to compile MATLAB MEX files (based on OpenCV library) on Mac OS X Tiger – a short guide

Friday, April 21st, 2006

I was trying to compile the fast Normalized Cross-correlation function from Daniel Eaton, when I encountered compilation errors on my PowerMac G5. It took me some time to figure out a solution, so I thought it might be useful to other people who want to use Intel s Open Computer Vision library in MATLAB on Mac OS X Tiger.

  1. Follow Christoph Seibert’s guide to compile OpenCV on Mac OS X Tiger. You will need Fink installed (use FinkCommander), as well as Apple XCode and X11.
  2. Open an X11 Terminal window and type in the following command to set up the environment for pkg-config.
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
    Or you can add this line to your .bash_profile file.
  3. Following the above command, start MATLAB by typing:
    (use your own version of MATLAB, instead of 7.1 here)
  4. In MATLAB command window, type in
    mex -setup
    and choose the default gcc option (# 2).
  5. Open a new Terminal window and modify the matlab file (~/.matlab/R14SP3/ for example). Now open the file with your favorite text editor (vi or pico) and find the section starting with
  6. replace the CC line with the following line and save the file.
    CC='gcc-3.3 -bind_at_load `pkg-config --cflags opencv` `pkg-config --libs opencv`'
  7. Okay, now you can go ahead and compile the MEX file, by using the “mex” command in MATLAB. For example:
    mex mycode.cpp

Have fun!