Commit f370a256 authored by Philippe's avatar Philippe
Browse files

remove: fun with ouput sorry_edwin

parent ca6ee703
Pipeline #27860 passed with stages
in 8 minutes and 21 seconds
......@@ -2,18 +2,13 @@
#include <map>
#include <mln/contrib/segdet/segdet.hpp>
#include <mln/contrib/segdet/segment.hpp>
#include <mln/core/image_format.hpp>
#include <mln/core/algorithm/fill.hpp>
#include <mln/core/image_format.hpp>
#include <pybind11/iostream.h>
#include <utility>
using sorry_edwin =
std::vector<std::pair<bool, std::pair<std::vector<std::vector<uint32_t>>, std::vector<std::vector<uint32_t>>>>>;
namespace pln::contrib::segdet
{
std::vector<mln::contrib::segdet::Segment> detect_line_base(mln::ndbuffer_image img, int min_len, int disc,
const std::map<std::string, double>& params)
{
......@@ -26,35 +21,16 @@ namespace pln::contrib::segdet
return mln::contrib::segdet::detect_line(std::move(img), min_len, disc, params_cpp);
}
sorry_edwin detect_line_sorry_edwin(mln::ndbuffer_image img, int min_len, int disc,
const std::map<std::string, double>& params = std::map<std::string, double>())
{
auto p = detect_line_base(img, min_len, disc, params);
sorry_edwin out;
for (auto& seg : p)
{
std::vector<std::vector<uint32_t>> points;
for (auto& point : seg.points)
points.push_back(std::vector<uint32_t>({point.x, point.y, point.thickness}));
std::vector<std::vector<uint32_t>> under;
auto inner_pair = std::make_pair(points, under);
auto outer_pair = std::make_pair(seg.is_horizontal, inner_pair);
out.push_back(outer_pair);
}
return out;
}
mln::ndbuffer_image detect_line_labelled(mln::ndbuffer_image img, int min_len, int disc,
const std::map<std::string, double>& params = std::map<std::string, double>())
mln::ndbuffer_image
detect_line_labelled(mln::ndbuffer_image img, int min_len, int disc,
const std::map<std::string, double>& params = std::map<std::string, double>())
{
auto p = detect_line_base(img, min_len, disc, params);
mln::image2d<uint16_t> out(img.size(0), img.size(1));
mln::fill(out, 0);
mln::contrib::segdet::labeled_arr(out, p);
return std::move(out);
}
......@@ -64,29 +40,25 @@ namespace pln::contrib::segdet
auto p = detect_line_base(std::move(img), min_len, disc, params);
int nb_points = 0;
for (auto &seg : p)
{
for (auto& seg : p)
nb_points += seg.nb_pixels;
}
mln::image2d<uint32_t> out(3, nb_points);
int count = 0;
int count = 0;
int nb_seg = 0;
for (auto& seg : p)
{
for (auto& point : seg.points)
{
out({0, count}) = nb_seg;
out({1, count}) = point.x;
out({0, count}) = nb_seg;
out({1, count}) = point.x;
out({2, count++}) = point.y;
}
nb_seg++;
}
return std::move(out);
}
} // namespace pln::contrib::segdet
\ No newline at end of file
......@@ -16,8 +16,6 @@ namespace pln
PYBIND11_MODULE(pylena, m)
{
init_pylena_numpy(m);
m.def("detect_line_se", &pln::contrib::segdet::detect_line_sorry_edwin, py::arg("img"), py::arg("min_len"),
py::arg("disc"), py::arg("params") = std::map<std::string, double>());
m.def("detect_line_l", &pln::contrib::segdet::detect_line_labelled, py::arg("img"), py::arg("min_len"),
py::arg("disc"), py::arg("params") = std::map<std::string, double>());
......
......@@ -10,10 +10,8 @@
#include <mln/morpho/erosion.hpp>
#include <utility>
namespace mln::contrib::segdet
{
/**
* Detects lines in the given image
* @param image A ndbuffer representing the image to process (can be rgb or uint8)
......@@ -22,13 +20,13 @@ namespace mln::contrib::segdet
* @return A vector of detected segments
*/
std::vector<Segment> detect_line(mln::ndbuffer_image image, uint min_len, uint discontinuity);
std::vector<Segment> detect_line(mln::ndbuffer_image image, uint min_len, uint discontinuity, const Parameters &params);
std::vector<Segment> detect_line(mln::ndbuffer_image image, uint min_len, uint discontinuity,
const Parameters& params);
/**
* Draw segments in img out
* @param out Image to draw in
* @param segments
*/
* Draw segments in img out
* @param out Image to draw in
* @param segments
*/
void labeled_arr(image2d<uint16_t> out, const std::vector<Segment>& segments);
} // namespace mln::contrib::segdet
\ No newline at end of file
......@@ -899,7 +899,4 @@ namespace mln::contrib::segdet
{
return detect_line(std::move(image), min_len, discontinuity, Parameters());
}
} // namespace mln::contrib::segdet
\ No newline at end of file
Markdown is supported
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