Commit 9519650b authored by Michaël Roynard's avatar Michaël Roynard
Browse files

ndimage is accessible

Fix ambiguous calls
parent c8006f2a
Pipeline #12375 failed with stages
in 5 minutes and 22 seconds
......@@ -18,8 +18,8 @@ namespace mln::archetypes
struct Image
{
using new_pixel_type = Pixel;
using value_type = pixel_value_t<Pixel>;
using reference = pixel_reference_t<Pixel>;
using new_value_type = pixel_value_t<Pixel>;
using new_reference = pixel_reference_t<Pixel>;
using new_point_type = domain_point_t<Domain>;
using domain_type = Domain;
using category_type = forward_image_tag;
......@@ -80,6 +80,7 @@ namespace mln::archetypes
struct OutputImage final : Image
{
using new_pixel_type = OutputPixel;
using new_reference = pixel_reference_t<OutputPixel>;
struct OutputPixelRange final
......@@ -139,7 +140,7 @@ namespace mln::archetypes
struct OutputIndexableImage final : IndexableImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using new_reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputIndexableImage> operator[](image_index_t<OutputIndexableImage>) const;
image_reference_t<OutputIndexableImage> operator[](image_index_t<OutputIndexableImage>);
......@@ -183,7 +184,7 @@ namespace mln::archetypes
struct OutputAccessibleImage final : AccessibleImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using new_reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputAccessibleImage> operator()(image_point_t<OutputAccessibleImage>) const;
image_reference_t<OutputAccessibleImage> operator()(image_point_t<OutputAccessibleImage>);
......@@ -243,7 +244,7 @@ namespace mln::archetypes
struct OutputBidirectionalImage : BidirectionalImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using new_reference = pixel_reference_t<OutputPixel>;
struct OutputPixelRange
{
......@@ -315,7 +316,7 @@ namespace mln::archetypes
struct OutputRawImage final : RawImage
{
using new_pixel_type = OutputPixel;
using reference = pixel_reference_t<OutputPixel>;
using new_reference = pixel_reference_t<OutputPixel>;
image_reference_t<OutputRawImage> operator[](image_index_t<OutputRawImage>) const;
image_reference_t<OutputRawImage> operator[](image_index_t<OutputRawImage>);
......
......@@ -171,13 +171,15 @@ namespace mln
using new_const_pixel_type = details::ndpixel<const T, dim>;
/// \copydoc image::value_type
using value_type = T;
using value_type[[deprecated]] = T;
using new_value_type = pixel_value_t<new_pixel_type>;
/// \copydoc image::reference
using reference = T&;
using reference[[deprecated]] = T&;
using new_reference[[deprecated]] = pixel_reference_t<new_pixel_type>;
/// \copydoc image::const_reference
using const_reference = const T&;
using const_reference[[deprecated]] = const T&;
/// \copydoc image::difference_type
using difference_type[[deprecated]] = int;
......@@ -245,24 +247,28 @@ namespace mln
/// \{
/// \copydoc image::operator()(const site_type& p) const
reference operator()(const site_type& p);
[[deprecated]] reference operator()(const site_type& p);
new_reference operator()(const new_point_type& p);
/// \copydoc image::operator()(const site_type& p) const
const_reference operator()(const site_type& p) const;
[[deprecated]] const_reference operator()(const site_type& p) const;
new_reference operator()(const new_point_type& p) const;
/// \copydoc image::operator[](size_type i) const
[[deprecated]] reference operator[](size_type i);
reference operator[](index_type i);
new_reference operator[](index_type i);
/// \copydoc image::operator[](size_type i) const
[[deprecated]] const_reference operator[](size_type i) const;
reference operator[](index_type i) const;
new_reference operator[](index_type i) const;
/// \copydoc image::at(const site_type& p) const
reference at(const site_type& p);
[[deprecated]] reference at(const site_type& p);
new_reference at(const new_point_type& p);
/// \copydoc image::at(const site_type& p) const
const_reference at(const site_type& p) const;
[[deprecated]] const_reference at(const site_type& p) const;
new_reference at(const new_point_type& p) const;
/// \}
......@@ -270,12 +276,14 @@ namespace mln
/// \{
/// \copydoc image::pixel_at(const point_type&) const
[[deprecated]] pixel_type pixel_at(const point_type& p);
new_pixel_type new_pixel_at(const point_type& p);
[[deprecated]] pixel_type pixel_at(const point_type& p);
[[deprecated]] new_pixel_type new_pixel_at(const point_type& p);
new_pixel_type new_pixel_at(const new_point_type& p);
/// \copydoc image::pixel_at(const point_type&) const
[[deprecated]] const_pixel_type pixel_at(const point_type& p) const;
new_const_pixel_type new_pixel_at(const point_type& p) const;
[[deprecated]] const_pixel_type pixel_at(const point_type& p) const;
[[deprecated]] new_const_pixel_type new_pixel_at(const point_type& p) const;
new_pixel_type new_pixel_at(const new_point_type& p) const;
/// \copydoc image::pixel_at_index(size_type) const
[[deprecated]] pixel_type pixel_at_index(size_type i);
......@@ -286,12 +294,14 @@ namespace mln
// new_const_pixel_type new_pixel_at_index(size_type i) const;
/// \copydoc image::pixel(const point_type&) const
[[deprecated]] pixel_type pixel(const point_type& p);
new_pixel_type new_pixel(const point_type& p);
[[deprecated]] pixel_type pixel(const point_type& p);
[[deprecated]] new_pixel_type new_pixel(const point_type& p);
new_pixel_type new_pixel(const new_point_type& p);
/// \copydoc image::pixel(const point_type&) const
[[deprecated]] const_pixel_type pixel(const point_type& p) const;
new_const_pixel_type new_pixel(const point_type& p) const;
[[deprecated]] const_pixel_type pixel(const point_type& p) const;
[[deprecated]] new_const_pixel_type new_pixel(const point_type& p) const;
new_pixel_type new_pixel(const new_point_type& p) const;
/// \}
......
......@@ -8,10 +8,10 @@ namespace mln
using image_pixel_t = typename I::new_pixel_type;
template <class I>
using image_reference_t = typename I::reference;
using image_reference_t = typename I::new_reference;
template <class I>
using image_value_t = typename I::value_type;
using image_value_t = typename I::new_value_type;
template <class I>
using image_point_t = typename I::new_point_type;
......
......@@ -39,7 +39,7 @@ namespace mln
other.m_domain = domain;
other.m_border = image.m_border; // FIXME
other.m_ptr = (char*)&image(domain.pmin);
other.m_last = (char*)&image(domain.pmax - 1);
other.m_last = (char*)&image(typename Domain_::point_type(domain.pmax - 1));
other.m_ptr_origin = image.m_ptr_origin;
other.m_index_first = image.index_of_point(domain.pmin);
other.m_index_last = image.index_of_point(domain.pmax - 1);
......
......@@ -389,9 +389,15 @@ namespace mln
Etype& edge_at(const edge_type& e)
{
if (e.type == SOURCE_EDGE)
return m_src.at(e.p / 2);
{
point2d pnt = e.p / 2;
return m_src.at(pnt);
}
else if (e.type == SINK_EDGE)
return m_sink.at(e.p / 2);
{
point2d pnt = e.p / 2;
return m_sink.at(pnt);
}
else
return base::edge_at(e.p);
}
......@@ -573,7 +579,7 @@ namespace mln
int operator()(W x, W y) const { return (y < x) - (x < y); }
};
}
} // namespace internal
template <typename V, class N, class DataFidelityFunction, class RegularityFunction, class Compare>
double graphcut(const image2d<V>& ima, image2d<bool>& f, const N& nbh, DataFidelityFunction d, RegularityFunction v,
......@@ -609,17 +615,25 @@ namespace mln
switch (e.type)
{
case G::SOURCE_EDGE:
w = d(false, ima(graph.target(e) / 2));
graph.edge(e) = {w, 0};
{
typename image2d<V>::site_type pnt = graph.target(e) / 2;
w = d(false, ima(pnt));
graph.edge(e) = {w, 0};
break;
}
case G::NORMAL_EDGE:
{
graph.edge(e) = {w2, w2};
break;
}
case G::SINK_EDGE:
w = d(true, ima(graph.source(e) / 2));
graph.edge(e) = {w, 0};
{
typename image2d<V>::site_type pnt = graph.source(e) / 2;
w = d(true, ima(pnt));
graph.edge(e) = {w, 0};
break;
}
}
mln_foreach (const point2d& p, graph.vertices())
graph.vertex(p) = {p, p, false};
......@@ -845,7 +859,7 @@ namespace mln
std::cout << "Maxflow: " << maxflow << std::endl;
return maxflow;
}
}
}
} // namespace graphcut
} // namespace mln
#endif // ! GRAPHCUT_HH
......@@ -59,9 +59,9 @@ namespace mln
std::enable_if_t<dim == (O::ndim - 1)> immersion(const I& input, O& output, mln_point(I) pmin,
mln_point(I) pmax)
{
auto q = pmin / 2;
auto p = pmin;
auto a = input(q);
mln_point(I) q = pmin / 2;
auto p = pmin;
auto a = input(q);
output(p) = a;
for (int i = pmin[dim] + 2; i < pmax[dim]; i += 2)
......@@ -120,9 +120,9 @@ namespace mln
return out;
}
} // end of namespace mln::morpho::tos::impl
} // end of namespace mln::morpho::tos
} // end of namespace mln::morpho
} // namespace impl
} // namespace ToS
} // namespace morpho
} // end of namespace mln
......
......@@ -11,7 +11,7 @@
namespace concepts = mln::concepts;
#ifdef PYLENE_CONCEPT_TS_ENABLED
template <concepts::IndexableImage Ima>
template <concepts::AccessibleImage Ima>
void foo(Ima)
{
}
......@@ -26,7 +26,7 @@ TEST(Core, Image_Image2D)
static_assert(concepts::Image<mln::image2d<int>>);
static_assert(concepts::IndexableImage<mln::image2d<int>>);
// static_assert(concepts::AccessibleImage<mln::image2d<int>>);
static_assert(concepts::AccessibleImage<mln::image2d<int>>);
// static_assert(concepts::BidirectionalImage<mln::image2d<int>>);
// static_assert(concepts::RawImage<mln::image2d<int>>);
#endif // PYLENE_CONCEPT_TS_ENABLED
......
......@@ -31,7 +31,7 @@ void test_dilation_by_periodic_line(const mln::point2d& dp, int k)
for (int i = 0; i < k; ++i)
mln_foreach (auto p, ref.domain())
if (ref.domain().has(p + dp))
ref(p) = ref(p + dp);
ref(p) = ref(mln::point2d(p + dp));
// Run algo
mln::se::periodic_line2d line(dp, k);
......
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