
* mln/io/plot/save_image_sh.hh: New header file. Give an example of code. * use/io/plot/save_image_sh: New directory. * use/io/plot/save_image_sh/Makefile.am: New makefile. * use/io/plot/save_image_sh/save_image_sh.cc: New source file. Make some unitary tests on gnuplot shell export. * tests/io/plot/save_image_sh: New directory. * tests/io/plot/save_image_sh/Makefile.am: New makefile. * tests/io/plot/save_image_sh/save_image_sh.cc: New source file. --- scribo/sandbox/green/ChangeLog | 109 +++++---- scribo/sandbox/green/README | 52 ++--- scribo/sandbox/green/mln/io/plot/save_image_sh.hh | 36 +++- .../green/tests/io/plot/save_image_sh/Makefile.am | 13 +- .../tests/io/plot/save_image_sh/save_image_sh.cc | 284 ++++++++++++++------ .../histo1d => io/plot/save_image_sh}/Makefile.am | 0 .../plot/save_image_sh/save_image_sh.cc} | 4 +- 7 files changed, 329 insertions(+), 169 deletions(-) copy scribo/sandbox/green/use/{accu/stat/histo1d => io/plot/save_image_sh}/Makefile.am (100%) copy scribo/sandbox/green/use/{accu/stat/histo1d/histo1d.cc => io/plot/save_image_sh/save_image_sh.cc} (91%) diff --git a/scribo/sandbox/green/ChangeLog b/scribo/sandbox/green/ChangeLog index db589a1..5a7ceaa 100644 --- a/scribo/sandbox/green/ChangeLog +++ b/scribo/sandbox/green/ChangeLog @@ -1,54 +1,20 @@ -2010-06-24 Yann Jacquelet <jacquelet@lrde.epita.fr> +2010-06-23 green <jacquelet@lrde.epita.fr> - Import files from milena/sandbox/green. + Define gnuplot shell export format. - * gaussian.sh: New gnuplot shell file. - * guassian2d.sh: New gnuplot shell file. - * test_labelling.cc: New source. - * tests/clustering/k_mean/Makefile.am: New makefile. - * tests/clustering/k_mean/k_mean.cc: New source. - * tests/clustering/kmean1d/Makefile.am: New makefile. - * tests/clustering/kmean1d/kmean1d.cc: New source. - * tests/io/plot/save_image_sh/Makefile.am: New makefile. - * tests/io/plot/save_image_sh/save_image_sh.cc: New source. + * mln/io/plot/save_image_sh.hh: New header file. -2010-06-24 Yann Jacquelet <jacquelet@lrde.epita.fr> + Give an example of code. - Import files from milena/sandbox/green. + * use/io/plot/save_image_sh: New directory. + * use/io/plot/save_image_sh/Makefile.am: New makefile. + * use/io/plot/save_image_sh/save_image_sh.cc: New source file. - * mln/accu/stat/histo1d.hh: New header file. - * mln/accu/stat/histo2d.hh: New header file. - * mln/accu/stat/histo3d_hsl.hh: New header file. - * mln/accu/stat/histo3d_rgb.hh: New header file. - * mln/clustering/k_mean.hh: New header file. - * mln/clustering/kmean1d.hh: New header file. - * mln/clustering/kmean2d.hh: New header file. - * mln/clustering/kmean3d.hh: New header file. - * mln/clustering/kmean_rgb.hh: New header file. - * mln/display/display_histo.hh: New header file. - * mln/display/project_histo.hh: New header file. - * mln/fun/p2b/achromatic.hh: New header file. - * mln/fun/p2b/component_equals.hh: New header file. - * mln/fun/v2v/achromatism.hh: New header file. - * mln/fun/v2v/hue_concentration.hh: New header file. - * mln/fun/v2v/int_u16_to_int_u14.hh: New header file. - * mln/fun/v2v/int_u16_to_int_u14.hh: New header file. - * mln/fun/v2v/log.hh: New header file. - * mln/fun/v2v/rg_to_rgb.hh: New header file. - * mln/fun/v2v/rgb8_to_int_u8: New header file. - * mln/fun/v2v/rgb_to_achromastism_map.hh: New header file. - * mln/fun/v2v/rgb_to_hsv.hh: New header file. - * mln/fun/v2v/rgb_to_hue_map.hh: New header file. - * mln/fun/v2v/rgb_to_saturation_map.hh: New header file. - * mln/fun/v2v/rgb_to_value_map.hh: New header file. - * mln/img_path.hh: New header file. - * mln/io/plot/save_image_sh.hh: New header file. - * mln/math/cell.hh: New header file. - * mln/math/floor.hh: New header file. - * tests/accu/stat/histo1d/Makefile.am: New makefile. - * tests/accu/stat/histo1d/histo1d.cc: New source. - * tests/accu/stat/histo2d/Makefile.am: New makefile. - * tests/accu/stat/histo2d/histo2d.cc: New source. + Make some unitary tests on gnuplot shell export. + + * tests/io/plot/save_image_sh: New directory. + * tests/io/plot/save_image_sh/Makefile.am: New makefile. + * tests/io/plot/save_image_sh/save_image_sh.cc: New source file. 2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr> @@ -130,6 +96,57 @@ * tests/accu/stat/histo3d_hsl/Makefile.am: New makefile. * tests/accu/stat/histo3d_hsl/histo3d_hsl.cc: New source. +2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr> + + Import files from milena/sandbox/green. + + * gaussian.sh: New gnuplot shell file. + * guassian2d.sh: New gnuplot shell file. + * test_labelling.cc: New source. + * tests/clustering/k_mean/Makefile.am: New makefile. + * tests/clustering/k_mean/k_mean.cc: New source. + * tests/clustering/kmean1d/Makefile.am: New makefile. + * tests/clustering/kmean1d/kmean1d.cc: New source. + * tests/io/plot/save_image_sh/Makefile.am: New makefile. + * tests/io/plot/save_image_sh/save_image_sh.cc: New source. + +2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr> + + Import files from milena/sandbox/green. + + * mln/accu/stat/histo1d.hh: New header file. + * mln/accu/stat/histo2d.hh: New header file. + * mln/accu/stat/histo3d_hsl.hh: New header file. + * mln/accu/stat/histo3d_rgb.hh: New header file. + * mln/clustering/k_mean.hh: New header file. + * mln/clustering/kmean1d.hh: New header file. + * mln/clustering/kmean2d.hh: New header file. + * mln/clustering/kmean3d.hh: New header file. + * mln/clustering/kmean_rgb.hh: New header file. + * mln/display/display_histo.hh: New header file. + * mln/display/project_histo.hh: New header file. + * mln/fun/p2b/achromatic.hh: New header file. + * mln/fun/p2b/component_equals.hh: New header file. + * mln/fun/v2v/achromatism.hh: New header file. + * mln/fun/v2v/hue_concentration.hh: New header file. + * mln/fun/v2v/int_u16_to_int_u14.hh: New header file. + * mln/fun/v2v/int_u16_to_int_u14.hh: New header file. + * mln/fun/v2v/log.hh: New header file. + * mln/fun/v2v/rg_to_rgb.hh: New header file. + * mln/fun/v2v/rgb8_to_int_u8: New header file. + * mln/fun/v2v/rgb_to_achromastism_map.hh: New header file. + * mln/fun/v2v/rgb_to_hsv.hh: New header file. + * mln/fun/v2v/rgb_to_hue_map.hh: New header file. + * mln/fun/v2v/rgb_to_saturation_map.hh: New header file. + * mln/fun/v2v/rgb_to_value_map.hh: New header file. + * mln/img_path.hh: New header file. + * mln/io/plot/save_image_sh.hh: New header file. + * mln/math/cell.hh: New header file. + * mln/math/floor.hh: New header file. + * tests/accu/stat/histo1d/Makefile.am: New makefile. + * tests/accu/stat/histo1d/histo1d.cc: New source. + * tests/accu/stat/histo2d/Makefile.am: New makefile. + * tests/accu/stat/histo2d/histo2d.cc: New source. 2010-06-21 Yann Jacquelet <jacquelet@lrde.epita.fr> diff --git a/scribo/sandbox/green/README b/scribo/sandbox/green/README index 4b6fb26..03106d3 100644 --- a/scribo/sandbox/green/README +++ b/scribo/sandbox/green/README @@ -153,8 +153,8 @@ d'exécution (chmod 755 gnuplot_shell_file.sh). Comme je trouve le format extrêmement pratique, il se retrouve preque partout dans mes sources. -V HISTOGRAMMES --------------- +VI HISTOGRAMMES +--------------- Un des travaux demandés par théo est la réalisation d'une librairie d'histogramme permettant de fournir un résultat sous forme d'image. @@ -173,7 +173,7 @@ a) version 1d * mln/accu/stat/histo1d.hh: Accumulateur histogramme image1d. * use/accu/stat/histo1d: Code minimal utilisant un histogramme 1d. -* tests/accu/stat/histo1d: Test unitaire sur l'histogramme 1d. +* tests/accu/stat/histo1d: Tests unitaires sur l'histogramme 1d. b) version 2d @@ -203,52 +203,42 @@ d) version 3d HSL * mln/accu/stat/histo3d_hsl.hh: Accumulateur histogramme image3d HSL. * use/accu/stat/histo3_hsl: Code minimal utilisant un histogramme 3d HSL. -* tests/accu/stat/histo3d_hsl: Test unitaire sur l'histogramme HSL 3d. +* tests/accu/stat/histo3d_hsl: Tests unitaires sur l'histogramme HSL 3d. Le code HSL ne compile plus car l'interface liant la transformation du domaine et la fonction fold a changée. Je n'ai pas le temps de regarder plus avant. +VII SAUVEGARDE FORMAT GNUPLOT SHELL +----------------------------------- -V MLN ------ - -a) La sauvegarde des images au format gnuplot shell - -* mln/io/plot/save_image_sh.hh: Librairie sauvegarde format gnuplot shell. - -to do ... - - - -b) Les histogrammes - - - - - - - +Ce travail est personnel. Ces développements m'ont été tellement +utiles que je ne regrette pas l'investissement effectué. L'idée est de +pouvoir avoir un format d'image en écriture lisible. J'ai pris celui +de gnuplot, ce qui permet en plus de pouvoir "sucrer" la présentation +des données à loisir. Les images sont plus lourdes car le codage est +textuel et un peu plus "verbose" mais se compresse aisément par +n'importe quel algorithme type huffman (tous les archiveurs en possède un). +* mln/io/plot/save_image_sh.hh: Librairie de sauvegarde au format gnuplot shell. +* use/io/plot/save_image_sh: Code simple d'utilisation de la sauvegarde. +* tests/io/plot/save_image_sh: Tests unitaires sur l'export. -* tests/accu/stat/histo1d +VI MLN +----- +a) La sauvegarde des images au format gnuplot shell -* tests/accu/stat/histo2d +* mln/io/plot/save_image_sh.hh: Librairie sauvegarde format gnuplot shell. +to do ... -* use/accu/stat/histo3d_rgb -* tests/accu/stat/histo3d_rgb -* use/accu/stat/histo3d_hsl -* tests/accu/stat/histo3d_hsl -VI SAUVEGARDE FORMAT GNUPLOT SHELL ----------------------------------- VII VISUALISATION HISTOGRAMMES 3D diff --git a/scribo/sandbox/green/mln/io/plot/save_image_sh.hh b/scribo/sandbox/green/mln/io/plot/save_image_sh.hh index 137f78d..7e28f6f 100644 --- a/scribo/sandbox/green/mln/io/plot/save_image_sh.hh +++ b/scribo/sandbox/green/mln/io/plot/save_image_sh.hh @@ -38,6 +38,29 @@ /// The script file call gnuplot in batch mode, the result window persists and /// that's all. /// +/// The following sample is a typical use of the gnuplot shell export library. +/// +/// #include <mln/accu/stat/histo1d.hh> +/// #include <mln/data/compute.hh> +/// #include <mln/core/image/image1d.hh> +/// #include <mln/core/image/image2d.hh> +/// #include <mln/img_path.hh> +/// #include <mln/io/pgm/load.hh> +/// #include <mln/io/plot/save_image_sh.hh> +/// #include <mln/value/int_u8.hh> +/// +/// int main() +/// { +/// typedef mln::value::int_u8 t_int_u8; +/// mln::image2d<t_int_u8> img; +/// mln::image1d<unsigned> histo; +/// +/// mln::io::pgm::load(img, OLENA_IMG_PATH"/lena.pgm"); +/// histo = mln::data::compute(mln::accu::meta::histo::histo1d(), img); +/// mln::io::plot::save_image_sh(histo, "histo.sh"); +/// +/// return 0; +/// } # include <fstream> # include <string> @@ -92,7 +115,6 @@ namespace mln /// filename parameter as unix path. The script shell file must have the /// permission to execute (chmod 755). Launch the script shell to call /// gnuplot in batchmode with fine parameters. - template <typename I> bool save_image_sh(const Image<I>& img, const std::string& filename); @@ -112,6 +134,18 @@ namespace mln bool save_image_sh(const util::array< image1d<I> >& stack, const std::string& filename); + /// \brief Save a stack of stack of image. + /// + /// This is an experimental support. + /// + /// \param[in] stack the stack of image to save. + /// \param[in] filename the name of the unix script shell. + /// \return the status of the opening file operation. + /// + /// The result depends on the permission to save the file with + /// filename parameter as unix path. The script shell file must have the + /// permission to execute (chmod 755). Launch the script shell to call + /// gnuplot in batchmode with fine parameters. template <typename I> bool save_image_sh(const util::array< util::array< image1d<I> > >& stack, const std::string& filename); diff --git a/scribo/sandbox/green/tests/io/plot/save_image_sh/Makefile.am b/scribo/sandbox/green/tests/io/plot/save_image_sh/Makefile.am index d970989..77f9015 100644 --- a/scribo/sandbox/green/tests/io/plot/save_image_sh/Makefile.am +++ b/scribo/sandbox/green/tests/io/plot/save_image_sh/Makefile.am @@ -6,8 +6,13 @@ # TOOLS # ######### -INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green +#LOADLIBES= -lboost_filesystem +INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green +INCLUDES2= -I$(HOME)/git/olena/milena +INCLUDES= $(INCLUDES1) $(INCLUDES2) 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) ECHO= echo RM= rm MKDIR= mkdir -p @@ -20,10 +25,10 @@ BUILD__PATTERN= green/build/tests ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN)) # Case where make is done from build directory. SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD)) -BUILD__DIR= $(PWD) +BUILD__DIR= $(PWD)/ else # Case where make is done from source directory. -SOURCE_DIR= $(PWD) +SOURCE_DIR= $(PWD)/ BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD)) endif @@ -60,7 +65,7 @@ $(BUILD__DIR): # Copy, if nessary, all the files, except the Makefile.am $(BUILD__F_PATH): $(SOURCE_F_PATH) - $(CP) $(addprefix $(SOURCE_DIR)/,$(@F)) $@ + $(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@ # Copy if nessary, the Makefile.am into Makefile $(BUILD__M_PATH): $(SOURCE_M_PATH) diff --git a/scribo/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc b/scribo/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc index c9c817b..c60533e 100644 --- a/scribo/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc +++ b/scribo/sandbox/green/tests/io/plot/save_image_sh/save_image_sh.cc @@ -1,4 +1,36 @@ -/// TEST SAVE_IMAGE_SH.HH +// Copyright (C) 2007,2008,2009,2010 EPITA LRDE +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to produce +// an executable, this file does not by itself cause the resulting +// executable to be covered by the GNU General Public License. This +// exception does not however invalidate any other reasons why the +// executable file might be covered by the GNU General Public License. + +/// \file +/// +/// \brief This source manages unitary testing on gnuplot shell export library. +/// +/// Tests are performed in various image format, such as image1d, image2d<bool>, +/// image2d<int_u8>, image2d<int_u16>, image2d<int_s8>, image2d<int_s16>, +/// image2d<float>, image2d<double>, image2d<rgb8>, image2d<rgb16>, +/// image2d<hsl_f>, image2d<hsl_d>, image2d<hsi_f>, image2d<hsi_d>, image3d. #include <iostream> #include <limits.h> @@ -32,9 +64,13 @@ #include <mln/literal/colors.hh> #include <mln/debug/println.hh> -//------------------------------------------------------------------------------ -// TEST TO SAVE UNSIGNED 8 BITS 1D GRAYSCALE IMAGE -//------------------------------------------------------------------------------ + +/// image1d<int_u8>. +/// \{ +/// \brief Test saving a grayscale image1d. +/// +/// As working on the image1d interface is something extremely rare, we need +/// to use the plot interface to first load some datas and then export them. mln::image1d<mln::value::int_u8> convert_array_to_image1d(const mln::util::array<mln::value::int_u8>& array) @@ -64,7 +100,7 @@ void test_save_image_sh_1d() image1d img; array1d array; - + mln::io::plot::load(array, OLENA_IMG_PATH"/fly.plot"); img = convert_array_to_image1d(array); @@ -73,16 +109,20 @@ void test_save_image_sh_1d() // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img, "fly1d.sh"); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image 1d : ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<bool> -//------------------------------------------------------------------------------ +/// \} +/// image2d<bool>. +/// \{ +/// \brief Test saving an image2d<bool>. +/// +/// Boolean image2d are extremly convenient for storing mask. We have a lots +/// of example in milena. void test_save_image2d_bool() { @@ -93,22 +133,26 @@ void test_save_image2d_bool() image2d_bool img_bool; mln::io::pbm::load(img_bool, OLENA_IMG_PATH"/lena.pbm"); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_bool, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_bool, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<bool>: ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<int_u8> -//------------------------------------------------------------------------------ +/// \} +/// image2d<int_u8>. +/// \{ +/// \brief Test saving a grayscale image2d. +/// +/// Grayscale image2d are very popular in image processing. It's the test we do +/// not fail! void test_save_image2d_int_u8() { @@ -120,27 +164,36 @@ void test_save_image2d_int_u8() image2d_int_u8 img_int_u8; mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm"); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_int_u8, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_int_u8, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<int_u8>: ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<int_u16> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<int_u16>. +/// \{ +/// \brief Test saving an extended grayscale image2d. +/// +/// This kind of image are not so current. But for medical use, we can get now, +/// some dicom in 12 bits and new generation bring us 16 bits. As 16 bits is a +/// strange format for image processing people, there is not a common +/// acceptation for the underline format. Xv or imageMagick doesn't agree for +/// the representation of the file. + struct int_u16_to_int_u8 : mln::Function_v2v< int_u16_to_int_u8 > { typedef mln::value::int_u16 argument; typedef mln::value::int_u8 result; - + result operator()(const argument& c) const { result res(c / 256); @@ -170,22 +223,28 @@ void test_save_image2d_int_u16() // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_int_u16, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<int_u16> : ok" << std::endl; } +/// \} + +/// image2d<int_s8>. +/// \{ +/// \brief Test saving an signed image2d. +/// +/// This kind of image are very artificial. It is given for exhaustivity of +/// testing. In fact, this kind of image traduces some step in a computing +/// chain. -//------------------------------------------------------------------------------ -// Test to save image2d<int_s8> -//------------------------------------------------------------------------------ struct int_u8_to_int_s8 : mln::Function_v2v< int_u8_to_int_s8 > { typedef mln::value::int_u8 argument; typedef mln::value::int_s8 result; - + result operator()(const argument& c) const { argument tmp_int_u8; @@ -197,7 +256,7 @@ struct int_u8_to_int_s8 : mln::Function_v2v< int_u8_to_int_s8 > { res = SCHAR_MAX; } - else if (SCHAR_MAX < c) + else if (static_cast<unsigned>(SCHAR_MAX) < c) { tmp_int_u8 = c - SCHAR_MAX; res = static_cast<mln::value::int_s8>(tmp_int_u8); @@ -226,28 +285,34 @@ void test_save_image2d_int_s8() image2d_int_u8 img_int_u8; mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm"); - img_int_s8 = mln::data::transform(img_int_u8, int_u8_to_int_s8()); - + img_int_s8 = mln::data::transform(img_int_u8, int_u8_to_int_s8()); + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_int_s8, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_int_s8, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<int_s8>: ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<int_s16> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<int_s16>. +/// \{ +/// \brief Test saving an extended image2d. +/// +/// This kind of image are very artificial. It is given for exhaustivity of +/// testing. In fact, this kind of image traduces some step in a computing +/// chain. struct int_u16_to_int_s16 : mln::Function_v2v< int_u16_to_int_s16 > { typedef mln::value::int_u16 argument; typedef mln::value::int_s16 result; - + result operator()(const argument& c) const { argument tmp_int_u16; @@ -258,7 +323,7 @@ struct int_u16_to_int_s16 : mln::Function_v2v< int_u16_to_int_s16 > { res = SHRT_MAX; } - else if (SHRT_MAX < c) + else if (static_cast<unsigned>(SHRT_MAX) < c) { tmp_int_u16 = c - SHRT_MAX; res = static_cast<mln::value::int_s16>(tmp_int_u16); @@ -286,29 +351,33 @@ void test_save_image2d_int_s16() image2d_int_u16 img_int_u16; mln::io::pgm::load(img_int_u16, OLENA_IMG_PATH"/lena_16_gnuplot.pgm"); - img_int_s16 = mln::data::transform(img_int_u16, int_u16_to_int_s16()); + img_int_s16 = mln::data::transform(img_int_u16, int_u16_to_int_s16()); // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_int_s16, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_int_s16, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<int_s16> : ok" << std::endl; } +/// \} -//------------------------------------------------------------------------------ -// Test to save image2d<float> -//------------------------------------------------------------------------------ +/// image2d<float>. +/// \{ +/// \brief Test saving a float image2d. +/// +/// This kind of image is a common way to save some attributes localized on +/// pixels. struct int_u8_to_float : mln::Function_v2v< int_u8_to_float > { typedef mln::value::int_u8 argument; typedef float result; - + result operator()(const argument& c) const { result res = static_cast<float>(c)/3; @@ -330,27 +399,32 @@ void test_save_image2d_float() mln::io::pgm::load(img_int_u8, OLENA_IMG_PATH"/lena.pgm"); img_float = mln::data::transform(img_int_u8, int_u8_to_float()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_float, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_float, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<float> : ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<double> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<double>. +/// \{ +/// \brief Test saving a double image2d. +/// +/// This kind of image is a common way to save some attributes localized on +/// pixels. struct int_u16_to_double : mln::Function_v2v< int_u16_to_double > { typedef mln::value::int_u16 argument; typedef double result; - + result operator()(const argument& c) const { result res = static_cast<float>(c)/256; @@ -372,23 +446,25 @@ void test_save_image2d_double() mln::io::pgm::load(img_int_u16, OLENA_IMG_PATH"/lena_16_gnuplot.pgm"); img_double = mln::data::transform(img_int_u16, int_u16_to_double()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_double, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_double, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<double> : ok" << std::endl; } +/// \} - -//------------------------------------------------------------------------------ -// Test to save image2d<rgb8> -//------------------------------------------------------------------------------ +/// image2d<rgb8>. +/// \{ +/// \brief Test saving a RGB color image2d. +/// +/// This kind of format is extremely popular in image, and in photography. void test_save_image2d_rgb8() { @@ -400,28 +476,33 @@ void test_save_image2d_rgb8() image2d_rgb8 img_rgb8; mln::io::ppm::load(img_rgb8, OLENA_IMG_PATH"/lena.ppm"); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_rgb8, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_rgb8, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<rgb8> : ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<rgb16> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<rgb16>. +/// \{ +/// \brief Test saving a 16 bits RGB color image2d. +/// +/// As this kind of image is less popular, the library enable this export by +/// the will of exhaustivity. struct rgb16_to_int_u16 : mln::Function_v2v< rgb16_to_int_u16 > { typedef mln::value::rgb16 argument; typedef mln::value::int_u16 result; - + result operator()(const argument& c) const { result res((c.red() + c.green() + c.blue())/3); @@ -447,23 +528,28 @@ void test_save_image2d_rgb16() mln::io::ppm::load(img_rgb16, OLENA_IMG_PATH"/lena_16.ppm"); //img_int_u16 = mln::data::transform(img_rgb16, rgb16_to_int_u16()); //mln::io::pgm::save(img_int_u16, "lena_16.pgm"); - + // Save it were it is impossible to do it !! bool ref_false=mln::io::plot::save_image_sh(img_rgb16, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_rgb16, lena); // mln::io::plot::save_image_sh(img_int_u16, lena2); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<rgb16> : ok" << std::endl; } +/// \} -//------------------------------------------------------------------------------ -// Test to save image2d<hsl_f> -//------------------------------------------------------------------------------ +/// image2d<hsl_f>. +/// \{ +/// \brief Test saving a HSL float color image2d. +/// +/// This kind of image allow to show the power of gnuplot. Raw data +/// are hsl, then hsl equations are integrated in the gnuplot shell +/// file. So decoding needs more time. void test_save_image2d_hsl_f() { @@ -484,21 +570,27 @@ void test_save_image2d_hsl_f() //mln::data::fill(img_rgb8, mln::literal::blue); img_hsl_f = mln::data::transform(img_rgb8, rgb_to_hsl()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_hsl_f, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_hsl_f, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<hsl_f> : ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<hsl_d> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<hsl_d>. +/// \{ +/// \brief Test saving a HSL double color image2d. +/// +/// This kind of image allow to show the power of gnuplot. Raw data +/// are hsl, then hsl equations are integrated in the gnuplot shell +/// file. So decoding needs more time. void test_save_image2d_hsl_d() { @@ -519,22 +611,27 @@ void test_save_image2d_hsl_d() //mln::data::fill(img_rgb16, mln::literal::blue); img_hsl_d = mln::data::transform(img_rgb16, rgb_to_hsl()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_hsl_d, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_hsl_d, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<hsl_d> : ok" << std::endl; } +/// \} -//------------------------------------------------------------------------------ -// Test to save image2d<hsi_f> -//------------------------------------------------------------------------------ +/// image2d<hsi_f>. +/// \{ +/// \brief Test saving a HSI float color image2d. +/// +/// This kind of image allow to show the power of gnuplot. Raw data +/// are hsi, then hsi equations are integrated in the gnuplot shell +/// file. So decoding needs more time. void test_save_image2d_hsi_f() { @@ -555,21 +652,27 @@ void test_save_image2d_hsi_f() //mln::data::fill(img_rgb8, mln::literal::blue); img_hsi_f = mln::data::transform(img_rgb8, rgb_to_hsi()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_hsi_f, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_hsi_f, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<hsi_f> : ok" << std::endl; } -//------------------------------------------------------------------------------ -// Test to save image2d<hsi_d> -//------------------------------------------------------------------------------ +/// \} + +/// image2d<hsi_d>. +/// \{ +/// \brief Test saving a HSI double color image2d. +/// +/// This kind of image allow to show the power of gnuplot. Raw data +/// are hsi, then hsi equations are integrated in the gnuplot shell +/// file. So decoding needs more time. void test_save_image2d_hsi_d() { @@ -590,21 +693,28 @@ void test_save_image2d_hsi_d() //mln::data::fill(img_rgb16, mln::literal::blue); img_hsi_d = mln::data::transform(img_rgb16, rgb_to_hsi()); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img_hsi_d, null_lena); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img_hsi_d, lena); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image2d<hsi_d> : ok" << std::endl; } -//------------------------------------------------------------------------------ -// TEST TO SAVE 8 BITS 3D RGB IMAGE -//------------------------------------------------------------------------------ +/// \} + +/// image3d<int_8>. +/// \{ +/// \brief Test saving a grayscale image3d. +/// +/// It seems important to be able to export in 3d, but it's not so popular +/// in the team. We try to simulate this functionnality. +/// +/// \fixme The data visualization is very hard in 3d compact with gnuplot. void test_save_image_sh_3d() { @@ -619,18 +729,20 @@ void test_save_image_sh_3d() array.append(OLENA_IMG_PATH"/fly.pgm"); mln::io::pgms::load(img, array); - + // Save it were it is impossible to do it !! bool ref_false = mln::io::plot::save_image_sh(img, "/dev/null/fly3d.sh"); // Save it where we have the full permissions. bool ref_true = mln::io::plot::save_image_sh(img, "fly3d.sh"); - + mln_assertion(true == ref_true); mln_assertion(false == ref_false); std::cout << "save image 3d : ok" << std::endl; } +/// \} + int main() { @@ -649,7 +761,7 @@ int main() test_save_image2d_rgb8(); test_save_image2d_rgb16(); - + test_save_image2d_hsl_f(); test_save_image2d_hsl_d(); diff --git a/scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am b/scribo/sandbox/green/use/io/plot/save_image_sh/Makefile.am similarity index 100% copy from scribo/sandbox/green/use/accu/stat/histo1d/Makefile.am copy to scribo/sandbox/green/use/io/plot/save_image_sh/Makefile.am diff --git a/scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc b/scribo/sandbox/green/use/io/plot/save_image_sh/save_image_sh.cc similarity index 91% copy from scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc copy to scribo/sandbox/green/use/io/plot/save_image_sh/save_image_sh.cc index af39d94..bd4b84f 100644 --- a/scribo/sandbox/green/use/accu/stat/histo1d/histo1d.cc +++ b/scribo/sandbox/green/use/io/plot/save_image_sh/save_image_sh.cc @@ -25,7 +25,7 @@ /// \file /// -/// \brief Minimal code for building 1d image histogram version. +/// \brief Example of code using the gnuplot shell export library. /// #include <mln/accu/stat/histo1d.hh> @@ -34,6 +34,7 @@ #include <mln/core/image/image2d.hh> #include <mln/img_path.hh> #include <mln/io/pgm/load.hh> +#include <mln/io/plot/save_image_sh.hh> #include <mln/value/int_u8.hh> @@ -46,6 +47,7 @@ int main() mln::io::pgm::load(img, OLENA_IMG_PATH"/lena.pgm"); histo = mln::data::compute(mln::accu::meta::stat::histo1d(), img); + mln::io::plot::save_image_sh(histo, "histo.sh"); return 0; } -- 1.5.6.5