Commit 68ea01c7 authored by Alexandre Abraham's avatar Alexandre Abraham
Browse files

Fix some constants.

	* nature/nature.cc: Fix constants.
	* nature/hsi.cc: New.
	* nature/hom.cc: .


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3182 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 1aa269e6
2009-01-21 Alexandre Abraham <abraham@lrde.epita.fr>
Fix some constants.
* nature/nature.cc: Fix constants.
* nature/hsi.cc: New.
* nature/hom.cc: .
2009-01-21 Guillaume Lazzara <z@lrde.epita.fr>
Add a new LCA implementation to Laurent's code.
......
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -45,8 +45,7 @@
#include <mln/morpho/dilation.hh>
#include <mln/morpho/opening.hh>
#include <mln/win/hline2d.hh>
#include <mln/win/vline2d.hh>
#include <mln/win/all.hh>
int main(int argc, const char * argv[])
{
......@@ -70,245 +69,16 @@ int main(int argc, const char * argv[])
// Compute the mean
int_t mean = estim::mean(ima);
image2d<bool> imab = binarization::threshold(ima, mean-10);
image2d<bool> imab = binarization::threshold(ima, 10);
window2d winout;
window2d winin;
// static const bool matout [] = {0, 0, 0, 0, 0, 0, 0,
// 0, 0, 1, 0, 0, 0, 0,
// 0, 0, 1, 0, 0, 0, 0,
// 0, 0, 1, 0, 0, 0, 0,
// 0, 0, 1, 1, 1, 1, 0,
// 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0};
static const bool blmatout [] = {0, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 1, 0, 0, 0,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0};
// static const bool blmatout [] = {0, 0, 0,
// 1, 0, 0,
// 1, 1, 0};
convert::from_to(blmatout, winout);
// static const bool matin [] = {0, 0, 0, 1, 0, 0, 0,
// 0, 0, 0, 1, 0, 0, 0,
// 0, 0, 0, 1, 0, 0, 0,
// 0, 0, 0, 1, 1, 1, 1,
// 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0,
// 0, 0, 0, 0, 0, 0, 0};
static const bool blmatin [] = {0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 1, 1,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
// static const bool blmatin [] = {0, 1, 0,
// 0, 1, 1,
// 0, 0, 0};
convert::from_to(blmatin, winin);
image2d<bool> bottom_left = morpho::hit_or_miss(imab, winout, winin);
// static const bool brmatout [] = {0, 0, 0,
// 0, 0, 1,
// 0, 1, 1};
// static const bool brmatin [] = {0, 1, 0,
// 1, 1, 0,
// 0, 0, 0};
static const bool brmatout [] = {0, 0, 0, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0};
static const bool brmatin [] = {0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
1, 1, 1, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
convert::from_to(brmatout, winout);
convert::from_to(brmatin, winin);
image2d<bool> bottom_right = morpho::hit_or_miss(imab, winout, winin);
// static const bool urmatout [] = {0, 1, 1,
// 0, 0, 1,
// 0, 0, 0};
// static const bool urmatin [] = {0, 0, 0,
// 1, 1, 0,
// 0, 1, 0};
static const bool urmatout [] = {0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 0};
static const bool urmatin [] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
1, 1, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0};
convert::from_to(urmatout, winout);
convert::from_to(urmatin, winin);
image2d<bool> up_right = morpho::hit_or_miss(imab, winout, winin);
// static const bool ulmatout [] = {1, 1, 0,
// 1, 0, 0,
// 0, 0, 0};
// static const bool ulmatin [] = {0, 0, 0,
// 0, 1, 1,
// 0, 1, 0};
static const bool ulmatout [] = {0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 1, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 0, 0, 0};
static const bool ulmatin [] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 1, 1, 1,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0};
convert::from_to(ulmatout, winout);
convert::from_to(ulmatin, winin);
image2d<bool> up_left = morpho::hit_or_miss(imab, winout, winin);
static const bool umatout [] = {0, 0, 0, 0, 0,
1, 1, 1, 1, 1,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
static const bool umatin [] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
convert::from_to(umatout, winout);
convert::from_to(umatin, winin);
image2d<bool> up = morpho::hit_or_miss(imab, winout, winin);
static const bool bmatout [] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
1, 1, 1, 1, 1,
0, 0, 0, 0, 0};
static const bool bmatin [] = {0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0};
convert::from_to(bmatout, winout);
convert::from_to(bmatin, winin);
image2d<bool> bottom = morpho::hit_or_miss(imab, winout, winin);
static const bool lmatout [] = {0, 1, 0, 0, 0,
0, 1, 0, 0, 0,
0, 1, 0, 0, 0,
0, 1, 0, 0, 0,
0, 1, 0, 0, 0};
static const bool lmatin [] = {0, 0, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 0, 0};
convert::from_to(lmatout, winout);
convert::from_to(lmatin, winin);
image2d<bool> left = morpho::hit_or_miss(imab, winout, winin);
static const bool rmatout [] = {0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0,
0, 0, 0, 1, 0};
static const bool rmatin [] = {0, 0, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 0, 0};
convert::from_to(rmatout, winout);
convert::from_to(rmatin, winin);
image2d<bool> right = morpho::hit_or_miss(imab, winout, winin);
io::pbm::save(imab, "hop.pbm");
window2d out = win::disk2d(25) - win::disk2d(22);
win::disk2d in(4);
std::string name(argv[i]);
name.erase(name.length() - 4);
io::pbm::save( imab, name.append("_bin.pbm"));
name = argv[i];
name.erase(name.length() - 4);
// image2d<bool> final(right.domain());
// data::fill(final, false);
// mln_piter_(image2d<bool>) p(final.domain());
// for_all(p)
// final(p) = up_left(p) || up_right(p) || bottom_right(p) || bottom_left(p) || up(p) || bottom(p) || left(p) || right(p);
image2d<bool> inter (up_left + up_right + bottom_right + bottom_left + up + bottom + left + right);
static const bool vert [] = {0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0};
static const bool hori [] = {0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0};
convert::from_to(vert, winin);
convert::from_to(hori, winout);
image2d<bool> final = morpho::opening(inter, win::hline2d(20));
final += morpho::opening(inter, win::vline2d(20));
io::pbm::save( final,
name.append("_hom.pbm"));
io::pbm::save(morpho::hit_or_miss(imab, in, out), name.append("_hom.pbm"));
}
}
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#include <iterator>
#include <string>
#include <mln/core/image/image2d.hh>
#include <mln/core/image/fun_image.hh>
#include <mln/core/alias/window2d.hh>
#include <mln/win/all.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/hsi.hh>
#include <mln/fun/v2v/rgb_to_hsi.hh>
#include <mln/fun/meta/inty.hh>
#include <mln/level/compare.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/morpho/erosion.hh>
#include <mln/accu/histo.hh>
#include <mln/histo/compute.hh>
#include <mln/level/transform.hh>
#include <mln/data/paste.hh>
using namespace mln;
using namespace value;
int main (int argc, const char* argv [])
{
if (argc < 2) {
std::cerr << "usage: " << argv[0] << " in.ppm [other_files.ppm]" << std::endl;
return 1;
}
for (int i = 1; i < argc; ++i)
{
image2d<rgb8> input;
io::ppm::load(input, argv[i]);
image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f);
fun_image<mln::meta::inty<hsi_f>, image2d<hsi_f> > l(hsi);
win::rectangle2d rect(7,7);
std::string name = argv[i];
name.erase(name.length() - 4);
data::paste(morpho::erosion(l, rect), l);
input = level::transform(hsi, fun::v2v::f_hsi_to_rgb_3x8);
io::ppm::save(input, name.append("_tst.ppm"));
}
}
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -27,7 +27,7 @@
#include <mln/core/image/image2d.hh>
#include <mln/core/image/cast_image.hh>
#include <mln/core/image/thru.hh>
#include <mln/core/image/fun_image.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/io/ppm/load.hh>
......@@ -80,7 +80,7 @@ enum doctype
};
template <typename T>
unsigned nb_peaks (histo::data<T> &h)
unsigned nb_peaks (histo::array<T> &h)
{
// First, we compute the maximum, ignoring the first column because it
// contains nonsense points
......@@ -126,17 +126,17 @@ int main (int argc, const char * argv [])
image2d<hsi_f> hsi = level::transform(input, fun::v2v::f_rgb_to_hsi_f);
thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > hue(hsi);
thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > sat(hsi);
thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > inty(hsi);
fun_image<mln::meta::hue<hsi_f>, image2d<hsi_f> > hue(hsi);
fun_image<mln::meta::sat<hsi_f>, image2d<hsi_f> > sat(hsi);
fun_image<mln::meta::inty<hsi_f>, image2d<hsi_f> > inty(hsi);
cast_image_<float01_8, thru<mln::meta::hue<hsi_f>, image2d<hsi_f> > > qhue(hue); // quantified hue
cast_image_<float01_8, thru<mln::meta::sat<hsi_f>, image2d<hsi_f> > > qsat(sat); // quantified sat
cast_image_<float01_8, thru<mln::meta::inty<hsi_f>, image2d<hsi_f> > > qinty(inty); // quantified inty
cast_image_<float01_8, fun_image<mln::meta::hue<hsi_f>, image2d<hsi_f> > > qhue(hue); // quantified hue
cast_image_<float01_8, fun_image<mln::meta::sat<hsi_f>, image2d<hsi_f> > > qsat(sat); // quantified sat
cast_image_<float01_8, fun_image<mln::meta::inty<hsi_f>, image2d<hsi_f> > > qinty(inty); // quantified inty
histo::data<float01_8> hhue = histo::compute(qhue);
histo::data<float01_8> hsat = histo::compute(qsat);
histo::data<float01_8> hinty = histo::compute(qinty);
histo::array<float01_8> hhue = histo::compute(qhue);
histo::array<float01_8> hsat = histo::compute(qsat);
histo::array<float01_8> hinty = histo::compute(qinty);
// Compute the number of peaks in the histogram to give a first intuition
......@@ -465,7 +465,7 @@ int main (int argc, const char * argv [])
score[PHOTO] += dist * 25;
score[SCREENSHOT] += dist * 25;
score[TEXT] += (1 + cos(arg)) * 2 * (4 - dist) * 50;
score[TEXT] += (1 + cos(arg)) * (4 - dist) * 25;
score[DRAWING] += dist * 25;
std::cout << "Test 4 : Fourier distance[" << dist << "]" << std::endl
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment