Commit 37e7d438 authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Slight modification for MM computation on tree (now it filters the tree as well)

	*  apps/mumford_shah_on_tree/CMakeLists.txt,
	*  apps/mumford_shah_on_tree/mumford_shah_on_tree.cpp,
	*  apps/mumford_shah_on_tree/mumford_shah_on_tree.hpp: Add inplace tree simplification.
parent b9c99b9f
link_libraries(-lfreeimage)
link_libraries(${FreeImage_LIBRARIES})
add_executable(mumford_shah_on_tree mumford_shah_on_tree.cpp)
add_executable(mumford_shah_on_tree_16 mumford_shah_on_tree.cpp)
add_executable(mumford_shah_on_tree_full mumford_shah_on_tree_full.cpp
${CMAKE_SOURCE_DIR}/apps/g2/satmaxtree.cpp
${CMAKE_SOURCE_DIR}/apps/g2/compute_g2.cpp)
set_target_properties(mumford_shah_on_tree_16 PROPERTIES COMPILE_DEFINITIONS MLN_INPUT_VALUE_TYPE=mln::rgb16)
target_link_libraries(mumford_shah_on_tree_full ${TBB_LIBRARIES})
\ No newline at end of file
......@@ -12,6 +12,10 @@
typedef mln::morpho::component_tree<unsigned, mln::image2d<unsigned> > tree_t;
#ifndef MLN_INPUT_VALUE_TYPE
# define MLN_INPUT_VALUE_TYPE mln::rgb8
#endif
tree_t::vertex_id_t
find_canonical(mln::property_map<tree_t, tree_t::vertex_id_t>& newpar,
tree_t::vertex_id_t x)
......@@ -26,7 +30,7 @@ find_canonical(mln::property_map<tree_t, tree_t::vertex_id_t>& newpar,
int main(int argc, char** argv)
{
if (argc < 6) {
std::cerr << "Usage: " << argv[0] << " input.ppm input.tree lambda grain output.ppm\n"
std::cerr << "Usage: " << argv[0] << " input.ppm input.tree lambda grain output.ppm [output.tree]\n"
;
std::exit(1);
}
......@@ -41,9 +45,9 @@ int main(int argc, char** argv)
using namespace mln;
typedef MLN_INPUT_VALUE_TYPE V;
image2d<rgb8> f, F;
image2d<V> f, F;
tree_t tree;
io::imread(input_path, f);
......@@ -68,4 +72,10 @@ int main(int argc, char** argv)
mumford_shah_on_tree(tree, F, lambda);
F = Kadjust_to(F, f.domain());
io::imsave(F, output_path);
if (argc == 7) {
const char* output_path = argv[6];
morpho::save(tree, output_path);
}
}
......@@ -11,12 +11,12 @@
/// \brief Perform the MS simplification
///
/// \param tree The input tree
/// \param[inout] tree The input tree
/// \param[inout] F The input image (interpolated to match tree's domain)
/// \param lambda Mumford-shash regularization parameter
template <class T, class I>
void
mumford_shah_on_tree(const T& tree,
mumford_shah_on_tree(T& tree,
I& F,
double lambda);
......@@ -106,7 +106,7 @@ mumford_shah_on_tree(T& tree,
std::cout << "After: " << k << std::endl;
// Reconstruction
{
morpho::filter_direct_inplace(tree, alive);
tree.shrink_to_fit();
......@@ -114,6 +114,7 @@ mumford_shah_on_tree(T& tree,
auto vmap = morpho::vaccumulate_proper(tree, F, accu::features::mean<> ());
morpho::reconstruction(tree, vmap, F);
}
}
......
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