Segmenting image.

by raulzito234

2. Separating the image from the background

This parts consists of identifying the segment of the part of the image that corresponds to the object of interest. For this part I had to download and compile code found at

http://www.cs.berkeley.edu/~fowlkes/BSE/

For porting the code to my computer I had to modify some headers and change the settings for the compiler.

First I had to install gfortran, which can be found on the following website:

http://hpc.sourceforge.net/

But because the gfortran is linked to a newer version of the c++ compiler, I had to follow delete Xcode, install g++ and reinstall Xcode. I found the answer for my problem in the following website:

http://eftrunk.blogspot.com/2011/11/how-to-fix-error-trying-to-exec-f951.html

I learned a lesson: I should follow other’s people advices if I’m not moving on.

Then, after being able to compile the code with gfortran I had to modify the compiler used for c++, instead of using c++, I started using g++.

Even tough I didn’t use some of the knowledge that I’ve learned in the process of solving this problem. I think it’s interesting to remember some of the material.

How the Makefile works:

http://www.opussoftware.com/tutorial/TutMakefile.htm

And a header is actually included inside a cpp file, i.e. the file is inserted at the beginning of the file.

Another useful information is the -i and -l flags.

The -l flag is used to add libraries when compiling and the -i flag is to add pathnames when including headers from other directories:

-l library
Search the library named library when linking. (The second
alternative with the library as a separate argument is only for
POSIX compliance and is not recommended.)

It makes a difference where in the command you write this option;
the linker searches and processes libraries and object files in the
order they are specified. Thus, foo.o -lz bar.o searches library z
after file foo.o but before bar.o. If bar.o refers to functions in
z, those functions may not be loaded.

The linker searches a standard list of directories for the library,
which is actually a file named liblibrary.a. The linker then uses
this file as if it had been specified precisely by name.

The directories searched include several standard system
directories plus any that you specify with -L.

Normally the files found this way are library files—archive files
whose members are object files. The linker handles an archive file
by scanning through it for members which define symbols that have
so far been referenced but not defined. But if the file that is
found is an ordinary object file, it is linked in the usual
fashion. The only difference between using an -l option and
specifying a file name is that -l surrounds library with lib and .a
and searches several directories.

For the -Ldir of the file we have:

-Ldir
Add directory dir to the list of directories to be searched for -l.

The -I flag:

-I dir
Add the directory dir to the list of directories to be searched
for header files. Directories named by -I are searched before the
standard system include directories. If the directory dir is a
standard system include directory, the option is ignored to ensure
that the default search order for system directories and the
special treatment of system headers are not defeated .

Then I encountered a new problem: The c++ files didn’t contain the definition of types used at the code. And all the headers that were included in the file didn’t contain the definition of the structure being used.

To solve this problem I looked for similar files that used the same structure and tried to determine what headers did these files use and I discover that one of these headers contained in the file using the same structure had the definition as it should.

Lesson: Try to identify similar code that does the same thing that you are trying to do. It gives a lot of insight.

After I compiled the code I run to a new problem, I tried to run the command:

./segment -image image.jpg -segfile image.seg -numsuperpixels 8

But I ran into the problem:

entering segment_main
reading image giu.jpg
Wrong JPEG library version: library is 80, caller expects 62

After googling the possible problem I found out that (http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=21131):

This error occurs when one of the delegate libraries include an older version of JPEG than what is currently on your system.

Therefore to solve this problem I need to install a older version of the jpeg library and link the code to the older version of the jpeg library.

Advertisements