Installing Image libraries in mac

7 01 2010

Mac does come with OpenGL and GLUT preinstalled, But when it comes to Image processing libraries , they rely on mac specific libraries. Since my project requires a cross platform structure, i had ignore the preinstalled libraries and search for cross platform libraries. When it comes to Image Procession the most popular library is OpenCV by intel

OpenCV

OpenCV logoOpenCV is very popular and it is has the similar features of image processing as Matlab Image Processing toolbox. Installation of OpenCV is pretty straight forward. There are few binary available in the net , but most of which work only for the sample program attached in the binary. So its better to compile the framework from the source.

Installation:

Step 1: Download the Source from sourceforge

Step 2: Extract the package

Step 3: Remove the spaces present in the extracted folder name (ie rename the folder to some simple name , I use OpenCVsrc)

Step 4:Open Terminal and go to path where the OpenCV is extracted

>cd <path>/OpenCVsrc

then run the shell script

>./make_frameworks.sh

Step 5: Once this is done , a new folder is created under OpenCVsrc with the name OpenCV.framework. Copy this to the framework directory.This directory is under /Library/Frameworks.

And now the framework is available under xcode frameworks to add and compile. OpenCV for mac is available only in i386 architecture. So the architecture in Xcode needs to be changed before compilation. An alternative method to install OpenCV is to use cmake.

CImg

CImg LogoCImg is a opensource Library which provides simple classes and methods to Load/save various file formats, access pixel values, display, resize/rotate/mirror/filter and draw primitives. There are loads of classes , which makes programming with cImg easier. Buts its not as powerful as OpenCV.

CImg needs no installation, just needs ImageMagick to run. Image magick takes care of the behind the scene operations on CImg.

CImg can be downloaded , the header file can be directly used to in programs. No compilation necessary.

Program Compilation

>g++ -o <Executable name> <Program name> -O2 -L/usr/X11R6/lib -lm -lpthread -lX11

ImageMagick

ImageMagick LogoImage Magic, another opensource image processing library . This is required by CImg for compilation. This has variety of features like

Format conversion, Transform , Resize , Transparency, Draw, Animation , Special effects etc.

The installation is as follows

Step 1: Download the Binaries from imagemagick or from the ftp site

Step 2:Create (or choose) a directory to install the package into and change to that directory, for example:

$magick> cd $HOME
Step 3:Next, extract the contents of the package. For example:
$magick> tar xvfz ImageMagick-x86_64-apple-darwin10.2.0.tar.gz
Step 4:Set the MAGICK_HOME environment variable to the path where you extracted the ImageMagick files. For example:

$magick> export MAGICK_HOME=”$HOME/ImageMagick-6.5.8″
Step 5:If the bin subdirectory of the extracted package is not already in your executable search path, add it to your PATH environment variable. For example:

$magick> export PATH=”$MAGICK_HOME/bin:$PATH”
Set the DYLD_LIBRARY_PATH environment variable:
$magick> export DYLD_LIBRARY_PATH=”$MAGICK_HOME/lib”
Step 6:Finally, to verify ImageMagick is working properly, type the following on the command line:
$magick> convert logo: logo.gif
$magick> identify logo.gif
$magick> display logo.gif
Program Compilation

g++ -o <Executable Name> <Program Name> `Magick++-config –cppflags –cxxflags –ldflags –libs`

OpenCV is in i386 architecture while CImg and ImageMagick are in x86 architecture. OpenCV is dependent on third party libraries like libjpeg etc for handling various file formats, so have a backup of the libraries before modifying these libraries.

Reference:

OpenCV

CImg

ImageMagick

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: