LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
List overview
Download
Olena-patches
June 2010
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9 participants
276 discussions
Start a n
N
ew thread
last-svn-commit-223-g71f26fd Work on Millet value descriptor.
by Yann Jacquelet
* green/exp/annotating/value: New directory. * green/exp/annotating/value/Makefile.am: New Makefile. * green/exp/annotating/value/value.cc: New source file. * green/exp/annotating/value/text-color.txt: New image class. * green/exp/annotating/value/text-img.txt: New image class. * green/exp/annotating/value/text-only.txt: New image class. --- .../annotating/{achromastism => value}/Makefile.am | 0 .../{achromastism => value}/text-color.txt | 0 .../{achromastism => value}/text-img.txt | 0 .../{achromastism => value}/text-only.txt | 0 .../exp/annotating/{hue/hue.cc => value/value.cc} | 143 ++++++++++++-------- 5 files changed, 84 insertions(+), 59 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => value}/Makefile.am (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-only.txt (100%) copy milena/sandbox/green/exp/annotating/{hue/hue.cc => value/value.cc} (68%) diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/value/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/value/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/value/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/value/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/value/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/value/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/value/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/value/text-only.txt diff --git a/milena/sandbox/green/exp/annotating/hue/hue.cc b/milena/sandbox/green/exp/annotating/value/value.cc similarity index 68% copy from milena/sandbox/green/exp/annotating/hue/hue.cc copy to milena/sandbox/green/exp/annotating/value/value.cc index 883e1c6..9209d47 100644 --- a/milena/sandbox/green/exp/annotating/hue/hue.cc +++ b/milena/sandbox/green/exp/annotating/value/value.cc @@ -1,4 +1,4 @@ -// SATURATION TEST CF MILLET 2008 +// VALUE TEST CF MILLET 2008 #include <iostream> #include <sstream> @@ -26,7 +26,7 @@ #include <mln/geom/nsites.hh> -#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> #include <mln/io/ppm/load.hh> #include <mln/io/pgm/save.hh> @@ -97,52 +97,25 @@ mln::value::rgb8 label_hue(const mln::value::int_u8 hue) { mln::value::rgb8 result; - - if (10 > hue) + if (14 > hue) result = mln::literal::red; - else if (32 > hue) + else if (29 > hue) result = mln::literal::orange; - else if (53 > hue) + else if (45 > hue) result = mln::literal::yellow; - else if (74 > hue) - result = mln::literal::green; // chartreuse - else if (96 > hue) + else if (113 > hue) result = mln::literal::green; - else if (116 > hue) - result = mln::literal::green;// turquoise, aigue-marine - else if (138 > hue) - result = mln::literal::green; // cyan - else if (159 > hue) - result = mln::literal::blue; // azur - else if (181 > hue) + else if (149 > hue) + result = mln::literal::cyan; + else if (205 > hue) result = mln::literal::blue; - else if (202 > hue) + else if (235 > hue) result = mln::literal::violet; - else if (223 > hue) + else if (242 > hue) result = mln::literal::pink; - else // if (244 > hue) + else result = mln::literal::red; - -// if (14 > hue) -// result = mln::literal::red; -// else if (29 > hue) -// result = mln::literal::orange; -// else if (45 > hue) -// result = mln::literal::yellow; -// else if (113 > hue) -// result = mln::literal::green; -// else if (149 > hue) -// result = mln::literal::cyan; -// else if (205 > hue) -// result = mln::literal::blue; -// else if (235 > hue) -// result = mln::literal::violet; -// else if (242 > hue) -// result = mln::literal::pink; -// else -// result = mln::literal::red; - return result; } @@ -212,14 +185,69 @@ unsigned mean_histo(const mln::Image<I>& histo_) return mean; } +// calcul de contribution +float r(short p, unsigned histo_p, short x, unsigned histo_x) +{ + float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p)); + + return result; +} + +template <typename I> +float stddev3(const mln::Image<I>& histo_, unsigned peak) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Compute stddev + + float stddev = 0.0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + stddev += r((short)peak, mln::opt::at(histo,peak), p.ind(), histo(p)); + } + + return stddev; +} + +template <typename I> +float stddev2(const mln::Image<I>& histo_, unsigned peak, unsigned limit) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + float stddev_low = 0.0; + float stddev_up = 0.0; + float ret = 0.0; + + // A transformer avec des iterators + + if (250 > peak) + stddev_up = stddev3(histo |mln::box1d(mln::point1d(peak+1), + mln::point1d(peak+limit)), peak); + + if (5 < peak) + stddev_low = stddev3(histo |mln::box1d(mln::point1d(peak-limit), + mln::point1d(peak-1)), peak); + + ret = (250 < peak)? stddev_low : (5 > peak)? stddev_up : + (stddev_low + stddev_up)/2; + + return ret; +} -float hue_test(const std::string input, - const std::string output, - const std::string tmp, - const unsigned threshold) +float value_test(const std::string input, + const std::string output, + const std::string tmp, + const unsigned threshold) { - typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_value_map; mln::image2d<mln::value::rgb8> input_rgb8; mln::image2d<mln::value::int_u8> map; @@ -228,23 +256,20 @@ float hue_test(const std::string input, unsigned cnt2; float prop; unsigned peak; - mln::value::rgb8 color; mln::io::ppm::load(input_rgb8, input.c_str()); - map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + map = mln::data::transform(input_rgb8, t_rgb_to_value_map()); histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); - peak = mean_histo(histo); //peak_histo(histo); - color = label_hue(peak); - cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), - mln::point1d(peak+threshold))); - cnt2 = mln::geom::nsites(input_rgb8); - prop = ((100.0 * cnt1) / cnt2); + peak = peak_histo(histo); // mean_histo(histo); + prop = stddev2(histo, peak, limit); +// cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), +// mln::point1d(peak+threshold))); +// cnt2 = mln::geom::nsites(input_rgb8); +// prop = ((100.0 * cnt1) / cnt2); mln::io::plot::save_image_sh(histo, output.c_str()); mln::io::pgm::save(map, tmp.c_str()); - std::cout << "peak = " << peak << std::endl; - std::cout << "color = " << color << std::endl; return prop; } @@ -271,15 +296,15 @@ int main() for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) { // concatenation de chaine - t_path directory(ANNOTATING_HUE_RET_PATH); + t_path directory(ANNOTATING_VALUE_RET_PATH); t_path leaf = dir_iter->path().leaf(); t_path output = change_extension(directory / leaf, ".sh"); t_path tmp = change_extension(directory / leaf, ".pgm"); - prop = hue_test(dir_iter->path().string(), - output.string(), - tmp.string(), - 20); + prop = value_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 15); std::cout << output << " : " << prop << std::endl; std::cerr << output << " : " << prop << std::endl; -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-38-g0a1cbd3 Work on Millet value descriptor.
by Yann Jacquelet
* green/exp/annotating/value: New directory. * green/exp/annotating/value/Makefile.am: New Makefile. * green/exp/annotating/value/value.cc: New source file. * green/exp/annotating/value/text-color.txt: New image class. * green/exp/annotating/value/text-img.txt: New image class. * green/exp/annotating/value/text-only.txt: New image class. --- .../annotating/{achromastism => value}/Makefile.am | 0 .../{achromastism => value}/text-color.txt | 0 .../{achromastism => value}/text-img.txt | 0 .../{achromastism => value}/text-only.txt | 0 .../exp/annotating/{hue/hue.cc => value/value.cc} | 143 ++++++++++++-------- 5 files changed, 84 insertions(+), 59 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => value}/Makefile.am (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => value}/text-only.txt (100%) copy milena/sandbox/green/exp/annotating/{hue/hue.cc => value/value.cc} (68%) diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/value/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/value/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/value/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/value/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/value/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/value/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/value/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/value/text-only.txt diff --git a/milena/sandbox/green/exp/annotating/hue/hue.cc b/milena/sandbox/green/exp/annotating/value/value.cc similarity index 68% copy from milena/sandbox/green/exp/annotating/hue/hue.cc copy to milena/sandbox/green/exp/annotating/value/value.cc index 883e1c6..9209d47 100644 --- a/milena/sandbox/green/exp/annotating/hue/hue.cc +++ b/milena/sandbox/green/exp/annotating/value/value.cc @@ -1,4 +1,4 @@ -// SATURATION TEST CF MILLET 2008 +// VALUE TEST CF MILLET 2008 #include <iostream> #include <sstream> @@ -26,7 +26,7 @@ #include <mln/geom/nsites.hh> -#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> #include <mln/io/ppm/load.hh> #include <mln/io/pgm/save.hh> @@ -97,52 +97,25 @@ mln::value::rgb8 label_hue(const mln::value::int_u8 hue) { mln::value::rgb8 result; - - if (10 > hue) + if (14 > hue) result = mln::literal::red; - else if (32 > hue) + else if (29 > hue) result = mln::literal::orange; - else if (53 > hue) + else if (45 > hue) result = mln::literal::yellow; - else if (74 > hue) - result = mln::literal::green; // chartreuse - else if (96 > hue) + else if (113 > hue) result = mln::literal::green; - else if (116 > hue) - result = mln::literal::green;// turquoise, aigue-marine - else if (138 > hue) - result = mln::literal::green; // cyan - else if (159 > hue) - result = mln::literal::blue; // azur - else if (181 > hue) + else if (149 > hue) + result = mln::literal::cyan; + else if (205 > hue) result = mln::literal::blue; - else if (202 > hue) + else if (235 > hue) result = mln::literal::violet; - else if (223 > hue) + else if (242 > hue) result = mln::literal::pink; - else // if (244 > hue) + else result = mln::literal::red; - -// if (14 > hue) -// result = mln::literal::red; -// else if (29 > hue) -// result = mln::literal::orange; -// else if (45 > hue) -// result = mln::literal::yellow; -// else if (113 > hue) -// result = mln::literal::green; -// else if (149 > hue) -// result = mln::literal::cyan; -// else if (205 > hue) -// result = mln::literal::blue; -// else if (235 > hue) -// result = mln::literal::violet; -// else if (242 > hue) -// result = mln::literal::pink; -// else -// result = mln::literal::red; - return result; } @@ -212,14 +185,69 @@ unsigned mean_histo(const mln::Image<I>& histo_) return mean; } +// calcul de contribution +float r(short p, unsigned histo_p, short x, unsigned histo_x) +{ + float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p)); + + return result; +} + +template <typename I> +float stddev3(const mln::Image<I>& histo_, unsigned peak) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Compute stddev + + float stddev = 0.0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + stddev += r((short)peak, mln::opt::at(histo,peak), p.ind(), histo(p)); + } + + return stddev; +} + +template <typename I> +float stddev2(const mln::Image<I>& histo_, unsigned peak, unsigned limit) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + float stddev_low = 0.0; + float stddev_up = 0.0; + float ret = 0.0; + + // A transformer avec des iterators + + if (250 > peak) + stddev_up = stddev3(histo |mln::box1d(mln::point1d(peak+1), + mln::point1d(peak+limit)), peak); + + if (5 < peak) + stddev_low = stddev3(histo |mln::box1d(mln::point1d(peak-limit), + mln::point1d(peak-1)), peak); + + ret = (250 < peak)? stddev_low : (5 > peak)? stddev_up : + (stddev_low + stddev_up)/2; + + return ret; +} -float hue_test(const std::string input, - const std::string output, - const std::string tmp, - const unsigned threshold) +float value_test(const std::string input, + const std::string output, + const std::string tmp, + const unsigned threshold) { - typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_value_map; mln::image2d<mln::value::rgb8> input_rgb8; mln::image2d<mln::value::int_u8> map; @@ -228,23 +256,20 @@ float hue_test(const std::string input, unsigned cnt2; float prop; unsigned peak; - mln::value::rgb8 color; mln::io::ppm::load(input_rgb8, input.c_str()); - map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + map = mln::data::transform(input_rgb8, t_rgb_to_value_map()); histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); - peak = mean_histo(histo); //peak_histo(histo); - color = label_hue(peak); - cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), - mln::point1d(peak+threshold))); - cnt2 = mln::geom::nsites(input_rgb8); - prop = ((100.0 * cnt1) / cnt2); + peak = peak_histo(histo); // mean_histo(histo); + prop = stddev2(histo, peak, limit); +// cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), +// mln::point1d(peak+threshold))); +// cnt2 = mln::geom::nsites(input_rgb8); +// prop = ((100.0 * cnt1) / cnt2); mln::io::plot::save_image_sh(histo, output.c_str()); mln::io::pgm::save(map, tmp.c_str()); - std::cout << "peak = " << peak << std::endl; - std::cout << "color = " << color << std::endl; return prop; } @@ -271,15 +296,15 @@ int main() for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) { // concatenation de chaine - t_path directory(ANNOTATING_HUE_RET_PATH); + t_path directory(ANNOTATING_VALUE_RET_PATH); t_path leaf = dir_iter->path().leaf(); t_path output = change_extension(directory / leaf, ".sh"); t_path tmp = change_extension(directory / leaf, ".pgm"); - prop = hue_test(dir_iter->path().string(), - output.string(), - tmp.string(), - 20); + prop = value_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 15); std::cout << output << " : " << prop << std::endl; std::cerr << output << " : " << prop << std::endl; -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-222-gad5614e Work on Millet saturation descriptor.
by Yann Jacquelet
* green/exp/annotating/hue: New directory. * green/exp/annotating/hue/Makefile.am: New Makefile. * green/exp/annotating/hue/hue.cc: New source file. * green/exp/annotating/hue/text-color.txt: New image class. * green/exp/annotating/hue/text-img.txt: New image class. * green/exp/annotating/hue/text-only.txt: New image class. --- milena/sandbox/ChangeLog | 11 + .../annotating/{achromastism => hue}/Makefile.am | 0 milena/sandbox/green/exp/annotating/hue/hue.cc | 291 ++++++++++++++++++++ .../{achromastism => hue}/text-color.txt | 0 .../annotating/{achromastism => hue}/text-img.txt | 0 .../annotating/{achromastism => hue}/text-only.txt | 0 6 files changed, 302 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/hue/hue.cc copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-only.txt (100%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index 074b0fc..2b14f89 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -79,6 +79,17 @@ Work on Millet saturation descriptor. + * green/exp/annotating/hue: New directory. + * green/exp/annotating/hue/Makefile.am: New Makefile. + * green/exp/annotating/hue/hue.cc: New source file. + * green/exp/annotating/hue/text-color.txt: New image class. + * green/exp/annotating/hue/text-img.txt: New image class. + * green/exp/annotating/hue/text-only.txt: New image class. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Work on Millet saturation descriptor. + * green/exp/annotating/saturation: New directory. * green/exp/annotating/saturation/Makefile.am: New Makefile. * green/exp/annotating/saturation/saturation.cc: New source file. diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/hue/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/hue/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/hue/hue.cc b/milena/sandbox/green/exp/annotating/hue/hue.cc new file mode 100644 index 0000000..883e1c6 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/hue/hue.cc @@ -0,0 +1,291 @@ +// SATURATION TEST CF MILLET 2008 + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +mln::value::rgb8 label_val(const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (82 > val) + result = mln::literal::black; + else if (179 > val) + result= mln::literal::medium_gray; + else + result = mln::literal::white; + + return result; +} + + +mln::value::rgb8 label_orange_or_brown(const mln::value::rgb8 color, + const mln::value::int_u8 sat, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::orange == color) + { + unsigned dist_orange = mln::math::abs(sat - 184) + + mln::math::abs(val - 65); + + unsigned dist_brown = mln::math::abs(sat - 255) + + mln::math::abs(val - 125); + + if (dist_orange < dist_brown) + result = mln::literal::orange; + else + result = mln::literal::brown; + } + else + result = color; + + return result; +} + +mln::value::rgb8 label_yellow_or_green(const mln::value::rgb8 color, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::yellow == color) + { + // Is it green or yellow ? + if (80 > val) + result = mln::literal::green; + else + result = mln::literal::yellow; + } + else + return color; + + return result; +} + +mln::value::rgb8 label_hue(const mln::value::int_u8 hue) +{ + mln::value::rgb8 result; + + + if (10 > hue) + result = mln::literal::red; + else if (32 > hue) + result = mln::literal::orange; + else if (53 > hue) + result = mln::literal::yellow; + else if (74 > hue) + result = mln::literal::green; // chartreuse + else if (96 > hue) + result = mln::literal::green; + else if (116 > hue) + result = mln::literal::green;// turquoise, aigue-marine + else if (138 > hue) + result = mln::literal::green; // cyan + else if (159 > hue) + result = mln::literal::blue; // azur + else if (181 > hue) + result = mln::literal::blue; + else if (202 > hue) + result = mln::literal::violet; + else if (223 > hue) + result = mln::literal::pink; + else // if (244 > hue) + result = mln::literal::red; + + +// if (14 > hue) +// result = mln::literal::red; +// else if (29 > hue) +// result = mln::literal::orange; +// else if (45 > hue) +// result = mln::literal::yellow; +// else if (113 > hue) +// result = mln::literal::green; +// else if (149 > hue) +// result = mln::literal::cyan; +// else if (205 > hue) +// result = mln::literal::blue; +// else if (235 > hue) +// result = mln::literal::violet; +// else if (242 > hue) +// result = mln::literal::pink; +// else +// result = mln::literal::red; + + return result; +} + +template <typename I> +unsigned count_histo(const mln::Image<I>& img_) +{ + const I& img = exact(img_); + + mln_precondition(img.is_valid()); + + unsigned result = 0; + + mln_piter(I) p(img.domain()); + + for_all(p) + result += img(p); + + return result; +} + +template <typename I> +unsigned peak_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the peak of the histogram + unsigned v_max = mln::opt::at(histo, 0); + short p_max = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + if (v_max < histo(p)) + { + v_max = histo(p); + p_max = p.ind(); + } + } + + return p_max; +} + +template <typename I> +unsigned mean_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + mean += p.ind()*histo(p); + } + + mean = mean / sum; + + return mean; +} + + +float hue_test(const std::string input, + const std::string output, + const std::string tmp, + const unsigned threshold) + +{ + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + unsigned cnt1; + unsigned cnt2; + float prop; + unsigned peak; + mln::value::rgb8 color; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + peak = mean_histo(histo); //peak_histo(histo); + color = label_hue(peak); + cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), + mln::point1d(peak+threshold))); + cnt2 = mln::geom::nsites(input_rgb8); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + std::cout << "peak = " << peak << std::endl; + std::cout << "color = " << color << std::endl; + + return prop; +} + + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + + t_path full_path[] = {t_path(ICDAR_20P_PPM_IMG_PATH)}; + + for (int i = 0; i < 1; ++i) + { + std::cout << "entering " << full_path[i] << std::endl; + + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + float prop = 0.0; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + // concatenation de chaine + t_path directory(ANNOTATING_HUE_RET_PATH); + t_path leaf = dir_iter->path().leaf(); + t_path output = change_extension(directory / leaf, ".sh"); + t_path tmp = change_extension(directory / leaf, ".pgm"); + + prop = hue_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 20); + + std::cout << output << " : " << prop << std::endl; + std::cerr << output << " : " << prop << std::endl; + } + } + } + + return 0; +} diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/hue/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/hue/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/hue/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/hue/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/hue/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/hue/text-only.txt -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-37-g7bc32d5 Work on Millet saturation descriptor.
by Yann Jacquelet
* green/exp/annotating/hue: New directory. * green/exp/annotating/hue/Makefile.am: New Makefile. * green/exp/annotating/hue/hue.cc: New source file. * green/exp/annotating/hue/text-color.txt: New image class. * green/exp/annotating/hue/text-img.txt: New image class. * green/exp/annotating/hue/text-only.txt: New image class. --- milena/sandbox/ChangeLog | 11 + .../annotating/{achromastism => hue}/Makefile.am | 0 milena/sandbox/green/exp/annotating/hue/hue.cc | 291 ++++++++++++++++++++ .../{achromastism => hue}/text-color.txt | 0 .../annotating/{achromastism => hue}/text-img.txt | 0 .../annotating/{achromastism => hue}/text-only.txt | 0 6 files changed, 302 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/hue/hue.cc copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => hue}/text-only.txt (100%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index eb301e5..2c3ec85 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -2,6 +2,17 @@ Work on Millet saturation descriptor. + * green/exp/annotating/hue: New directory. + * green/exp/annotating/hue/Makefile.am: New Makefile. + * green/exp/annotating/hue/hue.cc: New source file. + * green/exp/annotating/hue/text-color.txt: New image class. + * green/exp/annotating/hue/text-img.txt: New image class. + * green/exp/annotating/hue/text-only.txt: New image class. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Work on Millet saturation descriptor. + * green/exp/annotating/saturation: New directory. * green/exp/annotating/saturation/Makefile.am: New Makefile. * green/exp/annotating/saturation/saturation.cc: New source file. diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/hue/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/hue/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/hue/hue.cc b/milena/sandbox/green/exp/annotating/hue/hue.cc new file mode 100644 index 0000000..883e1c6 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/hue/hue.cc @@ -0,0 +1,291 @@ +// SATURATION TEST CF MILLET 2008 + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +mln::value::rgb8 label_val(const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (82 > val) + result = mln::literal::black; + else if (179 > val) + result= mln::literal::medium_gray; + else + result = mln::literal::white; + + return result; +} + + +mln::value::rgb8 label_orange_or_brown(const mln::value::rgb8 color, + const mln::value::int_u8 sat, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::orange == color) + { + unsigned dist_orange = mln::math::abs(sat - 184) + + mln::math::abs(val - 65); + + unsigned dist_brown = mln::math::abs(sat - 255) + + mln::math::abs(val - 125); + + if (dist_orange < dist_brown) + result = mln::literal::orange; + else + result = mln::literal::brown; + } + else + result = color; + + return result; +} + +mln::value::rgb8 label_yellow_or_green(const mln::value::rgb8 color, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::yellow == color) + { + // Is it green or yellow ? + if (80 > val) + result = mln::literal::green; + else + result = mln::literal::yellow; + } + else + return color; + + return result; +} + +mln::value::rgb8 label_hue(const mln::value::int_u8 hue) +{ + mln::value::rgb8 result; + + + if (10 > hue) + result = mln::literal::red; + else if (32 > hue) + result = mln::literal::orange; + else if (53 > hue) + result = mln::literal::yellow; + else if (74 > hue) + result = mln::literal::green; // chartreuse + else if (96 > hue) + result = mln::literal::green; + else if (116 > hue) + result = mln::literal::green;// turquoise, aigue-marine + else if (138 > hue) + result = mln::literal::green; // cyan + else if (159 > hue) + result = mln::literal::blue; // azur + else if (181 > hue) + result = mln::literal::blue; + else if (202 > hue) + result = mln::literal::violet; + else if (223 > hue) + result = mln::literal::pink; + else // if (244 > hue) + result = mln::literal::red; + + +// if (14 > hue) +// result = mln::literal::red; +// else if (29 > hue) +// result = mln::literal::orange; +// else if (45 > hue) +// result = mln::literal::yellow; +// else if (113 > hue) +// result = mln::literal::green; +// else if (149 > hue) +// result = mln::literal::cyan; +// else if (205 > hue) +// result = mln::literal::blue; +// else if (235 > hue) +// result = mln::literal::violet; +// else if (242 > hue) +// result = mln::literal::pink; +// else +// result = mln::literal::red; + + return result; +} + +template <typename I> +unsigned count_histo(const mln::Image<I>& img_) +{ + const I& img = exact(img_); + + mln_precondition(img.is_valid()); + + unsigned result = 0; + + mln_piter(I) p(img.domain()); + + for_all(p) + result += img(p); + + return result; +} + +template <typename I> +unsigned peak_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the peak of the histogram + unsigned v_max = mln::opt::at(histo, 0); + short p_max = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + if (v_max < histo(p)) + { + v_max = histo(p); + p_max = p.ind(); + } + } + + return p_max; +} + +template <typename I> +unsigned mean_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + mean += p.ind()*histo(p); + } + + mean = mean / sum; + + return mean; +} + + +float hue_test(const std::string input, + const std::string output, + const std::string tmp, + const unsigned threshold) + +{ + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + unsigned cnt1; + unsigned cnt2; + float prop; + unsigned peak; + mln::value::rgb8 color; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + peak = mean_histo(histo); //peak_histo(histo); + color = label_hue(peak); + cnt1 = count_histo(histo | mln::box1d(mln::point1d(peak-threshold), + mln::point1d(peak+threshold))); + cnt2 = mln::geom::nsites(input_rgb8); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + std::cout << "peak = " << peak << std::endl; + std::cout << "color = " << color << std::endl; + + return prop; +} + + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + + t_path full_path[] = {t_path(ICDAR_20P_PPM_IMG_PATH)}; + + for (int i = 0; i < 1; ++i) + { + std::cout << "entering " << full_path[i] << std::endl; + + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + float prop = 0.0; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + // concatenation de chaine + t_path directory(ANNOTATING_HUE_RET_PATH); + t_path leaf = dir_iter->path().leaf(); + t_path output = change_extension(directory / leaf, ".sh"); + t_path tmp = change_extension(directory / leaf, ".pgm"); + + prop = hue_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 20); + + std::cout << output << " : " << prop << std::endl; + std::cerr << output << " : " << prop << std::endl; + } + } + } + + return 0; +} diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/hue/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/hue/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/hue/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/hue/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/hue/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/hue/text-only.txt -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-221-g125df33 Work on Millet saturation descriptor.
by Yann Jacquelet
* green/exp/annotating/saturation: New directory. * green/exp/annotating/saturation/Makefile.am: New Makefile. * green/exp/annotating/saturation/saturation.cc: New source file. --- milena/sandbox/ChangeLog | 14 ++++++++- .../{achromastism => saturation}/Makefile.am | 0 .../achromastism.cc => saturation/saturation.cc} | 30 ++++++++++++-------- .../{achromastism => saturation}/text-color.txt | 0 .../{achromastism => saturation}/text-img.txt | 0 .../{achromastism => saturation}/text-only.txt | 0 6 files changed, 31 insertions(+), 13 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/Makefile.am (100%) copy milena/sandbox/green/exp/annotating/{achromastism/achromastism.cc => saturation/saturation.cc} (75%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-only.txt (100%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index 6a47420..074b0fc 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -77,10 +77,22 @@ 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet saturation descriptor. + + * green/exp/annotating/saturation: New directory. + * green/exp/annotating/saturation/Makefile.am: New Makefile. + * green/exp/annotating/saturation/saturation.cc: New source file. + * green/exp/annotating/saturation/text-color.txt: New image class. + * green/exp/annotating/saturation/text-img.txt: New image class. + * green/exp/annotating/saturation/text-only.txt: New image class. + + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet hsv descriptors. * green/exp/annotating/hsv: New directory. - * green/Exp/annotating/hsv/hsv.cc: New source file. + * green/exp/annotating/hsv/hsv.cc: New source file. 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/saturation/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/saturation/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/achromastism/achromastism.cc b/milena/sandbox/green/exp/annotating/saturation/saturation.cc similarity index 75% copy from milena/sandbox/green/exp/annotating/achromastism/achromastism.cc copy to milena/sandbox/green/exp/annotating/saturation/saturation.cc index fdb8e6d..3eb27a4 100644 --- a/milena/sandbox/green/exp/annotating/achromastism/achromastism.cc +++ b/milena/sandbox/green/exp/annotating/saturation/saturation.cc @@ -1,4 +1,4 @@ -// ACHROMATISM TEST CF MILLET 2008 +// SATURATION TEST CF MILLET 2008 #include <iostream> #include <sstream> @@ -21,9 +21,10 @@ #include <mln/geom/nsites.hh> -#include <mln/fun/v2v/rgb_to_achromatism_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> #include <mln/io/ppm/load.hh> +//#include <mln/io/pgm/save.hh> #include <mln/io/plot/save_image_sh.hh> #include <mln/value/rgb8.hh> @@ -45,12 +46,14 @@ unsigned count_histo(const mln::Image<I>& img_) return result; } -float achromatism_test(const std::string input, - const std::string output, - const unsigned threshold) + +float saturation_test(const std::string input, + const std::string output, +// const std::string tmp, + const unsigned threshold) { - typedef mln::fun::v2v::rgb_to_achromatism_map<8> t_rgb_to_achromatism_map; + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_saturation_map; mln::image2d<mln::value::rgb8> input_rgb8; mln::image2d<mln::value::int_u8> map; @@ -61,7 +64,7 @@ float achromatism_test(const std::string input, mln::io::ppm::load(input_rgb8, input.c_str()); - map = mln::data::transform(input_rgb8, t_rgb_to_achromatism_map()); + map = mln::data::transform(input_rgb8, t_rgb_to_saturation_map()); histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); cnt1 = count_histo(histo | mln::box1d(mln::point1d(0), mln::point1d(threshold))); @@ -69,6 +72,7 @@ float achromatism_test(const std::string input, prop = ((100.0 * cnt1) / cnt2); mln::io::plot::save_image_sh(histo, output.c_str()); +// mln::io::pgm::save(map, tmp.c_str()); return prop; } @@ -95,13 +99,15 @@ int main() for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) { // concatenation de chaine - t_path directory(ANNOTATING_ACHROMATISM_RET_PATH); - t_path leaf = dir_iter->path().leaf(); + t_path directory(ANNOTATING_SATURATION_RET_PATH); + t_path leaf = dir_iter->path().leaf(); t_path output = change_extension(directory / leaf, ".sh"); + t_path tmp = change_extension(directory / leaf, ".pgm"); - prop = achromatism_test(dir_iter->path().string(), - output.string(), - 11); + prop = saturation_test(dir_iter->path().string(), + output.string(), +// tmp.string(), + 25); std::cout << output << " : " << prop << std::endl; std::cerr << output << " : " << prop << std::endl; diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/saturation/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/saturation/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/saturation/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/saturation/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/saturation/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/saturation/text-only.txt -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-36-ga502be9 Work on Millet saturation descriptor.
by Yann Jacquelet
* green/exp/annotating/saturation: New directory. * green/exp/annotating/saturation/Makefile.am: New Makefile. * green/exp/annotating/saturation/saturation.cc: New source file. --- milena/sandbox/ChangeLog | 14 ++++++++- .../{achromastism => saturation}/Makefile.am | 0 .../achromastism.cc => saturation/saturation.cc} | 30 ++++++++++++-------- .../{achromastism => saturation}/text-color.txt | 0 .../{achromastism => saturation}/text-img.txt | 0 .../{achromastism => saturation}/text-only.txt | 0 6 files changed, 31 insertions(+), 13 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/Makefile.am (100%) copy milena/sandbox/green/exp/annotating/{achromastism/achromastism.cc => saturation/saturation.cc} (75%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-color.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-img.txt (100%) copy milena/sandbox/green/exp/annotating/{achromastism => saturation}/text-only.txt (100%) diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index 15be8a1..eb301e5 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,9 +1,21 @@ 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet saturation descriptor. + + * green/exp/annotating/saturation: New directory. + * green/exp/annotating/saturation/Makefile.am: New Makefile. + * green/exp/annotating/saturation/saturation.cc: New source file. + * green/exp/annotating/saturation/text-color.txt: New image class. + * green/exp/annotating/saturation/text-img.txt: New image class. + * green/exp/annotating/saturation/text-only.txt: New image class. + + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet hsv descriptors. * green/exp/annotating/hsv: New directory. - * green/Exp/annotating/hsv/hsv.cc: New source file. + * green/exp/annotating/hsv/hsv.cc: New source file. 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/saturation/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/saturation/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/achromastism/achromastism.cc b/milena/sandbox/green/exp/annotating/saturation/saturation.cc similarity index 75% copy from milena/sandbox/green/exp/annotating/achromastism/achromastism.cc copy to milena/sandbox/green/exp/annotating/saturation/saturation.cc index fdb8e6d..3eb27a4 100644 --- a/milena/sandbox/green/exp/annotating/achromastism/achromastism.cc +++ b/milena/sandbox/green/exp/annotating/saturation/saturation.cc @@ -1,4 +1,4 @@ -// ACHROMATISM TEST CF MILLET 2008 +// SATURATION TEST CF MILLET 2008 #include <iostream> #include <sstream> @@ -21,9 +21,10 @@ #include <mln/geom/nsites.hh> -#include <mln/fun/v2v/rgb_to_achromatism_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> #include <mln/io/ppm/load.hh> +//#include <mln/io/pgm/save.hh> #include <mln/io/plot/save_image_sh.hh> #include <mln/value/rgb8.hh> @@ -45,12 +46,14 @@ unsigned count_histo(const mln::Image<I>& img_) return result; } -float achromatism_test(const std::string input, - const std::string output, - const unsigned threshold) + +float saturation_test(const std::string input, + const std::string output, +// const std::string tmp, + const unsigned threshold) { - typedef mln::fun::v2v::rgb_to_achromatism_map<8> t_rgb_to_achromatism_map; + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_saturation_map; mln::image2d<mln::value::rgb8> input_rgb8; mln::image2d<mln::value::int_u8> map; @@ -61,7 +64,7 @@ float achromatism_test(const std::string input, mln::io::ppm::load(input_rgb8, input.c_str()); - map = mln::data::transform(input_rgb8, t_rgb_to_achromatism_map()); + map = mln::data::transform(input_rgb8, t_rgb_to_saturation_map()); histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); cnt1 = count_histo(histo | mln::box1d(mln::point1d(0), mln::point1d(threshold))); @@ -69,6 +72,7 @@ float achromatism_test(const std::string input, prop = ((100.0 * cnt1) / cnt2); mln::io::plot::save_image_sh(histo, output.c_str()); +// mln::io::pgm::save(map, tmp.c_str()); return prop; } @@ -95,13 +99,15 @@ int main() for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) { // concatenation de chaine - t_path directory(ANNOTATING_ACHROMATISM_RET_PATH); - t_path leaf = dir_iter->path().leaf(); + t_path directory(ANNOTATING_SATURATION_RET_PATH); + t_path leaf = dir_iter->path().leaf(); t_path output = change_extension(directory / leaf, ".sh"); + t_path tmp = change_extension(directory / leaf, ".pgm"); - prop = achromatism_test(dir_iter->path().string(), - output.string(), - 11); + prop = saturation_test(dir_iter->path().string(), + output.string(), +// tmp.string(), + 25); std::cout << output << " : " << prop << std::endl; std::cerr << output << " : " << prop << std::endl; diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-color.txt b/milena/sandbox/green/exp/annotating/saturation/text-color.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-color.txt copy to milena/sandbox/green/exp/annotating/saturation/text-color.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-img.txt b/milena/sandbox/green/exp/annotating/saturation/text-img.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-img.txt copy to milena/sandbox/green/exp/annotating/saturation/text-img.txt diff --git a/milena/sandbox/green/exp/annotating/achromastism/text-only.txt b/milena/sandbox/green/exp/annotating/saturation/text-only.txt similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/text-only.txt copy to milena/sandbox/green/exp/annotating/saturation/text-only.txt -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-220-gb9a5b97 Work on Millet hsv descriptors.
by Yann Jacquelet
* green/exp/annotating/hsv: New directory. * green/Exp/annotating/hsv/hsv.cc: New source file. --- milena/sandbox/ChangeLog | 24 + .../annotating/{achromastism => hsv}/Makefile.am | 0 milena/sandbox/green/exp/annotating/hsv/hsv.cc | 652 ++++++++++++++++++++ 3 files changed, 676 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => hsv}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/hsv/hsv.cc diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index ec9743c..6a47420 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -77,6 +77,29 @@ 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet hsv descriptors. + + * green/exp/annotating/hsv: New directory. + * green/Exp/annotating/hsv/hsv.cc: New source file. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Work on histograms view as density. + + * green/exp/annotating/histo: New directory. + * green/exp/annotating/histo/histo.cc: New Makefile.am. + * green/exp/annotating/histo/histo.cc: New source. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Test error quantification as a color descriptor in our database. + + * green/exp/annotating/error: New directory. + * green/exp/annotating/error/Makefile.am: New Makefile. + * green/exp/annotating/error/error.cc: New source. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Benchmark few descriptors. * green/exp/annotating/bench: New directory. @@ -87,6 +110,7 @@ Test on image database the achromatism descriptor. + * green/exp/annotating/achromatism: New directory. * green/exp/annotating/achromatism/Makefile.am: New Makefile. * green/exp/annotating/achromatism/achromatism.am: New source. * green/exp/annotating/achromatism/text-color.txt: New image class. diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/hsv/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/hsv/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/hsv/hsv.cc b/milena/sandbox/green/exp/annotating/hsv/hsv.cc new file mode 100644 index 0000000..2aa9113 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/hsv/hsv.cc @@ -0,0 +1,652 @@ +// HSV TEST CF MILLET 2008 + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/arith/minus.hh> +#include <mln/arith/div.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/convert.hh> +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/zero.hh> +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> +#include <mln/math/sqr.hh> +#include <mln/math/sqrt.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +//============================================================================// +// HISTOGRAM +//============================================================================// + +template <typename I> +mln_value(I) count_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) result = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + result += histo(p); + + return result; +} + +template <typename I> +mln_value(I) sum_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) sum = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + sum += histo(p); + + return sum; +} + +template <typename I> +mln_value(I) count_null_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) count = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + if (0 == histo(p)) + count++; + + return count; +} + +template <typename I> +mln_coord(mln_site_(I)) peak_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the peak of the histogram + mln_value(I) v_max = mln::opt::at(histo, mln::literal::zero); + mln_coord(mln_site_(I)) p_max = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + { + if (v_max < histo(p)) + { + v_max = histo(p); + p_max = p.ind(); + } + } + + return p_max; +} + +template <typename I> +mln_value(I) max_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the value of the peak from the histogram + mln_value(I) max = mln::opt::at(histo, mln::literal::zero); + mln_piter(I) p(histo.domain()); + + for_all(p) + { + max = mln::math::max(histo(p),max); + } + + return max; +} + +template <typename I> +float mean_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + mean += p.ind()*histo(p); + } + + mean = mean / sum; + + return mean; +} + +template <typename I> +float cmp_equi_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + var += mln::math::sqr(histo(p) - (1/256.0)); + } + + var = var / sum; + + return var; +} + +template <typename I> +float var_histo(const mln::Image<I>& histo_, float mean) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + var += mln::math::sqr(p.ind() - mean) * histo(p); + } + + var = var / sum; + + return var; +} + +template <typename I> +float mean_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum++; + mean += histo(p); + } + + mean = mean / sum; + + return mean; +} + +template <typename I> +float stddev_frequency_histo(const mln::Image<I>& histo_, float mean) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the var of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum++; + var += mln::math::sqr(histo(p)-mean); + } + + var = mln::math::sqrt(var / sum); + + return var; +} + + +//============================================================================// +// HUE TEST +//============================================================================// + +mln::value::rgb8 label_val(const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (82 > val) + result = mln::literal::black; + else if (179 > val) + result= mln::literal::medium_gray; + else + result = mln::literal::white; + + return result; +} + + +mln::value::rgb8 label_orange_or_brown(const mln::value::rgb8 color, + const mln::value::int_u8 sat, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::orange == color) + { + unsigned dist_orange = mln::math::abs(sat - 184) + + mln::math::abs(val - 65); + + unsigned dist_brown = mln::math::abs(sat - 255) + + mln::math::abs(val - 125); + + if (dist_orange < dist_brown) + result = mln::literal::orange; + else + result = mln::literal::brown; + } + else + result = color; + + return result; +} + +mln::value::rgb8 label_yellow_or_green(const mln::value::rgb8 color, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::yellow == color) + { + // Is it green or yellow ? + if (80 > val) + result = mln::literal::green; + else + result = mln::literal::yellow; + } + else + return color; + + return result; +} + +mln::value::rgb8 label_hue(const mln::value::int_u8 hue) +{ + mln::value::rgb8 result; + + + if (10 > hue) + result = mln::literal::red; + else if (32 > hue) + result = mln::literal::orange; + else if (53 > hue) + result = mln::literal::yellow; + else if (74 > hue) + result = mln::literal::green; // chartreuse + else if (96 > hue) + result = mln::literal::green; + else if (116 > hue) + result = mln::literal::green;// turquoise, aigue-marine + else if (138 > hue) + result = mln::literal::green; // cyan + else if (159 > hue) + result = mln::literal::blue; // azur + else if (181 > hue) + result = mln::literal::blue; + else if (202 > hue) + result = mln::literal::violet; + else if (223 > hue) + result = mln::literal::pink; + else // if (244 > hue) + result = mln::literal::red; + + return result; +} + +float hue_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float prop; + short peak; + mln::value::rgb8 color; + float sum; + mln::point1d inf; + mln::point1d sup; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + peak = mean_histo(histo); //peak_histo(histo); + color = label_hue(peak); + inf = mln::point1d(mln::math::max(0, peak-threshold)); + sup = mln::point1d(mln::math::min(255, peak+threshold)); + cnt1 = count_histo(histo_float|mln::box1d(inf,sup)); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); +// std::cout << "peak = " << peak << std::endl; +// std::cout << "color = " << color << std::endl; + + return prop; +} + +//============================================================================// +// SATURATION TEST +//============================================================================// + +float saturation_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_saturation_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float sum; + float prop; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_saturation_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + cnt1 = count_histo(histo_float | mln::box1d(mln::point1d(0), + mln::point1d(threshold))); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + + return prop; +} + +//============================================================================// +// VALUE TEST +//============================================================================// + +// calcul de contribution +float r(short p, unsigned histo_p, short x, unsigned histo_x) +{ + float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p)); + + return result; +} + +template <typename I> +float stddev3(const mln::Image<I>& histo_, unsigned peak) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Compute stddev + + float stddev = 0.0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + stddev += r((short)peak, mln::opt::at(histo,peak), p.ind(), histo(p)); + } + + return stddev; +} + +template <typename I> +float stddev2(const mln::Image<I>& histo_, unsigned peak, unsigned limit) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + float stddev_low = 0.0; + float stddev_up = 0.0; + float ret = 0.0; + + // A transformer avec des iterators + + if (250 > peak) + stddev_up = stddev3(histo |mln::box1d(mln::point1d(peak+1), + mln::point1d(peak+limit)), peak); + + if (5 < peak) + stddev_low = stddev3(histo |mln::box1d(mln::point1d(peak-limit), + mln::point1d(peak-1)), peak); + + ret = (250 < peak)? stddev_low : (5 > peak)? stddev_up : + (stddev_low + stddev_up)/2; + + return ret; +} + +// DOC: +// la discrimination entre la base AFP et la base ICDAR peut se faire en +// étudiant la forme des densités des niveaux de gris. +// Les images naturelles semblent avoir un spectre recouvrant +// en général les 256 niveaux de gris alors que les images de documents ont +// une présence importante du fond. Dans le cadre d'une densité, ce qui est +// alloué sur le fond ne peut se retrouver ailleurs. Une comparaison avec la +// densité équiprobable nous renseigne donc sur la nature des images. +// Il semble néanmoins qu'un certain nombre d'images défient ce dispositif. +// Par exemple des gros plans sur des zones mono-teintée (ski, voile,site web). + + + + +float value_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_value_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float prop; + float sum; + float prop4; + short peak; + mln::point1d inf; + mln::point1d sup; + + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_value_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + prop4 = cmp_equi_frequency_histo(histo_float); + peak = peak_histo(histo); // mean_histo(histo); + //prop = stddev2(histo, peak, threshold); + inf = mln::point1d(mln::math::max(0, peak-threshold)); + sup = mln::point1d(mln::math::min(255, peak+threshold)); + cnt1 = count_histo(histo_float|mln::box1d(inf,sup)); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + std::cerr << "peak = " << peak << std::endl; + std::cerr << "inf = " << inf << std::endl; + std::cerr << "sup = " << sup << std::endl; + std::cerr << "cnt1 = " << cnt1 << std::endl; + std::cerr << "cnt2 = " << cnt2 << std::endl; + std::cerr << "prop = " << prop << std::endl; + std::cerr << "prop4= " << prop4 << std::endl; + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + + return prop; +} + +//============================================================================// +// MAIN +//============================================================================// + + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + +// t_path full_path[] = {t_path(ICDAR_20P_TEXT_ONLY_IMG_PATH), +// t_path(ICDAR_20P_TEXT_COLOR_IMG_PATH), +// t_path(ICDAR_20P_TEXT_PHOTO_IMG_PATH)}; + + t_path full_path[] = {t_path(AFP_PPM_IMG_PATH)}; + + std::cout << "#!/usr/bin/gnuplot" << std::endl; + std::cout << "set terminal x11 persist 1" << std::endl; + std::cout << "#HUE - SATURATION - VALUE" << std::endl; + std::cout << "plot '-' using 1:2 with point notitle,\\" << std::endl; + std::cout << " '-' using 1:2 with point notitle,\\" << std::endl; + std::cout << " '-' using 1:2 with point notitle" << std::endl; + + for (int i = 0; i < 1; ++i) + { + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + float prop = 0.0; + t_path directory; + t_path leaf; + t_path output; + t_path tmp; + + std::cerr << "entering " << full_path[i] << std::endl; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + std::cerr << dir_iter->path() << std::endl; + // concatenation de chaine +// directory = (ANNOTATING_ICDAR_HUE_RET_PATH); + directory = (ANNOTATING_AFP_HUE_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = hue_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 20); + + std::cout << prop << " "; + +// directory = (ANNOTATING_ICDAR_SAT_RET_PATH); + directory = (ANNOTATING_AFP_SAT_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = saturation_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 25); + + std::cout << prop << " "; + +// directory = (ANNOTATING_ICDAR_VAL_RET_PATH); + directory = (ANNOTATING_AFP_VAL_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = value_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 15); + + std::cout << prop << " "; + std::cout << "# " << dir_iter->path().leaf() << std::endl; + } + std::cout << "e" << std::endl; + } + } + + return 0; +} -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-35-gddb6f8c Work on Millet hsv descriptors.
by Yann Jacquelet
* green/exp/annotating/hsv: New directory. * green/Exp/annotating/hsv/hsv.cc: New source file. --- milena/sandbox/ChangeLog | 24 + .../annotating/{achromastism => hsv}/Makefile.am | 0 milena/sandbox/green/exp/annotating/hsv/hsv.cc | 652 ++++++++++++++++++++ 3 files changed, 676 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => hsv}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/hsv/hsv.cc diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog index cc4634d..15be8a1 100644 --- a/milena/sandbox/ChangeLog +++ b/milena/sandbox/ChangeLog @@ -1,5 +1,28 @@ 2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Work on Millet hsv descriptors. + + * green/exp/annotating/hsv: New directory. + * green/Exp/annotating/hsv/hsv.cc: New source file. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Work on histograms view as density. + + * green/exp/annotating/histo: New directory. + * green/exp/annotating/histo/histo.cc: New Makefile.am. + * green/exp/annotating/histo/histo.cc: New source. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + + Test error quantification as a color descriptor in our database. + + * green/exp/annotating/error: New directory. + * green/exp/annotating/error/Makefile.am: New Makefile. + * green/exp/annotating/error/error.cc: New source. + +2010-06-21 Yann Jacquelet <jacquelet(a)lrde.epita.fr> + Benchmark few descriptors. * green/exp/annotating/bench: New directory. @@ -10,6 +33,7 @@ Test on image database the achromatism descriptor. + * green/exp/annotating/achromatism: New directory. * green/exp/annotating/achromatism/Makefile.am: New Makefile. * green/exp/annotating/achromatism/achromatism.am: New source. * green/exp/annotating/achromatism/text-color.txt: New image class. diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/hsv/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/hsv/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/hsv/hsv.cc b/milena/sandbox/green/exp/annotating/hsv/hsv.cc new file mode 100644 index 0000000..2aa9113 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/hsv/hsv.cc @@ -0,0 +1,652 @@ +// HSV TEST CF MILLET 2008 + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/arith/minus.hh> +#include <mln/arith/div.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/convert.hh> +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/zero.hh> +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> +#include <mln/math/sqr.hh> +#include <mln/math/sqrt.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +//============================================================================// +// HISTOGRAM +//============================================================================// + +template <typename I> +mln_value(I) count_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) result = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + result += histo(p); + + return result; +} + +template <typename I> +mln_value(I) sum_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) sum = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + sum += histo(p); + + return sum; +} + +template <typename I> +mln_value(I) count_null_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) count = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + if (0 == histo(p)) + count++; + + return count; +} + +template <typename I> +mln_coord(mln_site_(I)) peak_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the peak of the histogram + mln_value(I) v_max = mln::opt::at(histo, mln::literal::zero); + mln_coord(mln_site_(I)) p_max = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + { + if (v_max < histo(p)) + { + v_max = histo(p); + p_max = p.ind(); + } + } + + return p_max; +} + +template <typename I> +mln_value(I) max_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the value of the peak from the histogram + mln_value(I) max = mln::opt::at(histo, mln::literal::zero); + mln_piter(I) p(histo.domain()); + + for_all(p) + { + max = mln::math::max(histo(p),max); + } + + return max; +} + +template <typename I> +float mean_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + mean += p.ind()*histo(p); + } + + mean = mean / sum; + + return mean; +} + +template <typename I> +float cmp_equi_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + var += mln::math::sqr(histo(p) - (1/256.0)); + } + + var = var / sum; + + return var; +} + +template <typename I> +float var_histo(const mln::Image<I>& histo_, float mean) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum += histo(p); + var += mln::math::sqr(p.ind() - mean) * histo(p); + } + + var = var / sum; + + return var; +} + +template <typename I> +float mean_frequency_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the mean of the histogram + float sum = 0; + float mean = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum++; + mean += histo(p); + } + + mean = mean / sum; + + return mean; +} + +template <typename I> +float stddev_frequency_histo(const mln::Image<I>& histo_, float mean) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Find the var of the histogram + float sum = 0; + float var = 0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + sum++; + var += mln::math::sqr(histo(p)-mean); + } + + var = mln::math::sqrt(var / sum); + + return var; +} + + +//============================================================================// +// HUE TEST +//============================================================================// + +mln::value::rgb8 label_val(const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (82 > val) + result = mln::literal::black; + else if (179 > val) + result= mln::literal::medium_gray; + else + result = mln::literal::white; + + return result; +} + + +mln::value::rgb8 label_orange_or_brown(const mln::value::rgb8 color, + const mln::value::int_u8 sat, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::orange == color) + { + unsigned dist_orange = mln::math::abs(sat - 184) + + mln::math::abs(val - 65); + + unsigned dist_brown = mln::math::abs(sat - 255) + + mln::math::abs(val - 125); + + if (dist_orange < dist_brown) + result = mln::literal::orange; + else + result = mln::literal::brown; + } + else + result = color; + + return result; +} + +mln::value::rgb8 label_yellow_or_green(const mln::value::rgb8 color, + const mln::value::int_u8 val) +{ + mln::value::rgb8 result; + + if (mln::literal::yellow == color) + { + // Is it green or yellow ? + if (80 > val) + result = mln::literal::green; + else + result = mln::literal::yellow; + } + else + return color; + + return result; +} + +mln::value::rgb8 label_hue(const mln::value::int_u8 hue) +{ + mln::value::rgb8 result; + + + if (10 > hue) + result = mln::literal::red; + else if (32 > hue) + result = mln::literal::orange; + else if (53 > hue) + result = mln::literal::yellow; + else if (74 > hue) + result = mln::literal::green; // chartreuse + else if (96 > hue) + result = mln::literal::green; + else if (116 > hue) + result = mln::literal::green;// turquoise, aigue-marine + else if (138 > hue) + result = mln::literal::green; // cyan + else if (159 > hue) + result = mln::literal::blue; // azur + else if (181 > hue) + result = mln::literal::blue; + else if (202 > hue) + result = mln::literal::violet; + else if (223 > hue) + result = mln::literal::pink; + else // if (244 > hue) + result = mln::literal::red; + + return result; +} + +float hue_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float prop; + short peak; + mln::value::rgb8 color; + float sum; + mln::point1d inf; + mln::point1d sup; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + peak = mean_histo(histo); //peak_histo(histo); + color = label_hue(peak); + inf = mln::point1d(mln::math::max(0, peak-threshold)); + sup = mln::point1d(mln::math::min(255, peak+threshold)); + cnt1 = count_histo(histo_float|mln::box1d(inf,sup)); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); +// std::cout << "peak = " << peak << std::endl; +// std::cout << "color = " << color << std::endl; + + return prop; +} + +//============================================================================// +// SATURATION TEST +//============================================================================// + +float saturation_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_saturation_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float sum; + float prop; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_saturation_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + cnt1 = count_histo(histo_float | mln::box1d(mln::point1d(0), + mln::point1d(threshold))); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + + return prop; +} + +//============================================================================// +// VALUE TEST +//============================================================================// + +// calcul de contribution +float r(short p, unsigned histo_p, short x, unsigned histo_x) +{ + float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p)); + + return result; +} + +template <typename I> +float stddev3(const mln::Image<I>& histo_, unsigned peak) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + // Compute stddev + + float stddev = 0.0; + + mln_piter(I) p(histo.domain()); + + for_all(p) + { + stddev += r((short)peak, mln::opt::at(histo,peak), p.ind(), histo(p)); + } + + return stddev; +} + +template <typename I> +float stddev2(const mln::Image<I>& histo_, unsigned peak, unsigned limit) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + float stddev_low = 0.0; + float stddev_up = 0.0; + float ret = 0.0; + + // A transformer avec des iterators + + if (250 > peak) + stddev_up = stddev3(histo |mln::box1d(mln::point1d(peak+1), + mln::point1d(peak+limit)), peak); + + if (5 < peak) + stddev_low = stddev3(histo |mln::box1d(mln::point1d(peak-limit), + mln::point1d(peak-1)), peak); + + ret = (250 < peak)? stddev_low : (5 > peak)? stddev_up : + (stddev_low + stddev_up)/2; + + return ret; +} + +// DOC: +// la discrimination entre la base AFP et la base ICDAR peut se faire en +// étudiant la forme des densités des niveaux de gris. +// Les images naturelles semblent avoir un spectre recouvrant +// en général les 256 niveaux de gris alors que les images de documents ont +// une présence importante du fond. Dans le cadre d'une densité, ce qui est +// alloué sur le fond ne peut se retrouver ailleurs. Une comparaison avec la +// densité équiprobable nous renseigne donc sur la nature des images. +// Il semble néanmoins qu'un certain nombre d'images défient ce dispositif. +// Par exemple des gros plans sur des zones mono-teintée (ski, voile,site web). + + + + +float value_test(const std::string input, + const std::string output, + const std::string tmp, + const short threshold) + +{ + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_value_map; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float cnt1; + float cnt2; + float prop; + float sum; + float prop4; + short peak; + mln::point1d inf; + mln::point1d sup; + + + mln::io::ppm::load(input_rgb8, input.c_str()); + + map = mln::data::transform(input_rgb8, t_rgb_to_value_map()); + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = sum_frequency_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + prop4 = cmp_equi_frequency_histo(histo_float); + peak = peak_histo(histo); // mean_histo(histo); + //prop = stddev2(histo, peak, threshold); + inf = mln::point1d(mln::math::max(0, peak-threshold)); + sup = mln::point1d(mln::math::min(255, peak+threshold)); + cnt1 = count_histo(histo_float|mln::box1d(inf,sup)); + cnt2 = count_histo(histo_float); + prop = ((100.0 * cnt1) / cnt2); + + std::cerr << "peak = " << peak << std::endl; + std::cerr << "inf = " << inf << std::endl; + std::cerr << "sup = " << sup << std::endl; + std::cerr << "cnt1 = " << cnt1 << std::endl; + std::cerr << "cnt2 = " << cnt2 << std::endl; + std::cerr << "prop = " << prop << std::endl; + std::cerr << "prop4= " << prop4 << std::endl; + + mln::io::plot::save_image_sh(histo_float, output.c_str()); + mln::io::pgm::save(map, tmp.c_str()); + + return prop; +} + +//============================================================================// +// MAIN +//============================================================================// + + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + +// t_path full_path[] = {t_path(ICDAR_20P_TEXT_ONLY_IMG_PATH), +// t_path(ICDAR_20P_TEXT_COLOR_IMG_PATH), +// t_path(ICDAR_20P_TEXT_PHOTO_IMG_PATH)}; + + t_path full_path[] = {t_path(AFP_PPM_IMG_PATH)}; + + std::cout << "#!/usr/bin/gnuplot" << std::endl; + std::cout << "set terminal x11 persist 1" << std::endl; + std::cout << "#HUE - SATURATION - VALUE" << std::endl; + std::cout << "plot '-' using 1:2 with point notitle,\\" << std::endl; + std::cout << " '-' using 1:2 with point notitle,\\" << std::endl; + std::cout << " '-' using 1:2 with point notitle" << std::endl; + + for (int i = 0; i < 1; ++i) + { + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + float prop = 0.0; + t_path directory; + t_path leaf; + t_path output; + t_path tmp; + + std::cerr << "entering " << full_path[i] << std::endl; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + std::cerr << dir_iter->path() << std::endl; + // concatenation de chaine +// directory = (ANNOTATING_ICDAR_HUE_RET_PATH); + directory = (ANNOTATING_AFP_HUE_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = hue_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 20); + + std::cout << prop << " "; + +// directory = (ANNOTATING_ICDAR_SAT_RET_PATH); + directory = (ANNOTATING_AFP_SAT_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = saturation_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 25); + + std::cout << prop << " "; + +// directory = (ANNOTATING_ICDAR_VAL_RET_PATH); + directory = (ANNOTATING_AFP_VAL_RET_PATH); + leaf = dir_iter->path().leaf(); + output = change_extension(directory / leaf, ".sh"); + tmp = change_extension(directory / leaf, ".pgm"); + + prop = value_test(dir_iter->path().string(), + output.string(), + tmp.string(), + 15); + + std::cout << prop << " "; + std::cout << "# " << dir_iter->path().leaf() << std::endl; + } + std::cout << "e" << std::endl; + } + } + + return 0; +} -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-219-gd169338 Work on histograms view as density.
by Yann Jacquelet
* green/exp/annotating/histo: New directory. * green/exp/annotating/histo/histo.cc: New Makefile.am. * green/exp/annotating/histo/histo.cc: New source. --- .../annotating/{achromastism => histo}/Makefile.am | 0 milena/sandbox/green/exp/annotating/histo/histo.cc | 306 ++++++++++++++++++++ 2 files changed, 306 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => histo}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/histo/histo.cc diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/histo/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/histo/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/histo/histo.cc b/milena/sandbox/green/exp/annotating/histo/histo.cc new file mode 100644 index 0000000..2fb0131 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/histo/histo.cc @@ -0,0 +1,306 @@ +// Build normalized histogram as density + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/arith/minus.hh> +#include <mln/arith/div.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/convert.hh> +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/zero.hh> +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> +#include <mln/math/sqr.hh> +#include <mln/math/sqrt.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> +#include <mln/fun/v2v/component.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +//============================================================================// +// HISTOGRAM +//============================================================================// + +template <typename I> +mln_value(I) cnt_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) cnt = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + { + cnt += histo(p); + } + + return cnt; +} + +void histo(const std::string input, + const std::string output_map, + const std::string output_histo, + const char space) + +{ + typedef mln::value::rgb8 t_rgb8; + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_sat_map; + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_val_map; + typedef mln::fun::v2v::component<t_rgb8,0> t_component_r; + typedef mln::fun::v2v::component<t_rgb8,1> t_component_g; + typedef mln::fun::v2v::component<t_rgb8,2> t_component_b; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float sum; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + switch(space) + { + case 'h': map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); break; + case 's': map = mln::data::transform(input_rgb8, t_rgb_to_sat_map()); break; + case 'v': map = mln::data::transform(input_rgb8, t_rgb_to_val_map()); break; + case 'r': map = mln::data::transform(input_rgb8, t_component_r()); break; + case 'g': map = mln::data::transform(input_rgb8, t_component_g()); break; + case 'b': map = mln::data::transform(input_rgb8, t_component_b()); break; + default: break;// crash + } + + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = cnt_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + + mln::io::pgm::save(map, output_map.c_str()); + mln::io::plot::save_image_sh(histo_float, output_histo.c_str()); +} + +//============================================================================// +// MAIN +//============================================================================// + + +// in the directory of the images +// out the density directory +// 2 use-cases afp and icdar + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + +// t_path full_path[] = {t_path(ICDAR_20P_TEXT_ONLY_IMG_PATH), +// t_path(ICDAR_20P_TEXT_COLOR_IMG_PATH), +// t_path(ICDAR_20P_TEXT_PHOTO_IMG_PATH)}; + +// t_path full_path[] = {t_path(AFP_INPUT_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP30_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP20_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP10_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK30_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK20_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK10_IMG_PATH)}; + +// t_path full_path[] = {t_path(ICDAR_20P_INPUT_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_GMP30_IMG_PATH)}; + t_path full_path[] = {t_path(ICDAR_20P_GMP20_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_GMP10_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK30_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK20_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK10_IMG_PATH)}; + + for (int i = 0; i < 1; ++i) + { + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + t_path directory; + t_path leaf; + t_path output_map; + t_path output_histo; + + std::cerr << "entering " << full_path[i] << std::endl; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + std::cerr << dir_iter->path() << std::endl; + + leaf = dir_iter->path().leaf(); + +// directory = ANNOTATING_AFP_R_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_R_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_R_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_R_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_R_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'r'); + +// directory = ANNOTATING_AFP_G_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_G_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_G_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_G_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_G_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'g'); + +// directory = ANNOTATING_AFP_B_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_B_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_B_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_B_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_B_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'b'); + +// directory = ANNOTATING_AFP_H_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_H_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_H_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_H_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_H_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'h'); + +// directory = ANNOTATING_AFP_S_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_S_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_S_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_S_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_S_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 's'); + +// directory = ANNOTATING_AFP_V_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_V_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_V_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_V_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_V_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'v'); + } + } + } + + return 0; +} -- 1.5.6.5
14 years, 6 months
1
0
0
0
last-svn-commit-34-g72bad6e Work on histograms view as density.
by Yann Jacquelet
* green/exp/annotating/histo: New directory. * green/exp/annotating/histo/histo.cc: New Makefile.am. * green/exp/annotating/histo/histo.cc: New source. --- .../annotating/{achromastism => histo}/Makefile.am | 0 milena/sandbox/green/exp/annotating/histo/histo.cc | 306 ++++++++++++++++++++ 2 files changed, 306 insertions(+), 0 deletions(-) copy milena/sandbox/green/exp/annotating/{achromastism => histo}/Makefile.am (100%) create mode 100644 milena/sandbox/green/exp/annotating/histo/histo.cc diff --git a/milena/sandbox/green/exp/annotating/achromastism/Makefile.am b/milena/sandbox/green/exp/annotating/histo/Makefile.am similarity index 100% copy from milena/sandbox/green/exp/annotating/achromastism/Makefile.am copy to milena/sandbox/green/exp/annotating/histo/Makefile.am diff --git a/milena/sandbox/green/exp/annotating/histo/histo.cc b/milena/sandbox/green/exp/annotating/histo/histo.cc new file mode 100644 index 0000000..2fb0131 --- /dev/null +++ b/milena/sandbox/green/exp/annotating/histo/histo.cc @@ -0,0 +1,306 @@ +// Build normalized histogram as density + +#include <iostream> +#include <sstream> +#include <boost/filesystem.hpp> + +#include <mln/img_path.hh> + +#include <mln/accu/stat/histo1d.hh> + +#include <mln/arith/minus.hh> +#include <mln/arith/div.hh> + +#include <mln/core/image/image1d.hh> +#include <mln/core/image/image2d.hh> +#include <mln/core/image/dmorph/image_if.hh> + +#include <mln/data/convert.hh> +#include <mln/data/compute.hh> +#include <mln/data/stretch.hh> +#include <mln/data/transform.hh> + +#include <mln/literal/zero.hh> +#include <mln/literal/colors.hh> +#include <mln/literal/grays.hh> + +#include <mln/math/max.hh> +#include <mln/math/min.hh> +#include <mln/math/sqr.hh> +#include <mln/math/sqrt.hh> + +#include <mln/opt/at.hh> + +#include <mln/geom/nsites.hh> + +#include <mln/fun/v2v/rgb_to_hue_map.hh> +#include <mln/fun/v2v/rgb_to_saturation_map.hh> +#include <mln/fun/v2v/rgb_to_value_map.hh> +#include <mln/fun/v2v/component.hh> + +#include <mln/io/ppm/load.hh> +#include <mln/io/pgm/save.hh> +#include <mln/io/plot/save_image_sh.hh> + +#include <mln/value/rgb8.hh> + +//============================================================================// +// HISTOGRAM +//============================================================================// + +template <typename I> +mln_value(I) cnt_histo(const mln::Image<I>& histo_) +{ + const I& histo = exact(histo_); + + mln_precondition(histo.is_valid()); + + mln_value(I) cnt = mln::literal::zero; + mln_piter(I) p(histo.domain()); + + for_all(p) + { + cnt += histo(p); + } + + return cnt; +} + +void histo(const std::string input, + const std::string output_map, + const std::string output_histo, + const char space) + +{ + typedef mln::value::rgb8 t_rgb8; + typedef mln::fun::v2v::rgb_to_hue_map<8> t_rgb_to_hue_map; + typedef mln::fun::v2v::rgb_to_saturation_map<8> t_rgb_to_sat_map; + typedef mln::fun::v2v::rgb_to_value_map<8> t_rgb_to_val_map; + typedef mln::fun::v2v::component<t_rgb8,0> t_component_r; + typedef mln::fun::v2v::component<t_rgb8,1> t_component_g; + typedef mln::fun::v2v::component<t_rgb8,2> t_component_b; + + mln::image2d<mln::value::rgb8> input_rgb8; + mln::image2d<mln::value::int_u8> map; + mln::image1d<unsigned> histo; + mln::image1d<float> histo_float; + float sum; + + mln::io::ppm::load(input_rgb8, input.c_str()); + + switch(space) + { + case 'h': map = mln::data::transform(input_rgb8, t_rgb_to_hue_map()); break; + case 's': map = mln::data::transform(input_rgb8, t_rgb_to_sat_map()); break; + case 'v': map = mln::data::transform(input_rgb8, t_rgb_to_val_map()); break; + case 'r': map = mln::data::transform(input_rgb8, t_component_r()); break; + case 'g': map = mln::data::transform(input_rgb8, t_component_g()); break; + case 'b': map = mln::data::transform(input_rgb8, t_component_b()); break; + default: break;// crash + } + + histo = mln::data::compute(mln::accu::meta::stat::histo1d(), map); + sum = cnt_histo(histo); + histo_float = mln::data::convert(float(), histo) / sum; + + mln::io::pgm::save(map, output_map.c_str()); + mln::io::plot::save_image_sh(histo_float, output_histo.c_str()); +} + +//============================================================================// +// MAIN +//============================================================================// + + +// in the directory of the images +// out the density directory +// 2 use-cases afp and icdar + +int main() +{ + typedef boost::filesystem::path t_path; + typedef boost::filesystem::directory_iterator t_iter_path; + +// t_path full_path[] = {t_path(ICDAR_20P_TEXT_ONLY_IMG_PATH), +// t_path(ICDAR_20P_TEXT_COLOR_IMG_PATH), +// t_path(ICDAR_20P_TEXT_PHOTO_IMG_PATH)}; + +// t_path full_path[] = {t_path(AFP_INPUT_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP30_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP20_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_GMP10_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK30_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK20_IMG_PATH)}; +// t_path full_path[] = {t_path(AFP_MGK10_IMG_PATH)}; + +// t_path full_path[] = {t_path(ICDAR_20P_INPUT_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_GMP30_IMG_PATH)}; + t_path full_path[] = {t_path(ICDAR_20P_GMP20_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_GMP10_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK30_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK20_IMG_PATH)}; +// t_path full_path[] = {t_path(ICDAR_20P_MGK10_IMG_PATH)}; + + for (int i = 0; i < 1; ++i) + { + if (boost::filesystem::exists(full_path[i]) && + boost::filesystem::is_directory(full_path[i])) + { + boost::filesystem::system_complete(full_path[i]); + const t_iter_path end_iter; + t_path directory; + t_path leaf; + t_path output_map; + t_path output_histo; + + std::cerr << "entering " << full_path[i] << std::endl; + + for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter) + { + std::cerr << dir_iter->path() << std::endl; + + leaf = dir_iter->path().leaf(); + +// directory = ANNOTATING_AFP_R_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_R_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_R_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_R_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_R_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_R_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_R_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_R_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'r'); + +// directory = ANNOTATING_AFP_G_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_G_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_G_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_G_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_G_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_G_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_G_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_G_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'g'); + +// directory = ANNOTATING_AFP_B_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_B_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_B_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_B_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_B_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_B_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_B_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_B_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'b'); + +// directory = ANNOTATING_AFP_H_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_H_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_H_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_H_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_H_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_H_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_H_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_H_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'h'); + +// directory = ANNOTATING_AFP_S_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_S_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_S_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_S_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_S_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_S_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_S_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_S_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 's'); + +// directory = ANNOTATING_AFP_V_INPUT_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP30_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP20_RET_PATH; +// directory = ANNOTATING_AFP_V_GMP10_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK30_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK20_RET_PATH; +// directory = ANNOTATING_AFP_V_MGK10_RET_PATH; + +// directory = ANNOTATING_ICDAR_V_INPUT_RET_PATH; +// directory = ANNOTATING_ICDAR_V_GMP30_RET_PATH; + directory = ANNOTATING_ICDAR_V_GMP20_RET_PATH; +// directory = ANNOTATING_ICDAR_V_GMP10_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK30_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK20_RET_PATH; +// directory = ANNOTATING_ICDAR_V_MGK10_RET_PATH; + output_histo = change_extension(directory / leaf, ".sh"); + output_map = change_extension(directory / leaf, ".pgm"); + + histo(dir_iter->path().string(), + output_map.string(), + output_histo.string(), + 'v'); + } + } + } + + return 0; +} -- 1.5.6.5
14 years, 6 months
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
28
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Results per page:
10
25
50
100
200