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

Add new debug tools.

	* src/debug/Makefile.am: Add new targets.

	* src/debug/show_links_bbox_h_ratio.cc,
	* src/debug/show_links_bbox_overlap.cc,
	* src/debug/show_links_bottom_aligned.cc,
	* src/debug/show_links_center_aligned.cc,
	* src/debug/show_links_non_h_aligned.cc,
	* src/debug/show_links_several_right.cc,
	* src/debug/show_links_several_right_overlap.cc,
	* src/debug/show_links_single_left.cc,
	* src/debug/show_links_single_left_dmax_ratio.cc,
	* src/debug/show_links_single_right.cc,
	* src/debug/show_links_single_right_dmax_ratio.cc,
	* src/debug/show_links_top_aligned.cc,
	* src/debug/show_objects_large_small.cc,
	* src/debug/show_objects_thick.cc: New debug tools.

	* src/debug/show_objects_thin.cc: Write it.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4707 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 602810cd
2009-11-03 Guillaume Lazzara <z@lrde.epita.fr>
Add new debug tools.
* src/debug/Makefile.am: Add new targets.
* src/debug/show_links_bbox_h_ratio.cc,
* src/debug/show_links_bbox_overlap.cc,
* src/debug/show_links_bottom_aligned.cc,
* src/debug/show_links_center_aligned.cc,
* src/debug/show_links_non_h_aligned.cc,
* src/debug/show_links_several_right.cc,
* src/debug/show_links_several_right_overlap.cc,
* src/debug/show_links_single_left.cc,
* src/debug/show_links_single_left_dmax_ratio.cc,
* src/debug/show_links_single_right.cc,
* src/debug/show_links_single_right_dmax_ratio.cc,
* src/debug/show_links_top_aligned.cc,
* src/debug/show_objects_large_small.cc,
* src/debug/show_objects_thick.cc: New debug tools.
* src/debug/show_objects_thin.cc: Write it.
2009-11-03 Guillaume Lazzara <z@lrde.epita.fr>
Add new link filters.
......
......@@ -20,17 +20,41 @@
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_links_bbox_h_ratio \
show_links_bbox_overlap \
show_links_bottom_aligned \
show_links_center_aligned \
show_links_non_h_aligned \
show_links_several_right \
show_links_several_right_overlap \
show_links_single_left \
show_links_single_left_dmax_ratio \
show_links_single_right \
show_links_single_right_dmax_ratio \
show_links_top_aligned \
show_objects_large \
show_objects_large_small \
show_objects_small \
show_objects_thick \
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_links_bbox_h_ratio_SOURCES = show_links_bbox_h_ratio.cc
show_links_bbox_overlap_SOURCES = show_links_bbox_overlap.cc
show_links_bottom_aligned_SOURCES = show_links_bottom_aligned.cc
show_links_center_aligned_SOURCES = show_links_center_aligned.cc
show_links_non_h_aligned_SOURCES = show_links_non_h_aligned.cc
show_links_several_right_SOURCES = show_links_several_right.cc
show_links_several_right_overlap_SOURCES = show_links_several_right_overlap.cc
show_links_single_left_SOURCES = show_links_single_left.cc
show_links_single_left_dmax_ratio_SOURCES = show_links_single_left_dmax_ratio.cc
show_links_single_right_SOURCES = show_links_single_right.cc
show_links_single_right_dmax_ratio_SOURCES = show_links_single_right_dmax_ratio.cc
show_links_top_aligned_SOURCES = show_links_top_aligned.cc
show_objects_large_SOURCES = show_objects_large.cc
show_objects_large_small_SOURCES = show_objects_large_small.cc
show_objects_small_SOURCES = show_objects_small.cc
show_objects_thick_SOURCES = show_objects_thick.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/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/primitive/link/with_single_left_link.hh>
#include <scribo/filter/object_links_bbox_h_ratio.hh>
#include <scribo/debug/decision_image.hh>
#include <scribo/debug/links_decision_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." },
{ "height_ratio", "Min height ratio between two bboxes. (common value : 2)" },
{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 valid or invalid links according the bboxes height ratio.",
"input.pbm height_ratio 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_links
= primitive::link::with_single_right_link(objects);
// Filtering.
object_links<L> hratio_filtered_links
= filter::object_links_bbox_h_ratio(objects, right_links, atof(argv[2]));
// Debug image.
image2d<value::rgb8> hratio_decision_image
= scribo::debug::links_decision_image(input,
right_links,
hratio_filtered_links);
io::ppm::save(hratio_decision_image, argv[3]);
}
......@@ -38,11 +38,12 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/with_single_left_link.hh>
#include <scribo/filter/object_links_bbox_overlap.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/decision_image.hh>
#include <scribo/debug/links_decision_image.hh>
#include <scribo/debug/usage.hh>
......@@ -50,7 +51,7 @@
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)" },
{ "ratio", "Maximum bounding boxes overlap ratio. (common value : 0.7)" },
{0, 0}
};
......@@ -63,8 +64,8 @@ int main(int argc, char* argv[])
if (argc != 4)
return scribo::debug::usage(argv,
"Show sucessful/unsuccessful left links between components.",
"input.pbm max_nbh_dist output.ppm",
"Show valid or invalid links according the bboxes overlap.",
"input.pbm ratio output.ppm",
args_desc,
"A color image. Valid links are drawn in green, invalid ones in red.");
......@@ -77,41 +78,21 @@ int main(int argc, char* argv[])
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);
// Finding right links.
object_links<L> right_links
= primitive::link::with_single_right_link(objects);
mln_site_(L) p = c + mln::left;
// Filtering.
object_links<L> hratio_filtered_links
= filter::object_links_bbox_overlap(objects, right_links, atof(argv[2]));
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();
}
}
// Debug image.
image2d<value::rgb8> hratio_decision_image
= scribo::debug::links_decision_image(input,
right_links,
hratio_filtered_links);
io::ppm::save(hratio_decision_image, argv[3]);
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_bottom.hh>
#include <scribo/filter/object_links_bottom_aligned.hh>
#include <scribo/debug/alignment_decision_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_alpha", "Max angle between two object bottoms. (common value : 5)" },
{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 valid or invalid links according the horizontal alignment (based on bottom line).",
"input.pbm max_alpha 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_links
= primitive::link::with_single_right_link_bottom(objects);
// Filtering.
object_links<L> filtered_links
= filter::object_links_bottom_aligned(objects, right_links, atof(argv[2]));
// Debug image.
image2d<value::rgb8> decision_image
= scribo::debug::alignment_decision_image(input,
right_links,
filtered_links,
scribo::debug::bottom);
io::ppm::save(decision_image, 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/filter/object_links_center_aligned.hh>
#include <scribo/debug/alignment_decision_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_alpha", "Max angle between two object bottoms. (common value : 5)" },
{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 valid or invalid links according the horizontal alignment (based on center line).",
"input.pbm max_alpha 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_links
= primitive::link::with_single_right_link(objects);
// Filtering.
object_links<L> filtered_links
= filter::object_links_center_aligned(objects, right_links, atof(argv[2]));
// Debug image.
image2d<value::rgb8> decision_image
= scribo::debug::alignment_decision_image(input,
right_links,
filtered_links,
scribo::debug::center);
io::ppm::save(decision_image, 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/primitive/link/with_single_left_link.hh>
#include <scribo/filter/object_links_non_h_aligned.hh>
#include <scribo/debug/decision_image.hh>
#include <scribo/debug/links_decision_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." },
{ "delta", "Max delta for horizontal alignment. (common value : 5)" },
{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 valid or invalid links according the horizontal alignment (based on top and bottom lines).",
"input.pbm delta 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_links
= primitive::link::with_single_right_link(objects);
// Filtering.
object_links<L> filtered_links
= filter::object_links_non_h_aligned(objects, right_links, atoi(argv[2]));
// Debug image.
image2d<value::rgb8> decision_image
= scribo::debug::links_decision_image(input,
right_links,
filtered_links);
io::ppm::save(decision_image, argv[3]);
}
......@@ -38,11 +38,11 @@
#include <mln/io/ppm/save.hh>
#include <scribo/primitive/extract/objects.hh>
#include <scribo/primitive/link/with_single_right_link.hh>
#include <scribo/primitive/link/with_several_right_links.hh>
#include <scribo/draw/bounding_boxes.hh>
#include <scribo/debug/save_linked_bboxes_image.hh>
#include <scribo/debug/several_links_decision_image.hh>
#include <scribo/debug/usage.hh>
......@@ -79,39 +79,17 @@ int main(int argc, char* argv[])
// 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);
= primitive::link::with_several_right_links(objects, atoi(argv[2]));
// 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();
}
}
image2d<value::rgb8> decision_image
= scribo::debug::several_links_decision_image(input,
right_link,