Archive for the 'Apple' Category

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:
img_padded=padarray(img,[size(template,1)-1,size(template,2)-1]);
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

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:
    /Application/MATLAB71/bin/matlab
    (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 mexopts.sh file (~/.matlab/R14SP3/mexopts.sh for example). Now open the file with your favorite text editor (vi or pico) and find the section starting with
    mac)
    #-------------------------
    CC='gcc-3.3'
  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!

Apple might release Intel-based systems as early as Jan 2006!

Tuesday, November 22nd, 2005

The rumor (AppleInsider) has it: Apple could ship the first Intel-based Macs in Jan 2006, almost half a year earlier.

The first models could be an iMac or PowerBook with Intel version of Tiger system installed. As the leaked 10.4.3 Developer version of Tiger x86 suggests, most of the softwares will be run smoothly on the new Macs. Using the rosetta technology, even the PowerPC-based programs should still be usable on the new system.

Apple’s new products

Wednesday, October 12th, 2005

With all the rumors floating around, Apple released two major new updates:
one is the long-waited video iPod, which attracts all the attention from the media.

new iPod

the other one is an iMac, with a remote control and build-in iSight, making it essentially a Media Center.

iMacG5

According to a CNN news report, last quarter Apple sold 6.5 million iPods! Geez, they are doing pretty well!

Hopefully, with all the money they make from iPod, Apple would bring out an even better operation system. I like the 10.4 Tiger, but I am kind of reluctant to upgrade from Panther, just because of all the software incompatibility. Anyway, i am still waiting to see more from Apple :)

UPDATE on 10-21-2005:
Wow! Apple released a new line of PowerMac: Two dual-core G5 chips = QUAD processors! This is way cool. But I guess many people would wait for the Intel Macs. With hyperthreading, two dual-core Intel chips would be equal to 8 processors (rumor here)!