Google
 

12/23/09

Building And Using Static And Shared "C" Libraries

(Original location: http://users.actcom.co.il/~choo/lupg/tutorials/libraries/unix-c-libraries.html)
Table Of Contents:
  1. Building And Using Static And Shared "C" Libraries
  2. What Is A "C" Library? What Is It Good For?
  3. Creating A Static "C" Library Using "ar" and "ranlib"
  4. Using A "C" Library In A Program
  5. Creating A Shared "C" Library Using "ld"
  6. Using A Shared "C" Library - Quirks And Solutions
  7. Using A Shared "C" Library Dynamically - Programming Interface


    1. Loading A Shared Library Using dlopen()
    2. Calling Functions Dynamically Using dlsym()
    3. Unloading A Shared Library Using dlclose()
    4. Automatic Startup And Cleanup Functions



  8. Getting a Deeper Understanding - The Complete Linking Story


    1. The Importance Of Linking Order
    2. Static Linking Vs. Dynamic Linking







Building And Using Static And Shared "C" Libraries

One of the problems with developed programs, is that they tend to grow larger and larger, bringing up overall compilation and linking time to a large figure, and polluting out makefile, and the directory where we placed the source files. The first time a program we write reaches this state, is normally when we look for a different way to manage our projects.
It is this point where we start thinking about combining out source code into small units of related files, that can be managed with a separate makefile, possibly by a different programmer (for a multi-programmer project).




What Is A "C" Library? What Is It Good For?

One of the tools that compilers supply us with are libraries. A library is a file containing several object files, that can be used as a single entity in a linking phase of a program. Normally the library is indexed, so it is easy to find symbols (functions, variables and so on) in them. For this reason, linking a program whose object files are ordered in libraries is faster than linking a program whose object files are separate on the disk. Also, when using a library, we have fewer files to look for and open, which even further speeds up linking.
Unix systems (as well as most other modern systems) allow us to create and use two kinds of libraries - static libraries and shared (or dynamic) libraries.
Static libraries are just collections of object files that are linked into the program during the linking phase of compilation, and are not relevant during runtime. This last comment seems obvious, as we already know that object files are also used only during the linking phase, and are not required during runtime - only the program's executable file is needed in order to run the program.
Shared libraries (also called dynamic libraries) are linked into the program in two stages. First, during compile time, the linker verifies that all the symbols (again, functions, variables and the like) required by the program, are either linked into the program, or in one of its shared libraries. However, the object files from the dynamic library are not inserted into the executable file. Instead, when the program is started, a program in the system (called a dynamic loader) checks out which shared libraries were linked with the program, loads them to memory, and attaches them to the copy of the program in memory.
The complex phase of dynamic loading makes launching the program slightly slower, but this is a very insignificant drawback, that is out-weighted by a great advantage - if a second program linked with the same shared library is executed, it can use the same copy of the shared library, thus saving a lot of memory. For example, the standard "C" library is normally a shared library, and is used by all C programs. Yet, only one copy of the library is stored in memory at any given time. This means we can use far less memory to run our programs, and the executable files are much smaller, thus saving a lot of disk space as well.
However, there is one drawback to this arrangement. If we re-compile the dynamic library and try to run a second copy of our program with the new library, we'll soon get stuck - the dynamic loader will find that a copy of the library is already stored in memory, and thus will attach it to our program, and not load the new (modified) version from disk. There are ways around this too, as we'll see in the last section of our discussion.




Creating A Static "C" Library Using "ar" and "ranlib"

The basic tool used to create static libraries is a program called 'ar', for 'archiver'. This program can be used to create static libraries (which are actually archive files), modify object files in the static library, list the names of object files in the library, and so on. In order to create a static library, we can use a command like this:

ar rc libutil.a util_file.o util_net.o util_math.o 

This command creates a static library named 'libutil.a' and puts copies of the object files "util_file.o", "util_net.o" and "util_math.o" in it. If the library file already exists, it has the object files added to it, or replaced, if they are newer than those inside the library. The 'c' flag tells ar to create the library if it doesn't already exist. The 'r' flag tells it to replace older object files in the library, with the new object files.
After an archive is created, or modified, there is a need to index it. This index is later used by the compiler to speed up symbol-lookup inside the library, and to make sure that the order of the symbols in the library won't matter during compilation (this will be better understood when we take a deeper look at the link process at the end of this tutorial). The command used to create or update the index is called 'ranlib', and is invoked as follows:

ranlib libutil.a 

On some systems, the archiver (which is not always ar) already takes care of the index, so ranlib is not needed (for example, when Sun's C compiler creates an archive, it is already indexed). However, because 'ar' and 'ranlib' are used by many makefiles for many packages, such platforms tend to supply a ranlib command that does nothing. This helps using the same makefile on both types of platforms.
Note: when an archive file's index generation date (stored inside the archive file) is older than the file's last modification date (stored in the file system), a compiler trying to use this library will complain its index is out of date, and abort. There are two ways to overcome the problem:
  1. Use 'ranlib' to re-generate the index.
  2. When copying the archive file to another location, use 'cp -p', instead of only 'cp'. The '-p' flag tells 'cp' to keep all attributes of the file, including its access permissions, owner (if "cp" is invoked by a superuser) and its last modification date. This will cause the compiler to think the index inside the file is still updated. This method is useful for makefiles that need to copy the library to another directory for some reason.





Using A "C" Library In A Program

After we created our archive, we want to use it in a program. This is done by adding the library's name to the list of object file names given to the linker, using a special flag, normally '-l'. Here is an example:

cc main.o -L. -lutil -o prog 

This will create a program using object file "main.o", and any symbols it requires from the "util" static library. Note that we omitted the "lib" prefix and the ".a" suffix when mentioning the library on the link command. The linker attaches these parts back to the name of the library to create a name of a file to look for. Note also the usage of the '-L' flag - this flag tells the linker that libraries might be found in the given directory ('.', refering to the current directory), in addition to the standard locations where the compiler looks for system libraries.
For an example of program that uses a static library, try looking at our static library example directory.




Creating A Shared "C" Library Using "ld"

The creation of a shared library is rather similar to the creation of a static library. Compile a list of object files, then insert them all into a shared library file. However, there are two major differences:
  1. Compile for "Position Independent Code" (PIC) - When the object files are generated, we have no idea where in memory they will be inserted in a program that will use them. Many different programs may use the same library, and each load it into a different memory in address. Thus, we need that all jump calls ("goto", in assembly speak) and subroutine calls will use relative addresses, and not absolute addresses. Thus, we need to use a compiler flag that will cause this type of code to be generated.
    In most compilers, this is done by specifying '-fPIC' or '-fpic' on the compilation command.
  2. Library File Creation - unlike a static library, a shared library is not an archive file. It has a format that is specific to the architecture for which it is being created. Thus, we need to use the compiler (either the compiler's driver, or its linker) to generate the library, and tell it that it should create a shared library, not a final program file.
    This is done by using the '-G' flag with some compilers, or the '-shared' flag with other compilers.

Thus, the set of commands we will use to create a shared library, would be something like this:

cc -fPIC -c util_file.c
cc -fPIC -c util_net.c
cc -fPIC -c util_math.c
cc -shared libutil.so util_file.o util_net.o util_math.o

The first three commands compile the source files with the PIC option, so they will be suitable for use in a shared library (they may still be used in a program directly, even thought they were compiled with PIC). The last command asks the compiler to generate a shared library




Using A Shared "C" Library - Quirks And Solutions

Using a shared library is done in two steps:
  1. Compile Time - here we need to tell the linker to scan the shared library while building the executable program, so it will be convinced that no symbols are missing. It will not really take the object files from the shared library and insert them into the program.
  2. Run Time - when we run the program, we need to tell the system's dynamic loader (the process in charge of automatically loading and linking shared libraries into the running process) where to find our shared library.

The compilation part is easy. It is done almost the same as when linking with static libraries:

cc main.o -L. -lutil -o prog 

The linker will look for the file 'libutil.so' (-lutil) in the current directory (-L.), and link it to the program, but will not place its object files inside the resulting executable file, 'prog'.
The run-time part is a little trickier. Normally, the system's dynamic loader looks for shared libraries in some system specified directories (such as /lib, /usr/lib, /usr/X11/lib and so on). When we build a new shared library that is not part of the system, we can use the 'LD_LIBRARY_PATH' environment variable to tell the dynamic loader to look in other directories. The way to do that depends on the type of shell we use ('tcsh' and 'csh', versus 'sh', 'bash', 'ksh' and similar shells), as well as on whether or not 'LD_LIBRARY_PATH' is already defined. To check if you have this variable defined, try:

echo $LD_LIBRARY_PATH 

If you get a message such as 'LD_LIBRARY_PATH: Undefined variable.', then it is not defined.
Here is how to define this variable, in all four cases:
  1. 'tcsh' or 'csh', LD_LIBRARY_PATH is not defined:



    
        setenv LD_LIBRARY_PATH /full/path/to/library/directory
        




  2. 'tcsh' or 'csh', LD_LIBRARY_PATH already defined:



    
        setenv LD_LIBRARY_PATH /full/path/to/library/directory:${LD_LIBRARY_PATH}
        




  3. 'sh', 'bash' and similar, LD_LIBRARY_PATH is not defined:



    
        LD_LIBRARY_PATH=/full/path/to/library/directory
        export LD_LIBRARY_PATH
        




  4. 'sh', 'bash' and similar, LD_LIBRARY_PATH already defined:



    
        LD_LIBRARY_PATH=/full/path/to/library/directory:${LD_LIBRARY_PATH}
        export LD_LIBRARY_PATH
        





After you've defined LD_LIBRARY_PATH, you can check if the system locates the library properly for a given program linked with this library:

ldd prog 

You will get a few lines, each listing a library name on the left, and a full path to the library on the right. If a library is not found in any of the system default directories, or the directories mentioned in 'LD_LIBRARY_PATH', you will get a 'library not found' message. In such a case, verify that you properly defined the path to the directory inside 'LD_LIBRARY_PATH', and fix it, if necessary. If all goes well, you can run your program now like running any other program, and see it role...
For an example of a program that uses a shared library, try looking at our shared library example directory.




Using A Shared "C" Library Dynamically - Programming Interface

One of the less-commonly used feature of shared libraries is the ability to link them to a process anytime during its life. The linking method we showed earlier makes the shared library automatically loaded by the dynamic loader of the system. Yet, it is possible to make a linking operation at any other time, using the 'dl' library. This library provides us with a means to load a shared library, reference any of its symbols, call any of its functions, and finally detach it from the process when no longer needed.
Here is a scenario where this might be appealing: suppose that we wrote an application that needs to be able to read files created by different word processors. Normally, our program might need to be able to read tens of different file formats, but in a single run, it is likely that only one or two such document formats will be needed. We could write one shared library for each such format, all having the same interface (readfile and writefile for example), and one piece of code that determines the file format. Thus, when our program is asked to open such a file, it will first determine its format, then load the relevant shared library that can read and translate that format, and call its readfile function to read the document. We might have tens of such libraries, but only one of them will be placed in memory at any given time, making our application use less system resources. It will also allow us to ship the application with a small set of supported file formats, and add new file formats without the need to replace the whole application, by simply sending the client an additional set of shared libraries.




Loading A Shared Library Using dlopen()

In order to open and load the shared library, one should use the dlopen() function. It is used this way:

#include       /* defines dlopen(), etc.       */
.
.
void* lib_handle;       /* handle of the opened library */

lib_handle = dlopen("/full/path/to/library", RTLD_LAZY);
if (!lib_handle) {
    fprintf(stderr, "Error during dlopen(): %s\n", dlerror());
    exit(1);
}

The dlopen() function gets two parameters. One is the full path to the shared library. The other is a flag defining whether all symbols refered to by the library need to be checked immediatly, or only when used. In our case, we may use the lazy approach (RTLD_LAZY) of checking only when used. The function returns a pointer to the loaded library, that may later be used to reference symbols in the library. It will return NULL in case an error occured. In that case, we may use the dlerror() function to print out a human-readable error message, as we did here.




Calling Functions Dynamically Using dlsym()

After we have a handle to a loaded shared library, we can find symbols in it, of both functions and variables. We need to define their types properly, and we need to make sure we made no mistakes. The compiler won't be able to check those declarations, so we should be extra carefull when typing them. Here is how to find the address of a function named 'readfile' that gets one string parameter, and returns a pointer to a 'struct local_file' structure:


/* first define a function pointer variable to hold the function's address */
struct local_file* (*readfile)(const char* file_path);
/* then define a pointer to a possible error string */
const char* error_msg;
/* finally, define a pointer to the returned file */
struct local_file* a_file;

/* now locate the 'readfile' function in the library */
readfile = dlsym(lib_handle, "readfile");

/* check that no error occured */
error_msg = dlerror();
if (error_msg) {
    fprintf(stderr, "Error locating 'readfile' - %s\n", error_msg);
    exit(1);
}

/* finally, call the function, with a given file path */
a_file = (*readfile)("hello.txt");

As you can see, errors might occur anywhere along the code, so we should be carefull to make extensive error checking. Surely, you'll also check that 'a_file' is not NULL, after you call your function.




Unloading A Shared Library Using dlclose()

The final step is to close down the library, to free the memory it occupies. This should only be done if we are not intending to use it soon. If we do - it is better to leave it open, since library loading takes time. To close down the library, we use something like this:

dlclose(lib_handle); 

This will free down all resources taken by the library (in particular, the memory its executable code takes up).




Automatic Startup And Cleanup Functions

Finally, the dynamic loading library gives us the option of defining two special functions in each library, namely _init and _fini. The _init function, if found, is invoked automatically when the library is opened, and before dlopen() returns. It may be used to invoke some startup code needed to initialize data structures used by the library, read configuration files, and so on.
The _fini function is called when the library is closed using dlclose(). It may be used to make cleanup operations required by the library (freeing data structures, closing files, etc.).
For an example of a program that uses the 'dl' interface, try looking at our dynamic-shared library example directory.




Getting a Deeper Understanding - The Complete Linking Story






The Importance Of Linking Order

In order to fully understand the way linking is done, and be able to overcome linking problems, we should bare in mind that the order in which we present the object files and the libraries to the linker, is the order in which the linker links them into the resulting binary file.
The linker checks each file in turn. If it is an object file, it is being placed fully into the executable file. If it is a library, the linker checks to see if any symbols referenced (i.e. used) in the previous object files but not defined (i.e. contained) in them, are in the library. If such a symbol is found, the whole object file from the library that contains the symbol - is being added to the executable file. This process continues until all object files and libraries on the command line were processed.
This process means that if library 'A' uses symbols in library 'B', then library 'A' has to appear on the link command before library 'B'. Otherwise, symbols might be missing - the linker never turns back to libraries it has already processed. If library 'B' also uses symbols found in library 'A' - then the only way to assure successful linking is to mention library 'A' on the link command again after library 'B', like this:

$(LD) ....... -lA -lB -lA 

This means that linking will be slower (library 'A' will be processed twice). This also hints that one should try not to have such mutual dependencies between two libraries. If you have such dependencies - then either re-design your libraries' contents, or combine the two libraries into one larger library.
Note that object files found on the command line are always fully included in the executable file, so the order of mentioning them does not really matter. Thus, a good rule is to always mention the libraries after all object files.




Static Linking Vs. Dynamic Linking

When we discussed static libraries we said that the linker will try to look for a file named 'libutil.a'. We lied. Before looking for such a file, it will look for a file named 'libutil.so' - as a shared library. Only if it cannot find a shared library, will it look for 'libutil.a' as a static library. Thus, if we have created two copies of the library, one static and one shared, the shared will be preferred. This can be overridden using some linker flags ('-Wl,static' with some linkers, '-Bstatic' with other types of linkers. refer to the compiler's or the linker's manual for info about these flags).

This document is copyright (c) 1998-2002 by guy keren.

The material in this document is provided AS IS, without any expressed or implied warranty, or claim of fitness for a particular purpose. Neither the author nor any contributers shell be liable for any damages incured directly or indirectly by using the material contained in this document.

permission to copy this document (electronically or on paper, for personal or organization internal use) or publish it on-line is hereby granted, provided that the document is copied as-is, this copyright notice is preserved, and a link to the original document is written in the document's body, or in the page linking to the copy of this document.

Permission to make translations of this document is also granted, under these terms - assuming the translation preserves the meaning of the text, the copyright notice is preserved as-is, and a link to the original document is written in the document's body, or in the page linking to the copy of this document.

For any questions about the document and its license, please contact the author.

12/14/09

QString and number format.

Question: how to construct 0001.tif, 0002.tif, ..... and 0010.tif using QString?

With C++, one can use sprintf to do this. sprintf(str, '%04d', i) where str is the output string, i is the iteration number (from 1 to 10). With QString, one can also use sprintf, but as the document mentions it is not the recommended way. Instead, using arg is better.

Here is one example showing how to use arg to construct number format.


#include <_QtCore/QCoreApplication>
#include <_QString>
#include <_QDebug>


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    uint d = 90;
    QString test("9 is %1");
    const QChar fillChar = QLatin1Char('0');
    QString testNew = test.arg(d, 5, 10, fillChar);
    qDebug() << "string is: " << testNew;

    return a.exec();
}

the output is:

string is: "9 is 00090" 

10/21/09

ffmpeg usage.

Using ffmpeg to make movies is much faster than using ImageJ. The followings are the commonly used commands:

>> ffmpeg -r 60 -i %d.jpg -sameq -s vga out.mp4

-r 60 means the frame rate of the movie is 60;
-i %d.jpg: inputs are jpg sequences.
-sameq: make sure that the movie frames are the same quality as the input sequential images.
-s vga: constrains the size of the frames to vga size, which is 640x480.

10/18/09

compile Qt4.6 on snow leopard.

I had trouble with the binary files, both 4.5 and 4.6Beta. The installer freezes at "validating packages". Finally I decided to compile the source files. The first trial failed with a lot of errors related with tiff files. Then I used the following command and successfully compiled the file.

>> ./configure -qt-libtiff -sdk

>> make

>> sudo make install

So far it seems to work well.

10/15/09

binutils on snow leopard

use the following when config:

>> ./configure --disable-werror

otherwise it won't work.

compile openCV 2.0 on snow leopard

In the command window:


>> CXXFLAGS="-m32"
>>  LDFLAGS="-m32"
>>  ./configure


After that, do the following:


>> make
>> sudo make install (run as root). 



enable root account in Mac (10.6)

The easiest way to enable root is to start a terminal session, and type:

sudo passwd root
You will be prompted for a new password to enable root access.

If it does not work, following next steps:

  1. Open the Directory Utility located in /System/Library/CoreServices/.
  2. Unlock the application by clicking the padlock icon and entering your Administrator login.
  3. From the Edit menu, select Enable Root User.
  4. Chose Change Root Password from the Edit menu and chose a password for the root user.
That’s it! Make sure to lock the application by clicking the padlock icon.

10/12/09

QLabel

when set the qlabel pixmap, use the following:

 ui->label->setPixmap(QPixmap::fromImage(image));

QPixmap::fromImage is a static function.

The following codes do not seem to work:
QPixmap pixmap;
pixmap.fromImage(image);
ui->label->setPixmap(pixmap);

10/7/09

How to Build Up a Bulleted List in Apple Keynote ’09

http://www.ehow.com/how_4929870_build-up-bulleted-list-keynote.html

9/30/09

"arguments too long" error

http://en.wikipedia.org/wiki/Xargs

Use xargs to deal with "arguments too long" error.

9/29/09

use python to manipulate large number of files in a directory.

When you have tons of files in a folder and want to manipulate them together, you will have trouble. For example if you use "mv" or "cp", you will get "Arguments are too long". You can use python to do this.

here is how to do it.

invoke python first.

>>> import os, glob, shutil
>>> for file in glob.glob('./directory1/*.tif'):
                     shutil.copy(file, './temp')

this should work.

9/17/09

debian (5.0) install more languages.

as root

>> dpkg-reconfigure locales

Use the above to install more locales.

9/14/09

Image processing libraries!


PL,IPP,openCV,ITK,VTK,visDSK(转)
2009-03-02 09:18
IPL---INTEL 图象处理库 免费 源代码不公开
openCV--INTEL 图象处理库 免费 源代码公开
IPP--IPP--INTEL 集成开发环境库(图象处理、信号处理等) 收费 源代码不公开
visDSK---MICROSOFT 图象处理库 免费 源代码公开
ITK(Insight Segmentation and Registration ToolKit)提供了一个医学图像分割与配准的算法平台,它源于美国的可视人体项目(The Visual Human Project)[3]。同样地,ITK也支持跨平台开发,以开放源代码的形式发布,目前其稳定版本为1.6,提供了几乎所有主流的医学图像分割与配准算法。
VTK(The Visualization Toolkit)是美国Kitware公司的一个开放源码的自由软件(open source)。可以应用于图像处理、计算机图形学和科学计算可视化。它在科学计算可视化尤其是三维重建功能如面绘制和体绘制方面具有强大的功能,使其在可视化,尤其是在医学图像领域得到广泛应用。VTK完全采用面向对象的设计思想来设计与开发,提供了超过300个C++类,支持Window,Unix与Linux等多种平台,支持C,C++,Java,Tcl/Tk以及Python等编程语言,目前已发布的稳定版本是4.2。
Advanced Digital Imaging Solutions Laboratory (ADISL)
Image Apprentice is a C/C++ based Image Processing Learner’s Toolkit. Students use it as a companion to their favourite Image Processing Textbook. It allows one to use self-written image processing algorithms as plugins. 
It comes with a Plugin Development Kit (PDK) that has a skeleton code having a simple coding style. A student who has attended a 101-level course in C/C++ programming is well-equipped to write an Image Processing plugin for Image Apprentice using Visual C++.
AllSeeingI
AllSeeingI (ASI) is the codename for a computer vision and visualization framework. It is a visual programming environment for rapid development and easy reusability.
Editor's Note - This project is just getting started but may be a chance for developers to contribute to a brand new vision system.
CamCap and CLAG
Links to the Nottingham video processing environment otherwise known collectively as CamCap, for camera and video processing work and CLAG, for command line based image processing/display and prototyping. The environment is windows based and makes use of DirectShow and the intel open source computer vision library (OpenCV).
CImg
The CImg Library is an open source C++ toolkit for image processing. It provides simple classes and functions to load, save, process and display images in your own C++ code. CImg stands for "Cool Image" : It is simple to use and efficient. It's like a STL for image processing!
CMVision
Project goal was to create a simple, robust vision system suitable for real time robotics applications. The system aims to perform global low level color vision at video rates without the use of special purpose harware.
CVIPtools
One of the primary purposes of the CVIPtools development is to allow students, faculty, and other researchers to explore the power of computer processing of digital images. 
The newest version of CVIPtools, version 4.3, developed at the Computer Vision and Image Processing Laboratory at Southern Illinois University at Edwardsville, under the continuing direction of Dr. Scott E Umbaugh is currently available with the new textbook, Computer Imaging: Digital Image Analysis and Processing.
EDISON
Code for the Edge Detection and Image SegmentatiON system. This system is a low-level feature extraction tool that integrates confidence based edge detection and mean shift based image segmentation. It was developed by the Robust Image Understanding Laboratory at Rutgers University.
FILTERS
Filters is a library (not an application) implementing image filters and image processing functions.
Gandalf
The Fast Computer Vision and Numerical Library. Gandalf is a C library designed to support the development of computer vision applications. Gwyddion
Gwyddion is a modular program for SPM (scanning probe microscopy) data analysis. Primarily it is supposed to be used for analysis of height fields obtained by means of scanning probe microscopy techniques (AFM, MFM, STM, NSOM), but generally it can be used for any other height field analysis or image analysis.
Gluas plus GIMP - GNU Image Manipulation Program
Gluas is a GIMP plug-in providing a enviroment for testing algorithms for image processing. The environment contains a simple editor for entering the algorithms. It uses the lua interpreter.
Hornets Eye
HornetsEye also is an attempt to trim down the Mimas library and create a minimalistic and consistent C++/Ruby real-time computer vision library with an interface to Ruby.
iLab Neuromorphic Vision C++ Toolkit (iNVT)
The iLab Neuromorphic Vision C++ Toolkit is a comprehensive set of C++ classes for the development of neuromorphic models of vision. Neuromorphic models are computational neuroscience algorithms whose architecture and function is closely inspired from biological brains. The iLab Neuromorphic Vision C++ Toolkit comprises not only base classes for images, neurons, and brain areas, but also fully-developed models such as our model of bottom-up visual attention and of Bayesian surprise.
IM Toolkit
Windows and UNIX - The idea behind IM was to create a toolkit that was not so complex as OpenCV, neither so big as VTK, but that can be used as a solid base to the development of thesis and dissertations, as for commercial applications.
ImageJ
ImageJ is a public domain Java image processing program inspired by NIH Image for the Macintosh. It runs, either as an online applet or as a downloadable application, on any computer with a Java 1.1 or later virtual machine. Downloadable distributions are available for Windows, Mac OS, Mac OS X and Linux.
Editor's Note - This project is geared towards medical image analysis. If you need to analyze image cross-sections, break/create image stacks, then this package is worth some attention!
ImLib3D
ImLib3D is a C++ library and visualisation system for 3D image processing. It contains most basic image processing algorithms, and some more sophisticated ones. ImLib3D images are STL-compliant templated containers.
Imalab
Imalab is a powerful development environment for complex applications in computer vision. It allows for flexible interactive experimentation with the vision modules developed in the Prima team, and can be dynamically extended with new modules. A versatile scripting mechanism provides for fast and convenient interactive development.
Editor's Note - Most of the documentation is in French.
IMLAB
IMLAB is a free open source graphical application for Scientific Image Processing that runs in Windows, Linux and many other UNIX systems. It supports multiple windows, data types including 32 bit integers, 32 bit real numbers and complex numbers. It is implemented in C++ and also in C to provide a very simple way to add new functions. It has many image operations and supports several file formats.
IPL
Intel® Integrated Performance Primitives (Intel® IPP) is a software library of highly optimized functions for multimedia, audio, video, speech, computer vision, image and signal processing.
IMPROMPTU
IMPROMPTU, which stands for IMage PROcessing Module for the Prototyping, Testing, and Utilization of image analysis processes, is a software package for multi-dimensional image processing. With IMPROMPTU, a user can construct an arbitrary sequence of operations to run automatically on an input volume. This sequence, referred to as a process, can be made up of operations selected from any of several categories. Each category, which represents one general type of image-processing operation, contains a number of functions.
JHLabs
Jerry's Java Image Processing Pages. A great way to explore many image processing filters by experimenting with Java applets. 
Java Advanced Imaging (JAI) API
The Java Advanced Imaging API provides a set of object-oriented interfaces that support a simple, high-level programming model which lets you manipulate images easily.
MegaWave
MegaWave2 is a free software intended for image processing. It is made of a C library of modules, that contains original algorithms written by researchers and a Unix/Linux package designed for the fast developpement of new image processing algorithms.
Leptonica Library
This site contains well-tested C code for some basic image processing operations, along with a description of the functions and some design methods. A full set of affine transformations (translation, shear, rotation, scaling) on images of all depths is included, with the exception that some of the scaling methods do not work at all depths. There are also implementations of binary morphology, grayscale morphology, convolution and rank order filters, and applications such as jbig2 image processing and color quantization.
LTI-Lib
The LTI-Lib is an object oriented library with algorithms and data structures frequently used in image processing and computer vision. It has been developed at the Chair of Technical Computer Science (Lehrstuhl fuer Technische Informatik) LTI at the Aachen University of Technology, as part of many research projects in computer vision dealing with robotics, object recognition and sign language and gesture recognition.
Lispix
Lispix is a public domain image analysis program for Microsoft Windows (PC), written and maintained by David Bright. It features a collection of special purpose research tools for electron microscopy and spectral imaging at NIST. Most of Lispix is written in Common Lisp.
LuaMat
LuaMat aims to provide a easy to use language to create visual effects and to modify images. LuaMat is a fast way to use the most popular algorithms of Image Processing and Computer Vision. As Lua, becoming the standard for video-game scripting engines, LuaMat is fast and has a simple syntax.
The Mimas toolkit
Mimas was originally conceived as a platform for real-time machine vision research. Its aim was and still is to reduce the turnaround time of new research into the application workspace. It is written in C++ and is released in source code form subject to the GNU Lesser General Public License (LGPL).
Mavis
Mavis is computer vision software for mobile robots. It's part of an ongoing, group robotics project, called Leaf.
MIRIAD
MIRIAD (Multichannel Image Reconstruction, Image Analysis and Display) is a toolbox, in the form of an environment with a large set of moderate-sized program which perform individual tasks, involving calibration, mapping, deconvolution and image analysis of interferometric data. MIRIAD software is also part of the Hat Creek telescope control software; data obtained from the telescopes is directly written into MIRIAD format with a MIRIAD user interface.
Motion
Motion is a program that monitors the video signal from one or more cameras and is able to detect if a significant part of the picture has changed; in other words, it can detect motion.
tnimage
tnimage is a scientific image analysis program that allows you to create, edit, analyze, and produce color prints of images. It is particularly useful for analyzing images of SDS and agarose gels and X-ray or MRI images.
NeatVision
NeatVision is a free Java based image analysis and software development environment, which provides high level access to a wide range of image processing algorithms through well defined and easy to use graphical interface. NeatVision is in its second major release.
NIH IMAGE
NIH Image is a public domain image processing and analysis program for the Macintosh. It was developed at the Research Services Branch (RSB) of the National Institute of Mental Health (NIMH), part of the National Institutes of Health (NIH).
Editor's Note - The NIH IMAGE project is similar to ImageJ. In fact they are documented side by side. ImageJ is recommended to be used by PC based users as NIH IMAGE is a Mac based program.
OpenCV
OpenCV is an extensive open-source image processing library, built on the Intel Image Processing Library (IPL). OpenCV aids commercial uses of computer vision in human-computer interface, robotics, monitoring, biometrics and security by providing a free and open infrastructure where the distributed efforts of the vision community can be consolidated and performance optimized.
Peter Kovesi Research
MATLAB and Octave Functions for Computer Vision and Image Processing.
Projective Vision Toolkit
The Projective Vision Toolkit (PVT) is a series of utilities that allows one to take an image sequence and compute the fundamental matrix and trilinear tensor.
This can be used for such problems as camera selfcalibration, structure from motion, camera motion annotation, image stabilization, 3D tracking and recognition, etc.
RAVL - Recognition And Vision Library
RAVL provides a base C++ class library, together with a range of computer vision, pattern recognition and supporting tools. The aim of RAVL is to move software developed within the Centre for Vision, Speech and Signal Processing at the University of Surrey, England for research purposes into the public domain and to support its use in a wider community.
RoboRealm
Using RoboRealm you can create a low cost vision software solution with a standard webcam that allows you to explore the very complex world of image analysis and image processing. Through an easy to use analysis pipeline you can add image processing filters to translate an image into robotic movements, computer actions, or just plain fun! RoboRealm is free to download!
RobotVisionCAD
RobotVisionCAD or in short RvCAD is a computer aided design for Image Processing and Computer Vision. RvCAD's GUI presents users with a view where users drag and drop Image Processor Elements, and visually connecting them to form Image Processing Pipeline. RvCAD supports real-time live video processing from VideoForWindow, DirectShow(WDM) and Video4Linux on linux, compatible capture device.
SPIDER
SPIDER (System for Processing Image Data from Electron microscopy and Related fields) is an image processing system for electron microscopy.
TINA
TINA (TINA Is No Acronym) is an open source environment developed to accelerate the process of image analysis research. TINA provides functionality to assist in all areas of image analysis including handling of image, image feature and geometrical data; statistical and numerical analysis of data; GUI development as well as transmission and containment of data. TINA also provides a range of high-level analysis techniques for both machine vision (3D object location, 2D object recognition, temporal-stereo depth estimation, etc) and medical image analysis (MR tissue segmentation, blood flow analysis, etc).
Tekkotsu
Exploring Tekkotsu Programming on the Sony AIBO. Tekkotsu (see www.Tekkotsu.org) is an application development framework for the Sony AIBO robot dog. ("Tekkotsu" literally means iron bones in Japanese, and refers to a metal framework, such as the skeleton of a building.) At its lowest level, Tekkotsu provides primitives for sensory processing, smooth control of effectors, and event-based communication.
Torch3vision
It's a machine vision library, written in simple C++ and based on the Torch machine-learning library. This package contains Basic image processing and feature extraction algorithms such as rotation, flip, photometric normalizations (Histogram Equalization, Multiscale Retinex, Self-Quotient Image or Gross-Brajovic), edge detection, 2D DCT, 2D FFT, 2D Gabor, PCA to do Eigen-Faces, LDA to do Fisher-Faces
UTHSCSA ImageTool
UTHSCSA ImageTool (IT) is a free image processing and analysis program for Microsoft Windows 9x, Windows ME or Windows NT. IT can acquire, display, edit, analyze, process, compress, save and print gray scale and color images.IT can read and write over 22 common file formats including BMP, PCX, TIF, GIF and JPEG.
VXL
VXL (the Vision-something-Libraries) is a collection of C++ libraries designed for computer vision research and implementation. It was created from TargetJr and the IUE with the aim of making a light, fast and consistent system. VXL is written in ANSI/ISO C++ and is designed to be portable over many platforms. There are libraries covering numerical algorithms, image processing, co-ordinate systems, camera geometry, stereo, video manipulation, structure recovery from motion, probability modelling, GUI design, classification, robust estimation, feature tracking, topology, structure manipulation, 3d imaging, and much more.
XMegaWave
XMegaWave (XMW) is a freeware graphical windows environment oriented towards image processing. The development of XMW has been based on the collaboration between researchers from the University of the Balearic Islands (Spain), the University of Las Palmas de Gran Canaria (Spain) and the University of Paris IX Dauphine (France).
XVision
XVision provides an application independent set of tools for visual feature tracking optimized to be simple to configure at the user level, yet extremely fast to execute.

9/11/09

Matlab memory management.

Here is the office site describing how to use memory efficiently with Matlab.
One common pit is the following:

>> a=rand(100e6,1);

The above command will generate vector a; now if you want to generate another set of random numbers and store in a, you may think you just type in:

>> a = rand(100e6, 1)

This will not work!!!

You need to do the following:
>> a = rand(100e6, 1);
>> clear;
>> a= rand(100e6, 1);

This way, basically you clear out the old variable "a" first, then you generate a new one and store it in a. Basically the biggest memory to use to allocate the variable is half of your memory in this case.

9/9/09

Mac keynote 2009 format.

he new iWork '09 suite includes a new file format that packs all the data into a single file, rather than using a package bundle, as did iWork '08.


To get the folder, just change the extension of the file from .key to .zip. Then you can just unzip it to a folder. Change back from .zip to .key will give you the intact keynote file. 


To get the old formats back, simply go into Preferences in each iWork application, and under the General tab, check the box that says Save new documents as packages

5/18/09

Tricks to search emails in gmail.

To search all the unread emails:


In the search box, type "is:unread" without quotes. It will show you all the unread emails. By using "is:unread label:inbox", you will get all the unread emails in the inbox. 

4/15/09

delete locked files on Mac

Advanced tip about deleting locked files

If there are several locked files in the Trash, you can unlock them all at the same time at the command line. Follow these steps:

  1. Open Terminal. It's located in /Applications/Utilities.

    Type: chflags -R nouchg 
    Note: Type one space (not pictured) after nouchg in the line above, so that it ends in "nouchg ". Do not press Return yet.
  2. Double-click the Trash icon in the Dock to reveal the contents of the Trash. If necessary, arrange the Finder window so that a portion of the Terminal window is still visible.
  3. Press the Command-A key combination to select all files in the Trash.
  4. Drag the files from the Trash to the Terminal window. 
    Note: This automatically enters the pathname for each file. This eliminates the need to individually empty multiple Trash directories, particularly when multiple disks or volumes are present.
  5. Press Return. No special text message will be shown indicating that the command was successful.
  6. Empty the Trash.


If the Trash does not empty or if you see a message in Terminal that says "usage: chflags [-R [-H | -L | -P]] flags file..." you most likely did not type the text in step 2 as indicated or did not leave a space. Repeat the steps if this happens.


originally from: http://support.apple.com/kb/HT1526

1/9/09

Qt link error

I install Qt (4.4.3) version of dmg files and debug files (dmg file) the instalation is full. I type

qmake -project (create project.pro)
qmake (create project.xcodeproj)

I open xcodeproj file in xcode (version 2.2.1) and copile project. The stage of compiler is good but the stage of linking send me this error:

/usr/bin/ld: /Library/Frameworks/QtGui.framework/QtGui load command 6 unknown cmd field


/usr/bin/ld: /Library/Frameworks/QtCore.framework/QtCore load command 5 unknown cmd field

collect2: ld returned 1 exit status
---------------------------------------------------------------------------------------------------------
I solved this problem by upgrading my xcode to version 2.5. Now the program can be compiled.

1/5/09

Recover old version of Qt on Mac (Tiger)

I have problems with Qt 4.4 on my Mac (tiger) and I posted my questions. But so far no real solution yet. I want to switch back to Qt 4.3.4. But when I used the dmg file to install it, the computer says "there is nothing to install". How can I deal with this?

Navigate to /Library/Receipts, find the Reciept from the last time you used the package installer to install 4.3.4 (back before you had 4.4.0), and delete it/them. Looking at my machine, it looks like there might be several packages named something like Qt_libraries, Qt_docs, etc. The installer should be happy then. No guarantees as to how well this will actually work with the 4.4.0 install though. I THINK it should work.