
* green/exp/labeling/regional_maxima/Makefile.am: New Makefile. * green/exp/clustering/regional_maxima/regional_maxima.cc: New directory oriented demonstration code. --- milena/sandbox/ChangeLog | 22 ++- .../labeling/regional_maxima}/Makefile.am | 8 +- .../labeling/regional_maxima/regional_maxima.cc | 156 ++++++++++++++++++++ 3 files changed, 175 insertions(+), 11 deletions(-) copy milena/sandbox/green/{demo/annoting/rgb_64 => exp/labeling/regional_maxima}/Makefile.am (95%) create mode 100644 milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index b3029e2..37cce8a 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,37 +1,45 @@ 2009-12-02 Yann Jacquelet <jacquelet@lrde.epita.fr> + Test experimentation with regmax code on annoting database. + + * green/exp/labeling/regional_maxima/Makefile.am: New Makefile. + * green/exp/clustering/regional_maxima/regional_maxima.cc: New directory + oriented demonstration code. + +2009-12-02 Yann Jacquelet <jacquelet@lrde.epita.fr> + Transform kmean object in a big function and then a canvas. * green/mln/clustering/kmean_rgb.hh: New library source code. - * green/demo/clustering/kmean_rgb/Makefile: New Makefile. + * green/demo/clustering/kmean_rgb/Makefile.am: New Makefile. * green/demo/clustering/kmean_rgb/kmean_rgb.cc: New demo. code. 2009-12-02 Yann Jacquelet <jacquelet@lrde.epita.fr> Benchmark on distance, preliminary work before optimizing kmean. - * green/bench/transform/distance/Makefile: New Makefile. + * green/bench/transform/distance/Makefile.am: New Makefile. * green/bench/transform/distance/distance.cc: New processing chain. 2009-12-02 Yann Jacquelet <jacquelet@lrde.epita.fr> Works on Millet2008 descriptors. - * green/mln/demo/annoting/bic/Makefile: New Makefile. + * green/mln/demo/annoting/bic/Makefile.am: New Makefile. * green/mln/demo/annoting/bic/bic.cc: New impl. of the bic descriptor. - * green/mln/demo/annoting/lep/Makefile: New Makefile. + * green/mln/demo/annoting/lep/Makefile.am: New Makefile. * green/mln/demo/annoting/lep/lep.cc: New impl. of the lep descriptor. - * green/mln/demo/annoting/project/Makefile: New Makefile. + * green/mln/demo/annoting/project/Makefile.am: New Makefile. * green/mln/demo/annoting/project/project.cc: New impl. of the project descriptor. - * green/mln/demo/annoting/rgb_64/Makefile: New Makefile. + * green/mln/demo/annoting/rgb_64/Makefile.am: New Makefile. * green/mln/demo/annoting/rgb_64/rgb_64.cc: New impl. of the rgb_64 descriptor. - * green/mln/demo/annoting/rgb_64_9/Makefile: New Makefile. + * green/mln/demo/annoting/rgb_64_9/Makefile.am: New Makefile. * green/mln/demo/annoting/rgb_64_9/rgb_64_9.cc: New impl. of the rgb_64_9 descriptor. diff --git a/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am similarity index 95% copy from milena/sandbox/green/demo/annoting/rgb_64/Makefile.am copy to milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am index 96eafb4..ab76e18 100644 --- a/milena/sandbox/green/demo/annoting/rgb_64/Makefile.am +++ b/milena/sandbox/green/exp/labeling/regional_maxima/Makefile.am @@ -8,15 +8,15 @@ INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green #CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES) -CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES) -#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES) +#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES) +CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES) ECHO= echo RM= rm MKDIR= mkdir -p CP= cp -SOURCE_PATTERN= green/demo -BUILD__PATTERN= green/build/demo +SOURCE_PATTERN= green/exp +BUILD__PATTERN= green/build/exp ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN)) diff --git a/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc new file mode 100644 index 0000000..28b6b88 --- /dev/null +++ b/milena/sandbox/green/exp/labeling/regional_maxima/regional_maxima.cc @@ -0,0 +1,156 @@ +// EXPERIMENTATION ON REGIONAL MAXIMA +// COUNTING THE IMAGE COLORS + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/math/sum.hh> +#include <mln/accu/math/count.hh> +#include <mln/accu/stat/histo3d_rgb.hh> +#include <mln/accu/stat/mean.hh> +#include <mln/accu/stat/variance.hh> + +#include <mln/algebra/vec.hh> + +#include <mln/arith/diff_abs.hh> + +#include <mln/core/macros.hh> +#include <mln/core/alias/neighb3d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/image3d.hh> +#include <mln/core/image/dmorph/image_if.hh> +#include <mln/core/routine/initialize.hh> + +#include <mln/data/compute.hh> +#include <mln/data/fill.hh> +#include <mln/data/transform.hh> + +#include <mln/fun/v2v/rgb8_to_rgbn.hh> + +#include <mln/io/pgm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/ppm/load.hh> +#include <mln/io/ppm/save.hh> + +#include <mln/labeling/regional_maxima.hh> +#include <mln/labeling/mean_values.hh> +#include <mln/labeling/compute.hh> + +#include <mln/literal/colors.hh> + +#include <mln/morpho/opening/volume.hh> +#include <mln/morpho/elementary/dilation.hh> + +#include <mln/opt/at.hh> + +#include <mln/pw/cst.hh> + +#include <mln/util/array.hh> +#include <mln/util/timer.hh> + +#include <mln/value/label_8.hh> +#include <mln/value/rgb8.hh> +#include <mln/value/rgb.hh> +#include <mln/value/int_u.hh> + + +// LISTER UN REPERTOIRE +// ECRIRE UN FICHIER DE SYNTHESE SUR LA CLASSE +// + + +// n < 8, n is the degree of quantification +template <unsigned n> +unsigned count_image_color(const std::string& image) +{ + typedef mln::value::label_8 t_lbl8; + typedef mln::value::int_u8 t_int_u8; + typedef mln::value::rgb8 t_rgb8; + typedef mln::value::rgb<n> t_rgbn; + typedef mln::image3d<t_lbl8> t_image3d_lbl8; + typedef mln::image2d<t_lbl8> t_image2d_lbl8; + typedef mln::image2d<t_rgb8> t_image2d_rgb8; + typedef mln::image2d<t_rgbn> t_image2d_rgbn; + typedef mln::image2d<t_int_u8> t_image2d_int_u8; + typedef mln::image3d<unsigned> t_histo3d; + typedef mln::image2d<unsigned> t_histo2d; + typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn; + typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun; + typedef mln::accu::meta::math::count t_count_fun; + + t_image2d_rgb8 input_rgb8; + t_image2d_rgbn input_rgbn; + t_image2d_rgbn output_rgbn; + t_histo3d histo; + t_histo3d opened; + t_image3d_lbl8 label; + t_image2d_lbl8 label_img; + t_image3d_lbl8 dilated; + t_lbl8 n_labels; + + mln::io::ppm::load(input_rgb8, image.c_str()); + + unsigned nb_pixel = input_rgb8.ncols() * input_rgb8.nrows(); + unsigned min_volume = (unsigned)(nb_pixel * 0.054); + + input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn()); + // FIXME UTILISER UN PREDICAT COMME FUN::CHESS + histo = mln::data::compute(t_histo3d_fun(), input_rgbn | mln::pw::value(0)); +// return mln::data::compute(t_count_fun(), input_rgbn); + // FIXME REALISER UN COUNT AVEC UN PREDICA SUR L'IMAGE + return nb_pixel; +// opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume); +// label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels); + +// return n_labels; +} + + +int main() +{ + typedef boost::filesystem::path t_path; + //typedef boost::filesystem::initial_path<t_path()> t_init_path; + typedef boost::filesystem::directory_iterator t_iter_path; + + t_path full_path(ANNOTING_TYPED_IMG_PATH); + + std::cout << "entering " << full_path << std::endl; + + if (//1 < argc && + boost::filesystem::exists(full_path) && + boost::filesystem::is_directory(full_path)) + { + boost::filesystem::system_complete(full_path); + const t_iter_path end_iter; + unsigned count = 0; + unsigned sum1 = 0; + unsigned sum2 = 0; + + for (t_iter_path dir_iter(full_path); end_iter != dir_iter; ++dir_iter) + { + unsigned val = count_image_color<5>(dir_iter->path().string()); + + ++count; + sum1 += val; + sum2 += val*val; + + std::cout << dir_iter->path().string() << " => " << val << std::endl; + // FIXME NB COULEURS BRUTES + // FIXME NB DE COULEURS + // FIXME LISTE DES COULEURS + // IMPORTANCES + } + + unsigned mean = sum1 / count; + unsigned var = sum2 / count - mean * mean; + + std::cout << "mean : " << mean << std::endl; + std::cout << "var : " << var << std::endl; + } + + return 0; +} + -- 1.5.6.5