git HEAD
--------
+* Image segmentation example now has a build flag for the version of CImg
* Deprecated Graph::Neighbor, BipartiteGraph::Neighbor and DAG::Neighbor
and replaced them by a globally defined Neighbor structure
* Deprecated Graph::Neighbors, BipartiteGraph::Neighbors and DAG::Neighbors
all : $(TARGETS)
@echo libDAI built successfully!
-examples : examples/example$(EE) examples/example_bipgraph$(EE) examples/example_varset$(EE) examples/example_permute$(EE) examples/example_sprinkler$(EE) examples/example_sprinkler_gibbs$(EE) examples/example_sprinkler_em$(EE) examples/example_imagesegmentation$(EE)
+EXAMPLES=$(foreach name,example example_bipgraph example_varset example_permute example_sprinkler example_sprinkler_em,examples/$(name)$(EE))
+ifdef WITH_GIBBS
+ EXAMPLES:=$(EXAMPLES) examples/example_sprinkler_gibbs$(EE)
+endif
+ifdef WITH_CIMG
+ EXAMPLES:=$(EXAMPLES) examples/example_imagesegmentation$(EE)
+endif
+examples : $(EXAMPLES)
matlabs : matlab/dai$(ME) matlab/dai_readfg$(ME) matlab/dai_writefg$(ME) matlab/dai_potstrength$(ME)
$(CC) $(CCO)$@ $< $(LIBS)
examples/example_sprinkler_gibbs$(EE) : examples/example_sprinkler_gibbs.cpp $(HEADERS) $(LIB)/libdai$(LE)
-ifdef WITH_GIBBS
$(CC) $(CCO)$@ $< $(LIBS)
-else
- @echo Skipping $@
-endif
examples/example_imagesegmentation$(EE) : examples/example_imagesegmentation.cpp $(HEADERS) $(LIB)/libdai$(LE)
- -$(CC) $(CIMGINC) $(CCO)$@ $< $(LIBS) $(CIMGLIBS)
+ifdef NEW_CIMG
+ $(CC) -DNEW_CIMG $(CIMGINC) $(CCO)$@ $< $(LIBS) $(CIMGLIBS)
+else
+ $(CC) $(CIMGINC) $(CCO)$@ $< $(LIBS) $(CIMGLIBS)
+endif
# UNIT TESTS
WITH_CBP=true
WITH_DECMAP=true
-# Build doxygen documentation?
-WITH_DOC=
-
-# Build with debug info?
+# Build with debug info? (slower but safer)
DEBUG=true
-# Build MatLab interface?
+# Build doxygen documentation? (doxygen and TeX need to be installed)
+WITH_DOC=
+
+# Build MatLab interface? (MatLab needs to be installed)
WITH_MATLAB=
-# MatLab version 7.3 (R2006b) or newer?
-NEW_MATLAB=true
+# Build image segmentation example? (CImg needs to be installed)
+WITH_CIMG=
CCNODEBUGFLAGS=-O3
# Standard include directories
CCINC=-Iinclude -I/cygdrive/e/cygwin/boost_1_42_0
-# Include directory for image segmentation example
-CIMGINC=-I/cygdrive/e/cygwin/CImg-1.3.9
# LINKER
# Standard libraries to include
# For linking with BOOST libraries
BOOSTLIBS_PO=-lboost_program_options
BOOSTLIBS_UTF=-lboost_unit_test_framework
-# Libraries for image segmentation example
-CIMGLIBS=-lpthread -lX11
# Additional library search paths for linker
CCLIB=-Llib -L/cygdrive/e/cygwin/boost_1_42_0/stage/lib
# MATLAB
+# MatLab version 7.3 (R2006b) or newer?
+NEW_MATLAB=true
# Replace the following by the directory where MatLab has been installed
MATLABDIR=/agbs/share/sw/matlab
# The following should resolve to the MatLab mex compile command
INCLUDE_PYTHON=/usr/include/python2.5
# Location of Boost C++ library header files
INCLUDE_BOOST=/cygdrive/e/cygwin/boost_1_42_0
+
+# CIMG
+# CImg version 1.3.0 or newer?
+NEW_CIMG=true
+# Include directory for image segmentation example
+CIMGINC=-I/cygdrive/e/cygwin/CImg-1.3.9
+# Libraries for image segmentation example
+CIMGLIBS=-lpthread -lX11
CCNODEBUGFLAGS=-O3
# Standard include directories
CCINC=-Iinclude
-# Include directory for image segmentation example
-CIMGINC=
# LINKER
# Standard libraries to include
# For linking with BOOST libraries
BOOSTLIBS_PO=-lboost_program_options-mt
BOOSTLIBS_UTF=-lboost_unit_test_framework-mt
-# Libraries for image segmentation example
-CIMGLIBS=-lpthread -lX11
# Additional library search paths for linker
CCLIB=-Llib
# MATLAB
+# MatLab version 7.3 (R2006b) or newer?
+NEW_MATLAB=true
# Replace the following by the directory where MatLab has been installed
MATLABDIR=/agbs/share/sw/matlab
# The following should resolve to the MatLab mex compile command
INCLUDE_PYTHON=/usr/include/python2.5
# Location of Boost C++ library header files
INCLUDE_BOOST=/usr/include/boost
+
+# CIMG
+# CImg version 1.3.0 or newer?
+NEW_CIMG=true
+# Include directory for image segmentation example
+CIMGINC=
+# Libraries for image segmentation example
+CIMGLIBS=-lpthread -lX11
CCNODEBUGFLAGS=-O3
# Standard include directories
CCINC=-Iinclude -I/opt/local/include
-# Include directory for image segmentation example
-CIMGINC=
# LINKER
# Standard libraries to include
# For linking with BOOST libraries
BOOSTLIBS_PO=-lboost_program_options
BOOSTLIBS_UTF=-lboost_unit_test_framework
-# Libraries for image segmentation example
-CIMGLIBS=-lpthread -lX11
# Additional library search paths for linker
CCLIB=-Llib -L/opt/local/lib
# MATLAB
+# MatLab version 7.3 (R2006b) or newer?
+NEW_MATLAB=true
# Replace the following by the directory where MatLab has been installed
MATLABDIR=/agbs/share/sw/matlab
# The following should resolve to the MatLab mex compile command
INCLUDE_PYTHON=/usr/include/python2.5
# Location of Boost C++ library header files
INCLUDE_BOOST=/usr/include/boost
+
+# CIMG
+# CImg version 1.3.0 or newer?
+NEW_CIMG=true
+# Include directory for image segmentation example
+CIMGINC=
+# Libraries for image segmentation example
+CIMGLIBS=-lpthread -lX11
CCDEBUGFLAGS=/Ox /Zi /DDAI_DEBUG
# Flags to add in non-debugging mode (if DEBUG=false)
CCNODEBUGFLAGS=/Ox
-# Include directory for image segmentation example
-CIMGINC=-IE:\windows\CImg-1.3.9
# Standard include directories
CCINC=-Iinclude -IE:\windows\boost_1_42_0
# For linking with BOOST libraries
BOOSTLIBS_PO=/LIBPATH:E:\windows\boost_1_42_0\stage\lib
BOOSTLIBS_UTF=/LIBPATH:E:\windows\boost_1_42_0\stage\lib
-# Libraries for image segmentation example
-CIMGLIBS=gdi32.lib
# Additional library search paths for linker
# (For some reason, we have to add the VC library path, although it is in the environment)
CCLIB=/LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB" /LIBPATH:"C:\Program Files\Microsoft Visual Studio 9.0\VC\LIB" /LIBPATH:"C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib"
# MATLAB
+# MatLab version 7.3 (R2006b) or newer?
+NEW_MATLAB=true
# Replace the following by the directory where MatLab has been installed
MATLABDIR=c:\matlab\R2008b
# The following should resolve to the MatLab mex compile command
INCLUDE_PYTHON=C:\python2.5
# Location of Boost C++ library header files
INCLUDE_BOOST=E:\windows\boost_1_42_0
+
+# CIMG
+# CImg version 1.3.0 or newer?
+NEW_CIMG=true
+# Include directory for image segmentation example
+CIMGINC=-IE:\windows\CImg-1.3.9
+# Libraries for image segmentation example
+CIMGLIBS=gdi32.lib
#include <iostream>
#include <dai/alldai.h> // Include main libDAI header file
-#include <CImg.h> // This example needs a recent version of CImg to be installed
-
-
-// For backwards compatibility with old CImg interface
-// #define CIMGOLD
+#include <CImg.h> // This example needs CImg to be installed
using namespace dai;
vector<Var> vars;
vector<Factor> factors;
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
size_t dimx = img.width; // Width of the image in pixels
size_t dimy = img.height; // Height of the image in pixels
#else
}
// Display the image with the current beliefs
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
disp << image;
#else
disp = image;
CImg<unsigned char> image2 = CImg<>( file_i2 );
// Check image sizes
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
if( (image1.width != image2.width) || (image1.height != image2.height) )
cerr << "Error: input images should have same size." << endl;
size_t dimx = image1.width;
for( size_t i = 0; i < dimx; i++ ) {
for( size_t j = 0; j < dimy; j++ ) {
int avg = 0;
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
for( int c = 0; c < image1.dimv(); c++ )
avg += image1( i, j, c );
avg /= image1.dimv();
image4(i,j,1) = image2(i,j,1);
image4(i,j,2) = image2(i,j,2);
} else
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
for( size_t c = 0; c < (size_t)image4.dimv(); c++ )
image4(i,j,c) = 255;
#else
image4.save_jpeg( file_o2, 100 );
cout << "Close the last image display in order to finish." << endl;
-#ifdef CIMGOLD
+#ifndef NEW_CIMG
while( !main_disp.is_closed )
cimg::wait( 40 );
#else