Commit 6ba16787 authored by Michaël Roynard's avatar Michaël Roynard
Browse files

"Fix" documentation compilation error

parent a9f96455
#include <mln/core/algorithm/transform.hpp>
#include <mln/core/image/image2d.hpp>
#include <mln/core/image/private/image_operators.hpp>
#include <mln/core/neighb2d.hpp>
#include <mln/core/neighborhood/dyn_wneighborhood.hpp>
#include <mln/core/se/disc.hpp>
......@@ -112,9 +113,10 @@ mln::rgb8 heat_lut(float x)
}
}
int main(int argc, char** argv)
{
using namespace mln::experimental::ops;
if (argc < 4)
{
std::cout << "Usage:" << argv[0] << " input distance output\n";
......@@ -136,14 +138,16 @@ int main(int argc, char** argv)
// (3) Run the watershed segmentation
int nlabel;
auto ws = mln::morpho::watershed<mln::int16>(dinv, mln::c8, nlabel);
auto ws = mln::morpho::experimental::watershed<mln::int16>(dinv, mln::c8, nlabel);
// (4) Labelize input
auto output = mln::where(ws == 0, 1, mln::where(input, ws, 0));
[[maybe_unused]] auto output = mln::experimental::where(ws == 0, 1, mln::experimental::where(input, ws, 0));
// END
auto d_stretched = mln::data::stretch<float>(d);
mln::io::imsave(mln::transform(d_stretched, heat_lut), argv[2]);
mln::io::imsave(mln::transform(output, regions_lut), argv[3]);
// FIXME: migrate rangev3 @HEAD
// mln::io::experimental::imsave(mln::transform(output, regions_lut), argv[3]);
}
......@@ -17,6 +17,12 @@ namespace mln
template <class Label_t, class I, class N>
mln_ch_value(I, Label_t) watershed(const Image<I>& ima, const Neighborhood<N>& nbh, int& nlabel);
namespace experimental
{
template <class Label_t, class InputImage, class N>
mln_ch_value(InputImage, Label_t) watershed(InputImage ima, const Neighborhood<N>& nbh, int& nlabel);
}
/******************************************/
/**** Implementation ****/
......@@ -175,6 +181,37 @@ namespace mln
return output;
}
namespace experimental
{
template <class Label_t, class InputImage, class N>
mln_ch_value(InputImage, Label_t) watershed(InputImage ima, const Neighborhood<N>& nbh_, int& nlabel)
{
static_assert(is_a<InputImage, Image>());
static_assert(std::is_integral<Label_t>::value, "The label type must integral.");
static_assert(std::is_signed<Label_t>::value, "The label type must be signed.");
mln_entering("mln::morpho::watershed");
const N& nbh = exact(nbh_);
constexpr Label_t kUninitialized = -1;
mln_ch_value(InputImage, Label_t) output = imchvalue<Label_t>(ima).adjust(nbh).init(kUninitialized);
if (extension::need_adjust(output, nbh))
{
auto out = extension::add_value_extension(output, kUninitialized);
nlabel = details::watershed(ima, nbh, out);
}
else
{
mln::extension::fill(output, kUninitialized);
nlabel = details::watershed(ima, nbh, output);
}
return output;
}
} // namespace experimental
} // namespace morpho
} // namespace mln
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