Commit f51682b2 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

New debugging tools for Scribo.

	* src/Makefile.am: Add debug as subdir.

	* src/debug/Makefile.am,
	* src/debug/show_left_right_links_validation.cc,
	* src/debug/show_link_single_left.cc,
	* src/debug/show_link_single_right.cc,
	* src/debug/show_objects_large.cc,
	* src/debug/show_objects_small.cc,
	* src/debug/show_objects_thin.cc: New.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4596 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent bbc4eb43
2009-10-01 Guillaume Lazzara <z@lrde.epita.fr>
New debugging tools for Scribo.
* src/Makefile.am: Add debug as subdir.
* src/debug/Makefile.am,
* src/debug/show_left_right_links_validation.cc,
* src/debug/show_link_single_left.cc,
* src/debug/show_link_single_right.cc,
* src/debug/show_objects_large.cc,
* src/debug/show_objects_small.cc,
* src/debug/show_objects_thin.cc: New.
2009-10-01 Guillaume Lazzara <z@lrde.epita.fr>
Few improvements in Scribo.
......
......@@ -21,6 +21,7 @@ include $(top_srcdir)/scribo/scribo.mk
SUBDIRS = \
binarization \
debug \
primitive \
filter \
misc \
......
# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
# Olena is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, version 2 of the License.
#
# Olena is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
#
## Process this file through Automake to create Makefile.in.
include $(top_srcdir)/scribo/scribo.mk
bin_PROGRAMS = \
show_objects_large \
show_left_right_links_validation \
show_link_single_left \
show_link_single_right \
show_objects_small \
show_objects_thin
show_objects_large_SOURCES = show_objects_large.cc
show_left_right_links_validation_SOURCES = show_left_right_links_validation.cc
show_link_single_left_SOURCES = show_link_single_left.cc
show_link_single_right_SOURCES = show_link_single_right.cc
show_objects_small_SOURCES = show_objects_small.cc
show_objects_thin_SOURCES = show_objects_thin.cc
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/labeling/colorize.hh>
#include <mln/debug/println.hh>
#include <mln/data/convert.hh>
#include <mln/util/array.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/value/label_16.hh>
#include <scribo/core/object_links.hh>
#include <scribo/core/object_image.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/merge_double_link.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/draw/bounding_box_links.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. 'True' for objects, 'False'\
for the background." },
{ "hlmax", "Maximum distance between two grouped objects while browsing on the left." },
{ "hrmax", "Maximum distance between two grouped objects while browsing on the right." },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace scribo;
using namespace mln;
if (argc != 5)
return scribo::debug::usage(argv,
"Display double validated (left and right) links between objects",
"<input.pbm> <hlmax> <hrmax> <output.ppm>",
args_desc,
"A color image. Validated links are drawn in green.");
image2d<bool> input;
io::pbm::load(input, argv[1]);
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects = primitive::extract::objects(input, c8(), nbboxes);
// Left links.
object_links<L> left_link
= primitive::link::with_single_left_link(objects, atoi(argv[2]));
// Right links.
object_links<L> right_link
= primitive::link::with_single_right_link(objects, atoi(argv[3]));
// Validation.
object_links<L>
links = primitive::link::merge_double_link(objects, left_link, right_link);
// Saving result.
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
// scribo::draw::bounding_boxes(output, objects, literal::blue);
scribo::draw::bounding_box_links(output,
objects.bboxes(),
links,
literal::green);
util::array<bool> drawn(objects.nlabels(), 0);
for_all_components(i, objects.bboxes())
if (links[i] == i && ! drawn(i))
{
mln::draw::box(output, objects.bbox(i), literal::orange);
drawn[i] = true;
}
else
{
mln::draw::box(output, objects.bbox(i), literal::blue);
mln::draw::box(output, objects.bbox(links[i]), literal::blue);
drawn[i] = true;
drawn[links[i]] = true;
}
io::ppm::save(output, argv[4]);
}
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/convert.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the background." },
{ "max_nbh_dist", " Maximum distance for neighborhood search. (common value : 30)" },
{0, 0}
};
int main(int argc, char* argv[])
{
using namespace scribo;
using namespace scribo::primitive::internal;
using namespace mln;
if (argc != 4)
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful left links between components.",
"input.pbm max_nbh_dist output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
image2d<bool> input;
io::pbm::load(input, argv[1]);
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
// Finding left links.
object_links<L> left_link
= primitive::link::with_single_left_link(objects, atoi(argv[2]));
// Preparing output image.
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
scribo::draw::bounding_boxes(output, objects, literal::blue);
// Drawing links.
mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
mass_centers = labeling::compute(accu::meta::center(),
objects, objects.nlabels());
for_all_ncomponents(i, objects.nlabels())
{
unsigned midcol = (objects.bbox(i).pmax().col()
- objects.bbox(i).pmin().col()) / 2;
int dmax = midcol + atoi(argv[2]);
mln_site_(L) c = mass_centers(i);
mln_site_(L) p = c + mln::left;
while (is_invalid_link(objects, left_link, p, i, c, dmax))
{
if (left_link[i] != i)
output(p) = literal::green;
else
output(p) = literal::red;
--p.col();
}
}
io::ppm::save(output, argv[3]);
}
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/convert.hh>
#include <mln/value/rgb8.hh>
#include <mln/value/label_16.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the background." },
{ "max_nbh_dist", " Maximum distance for neighborhood search. (common value : 30)" },
{0, 0}
};
int main(int argc, char* argv[])
{
using namespace scribo;
using namespace scribo::primitive::internal;
using namespace mln;
if (argc != 4)
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful right links between components.",
"input.pbm max_nbh_dist output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
image2d<bool> input;
io::pbm::load(input, argv[1]);
// Finding objects.
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
// Finding right links.
object_links<L> right_link
= primitive::link::with_single_right_link(objects, atoi(argv[2]));
// Preparing output image.
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
scribo::draw::bounding_boxes(output, objects, literal::blue);
// Drawing links.
mln::util::array<mln_result_(accu::center<mln_psite_(L)>)>
mass_centers = labeling::compute(accu::meta::center(),
objects, objects.nlabels());
for_all_ncomponents(i, objects.nlabels())
{
unsigned midcol = (objects.bbox(i).pmax().col()
- objects.bbox(i).pmin().col()) / 2;
int dmax = midcol + atoi(argv[2]);
mln_site_(L) c = mass_centers(i);
mln_site_(L) p = c + mln::right;
while (is_invalid_link(objects, right_link, p, i, c, dmax))
{
if (right_link[i] != i)
output(p) = literal::green;
else
output(p) = literal::red;
++p.col();
}
}
io::ppm::save(output, argv[3]);
}
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/convert.hh>
#include <mln/value/label_16.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/filter/objects_large.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the background." },
{ "max_card", " Maximum cardinality in a component." },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace mln;
if (argc != 4)
return scribo::debug::usage(argv,
"Show components having a too high cardinality.",
"input.pbm min_card output.ppm",
args_desc,
"A color image. Components with high cardinality have their bounding boxes drawn in red, others in green.");
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
scribo::draw::bounding_boxes(output, objects, literal::red);
object_image(L) filtered_objects
= scribo::filter::objects_large(objects, atoi(argv[2]));
scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
io::ppm::save(output, argv[3]);
}
// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
#include <iostream>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/data/convert.hh>
#include <mln/value/label_16.hh>
#include <mln/value/rgb8.hh>
#include <mln/literal/colors.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/filter/objects_small.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/usage.hh>
const char *args_desc[][2] =
{
{ "input.pbm", "A binary image. True for objects and False for the background." },
{ "min_card", " Minimum cardinality in a component.. (Common value : 6)" },
{0, 0}
};
int main(int argc, char *argv[])
{
using namespace mln;
if (argc != 4)
return scribo::debug::usage(argv,
"Show components having a too low cardinality.",
"input.pbm min_card output.ppm",
args_desc,
"A color image. Components with low cardinality have their bounding boxes drawn in red, others in green.");
trace::entering("main");
image2d<bool> input;
io::pbm::load(input, argv[1]);
value::label_16 nbboxes;
typedef image2d<value::label_16> L;
object_image(L) objects
= scribo::primitive::extract::objects(input, c8(), nbboxes);
image2d<value::rgb8> output = data::convert(value::rgb8(), input);
scribo::draw::bounding_boxes(output, objects, literal::red);
object_image(L) filtered_objects
= scribo::filter::objects_small(objects, atoi(argv[2]));
scribo::draw::bounding_boxes(output, filtered_objects, literal::green);
io::ppm::save(output, argv[3]);
}
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