39 #include <visp3/core/vpImageTools.h>
40 #include <visp3/imgproc/vpImgproc.h>
67 for (
unsigned int i = 0; i < I.
getHeight(); ++i) {
68 for (
unsigned int j = 0; j < I.
getWidth(); ++j) {
69 mask[i + 1][j + 1] = 255 - I[i][j];
75 for (
unsigned int i = 0; i < marker.
getHeight(); ++i) {
76 if (i == 0 || i == marker.
getHeight() - 1) {
77 for (
unsigned int j = 0; j < marker.
getWidth(); ++j) {
83 marker[i][marker.
getWidth() - 1] = 255;
88 reconstruct(marker, mask, I_reconstruct, connexity);
90 for (
unsigned int i = 0; i < I.
getHeight(); ++i) {
91 for (
unsigned int j = 0; j < I.
getWidth(); ++j) {
92 I[i][j] = 255 - I_reconstruct[i + 1][j + 1];
100 for (
unsigned int i = 0; i < i_height; ++i) {
101 memcpy(flood_fill_mask[i + 1] + 1, I[i],
sizeof(
unsigned char) * I.
getWidth());
105 const unsigned char newVal = 255;
110 unsigned int mask_height = mask.
getHeight();
111 for (
unsigned int i = 0; i < mask_height; ++i) {
112 memcpy(mask[i], flood_fill_mask[i + 1] + 1,
sizeof(
unsigned char) * mask.
getWidth());
126 std::cerr <<
"marker.getHeight() != mask.getHeight() || "
127 "marker.getWidth() != mask.getWidth()"
133 std::cerr <<
"Input images are empty!" << std::endl;
140 bool h_kp1_eq_h_k =
false;
143 vpImageMorphology::dilatation<unsigned char>(h_kp1, connexity);
146 unsigned int h_kp1_height = h_kp1.
getHeight();
147 unsigned int h_kp1_width = h_kp1.
getWidth();
148 for (
unsigned int i = 0; i < h_kp1_height; ++i) {
149 for (
unsigned int j = 0; j < h_kp1_width; ++j) {
150 h_kp1[i][j] = std::min<unsigned char>(h_kp1[i][j], mask[i][j]);
161 }
while (h_kp1_eq_h_k ==
false);
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
unsigned int getWidth() const
unsigned int getSize() const
unsigned int getHeight() const
VISP_EXPORT void floodFill(VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &seedPoint, const unsigned char oldValue, const unsigned char newValue, const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity=VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4)
VISP_EXPORT void fillHoles(VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &I)
VISP_EXPORT void reconstruct(const VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &marker, const VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &mask, VISP_NAMESPACE_ADDRESSING vpImage< unsigned char > &h_kp1, const VISP_NAMESPACE_ADDRESSING vpImageMorphology::vpConnexityType &connexity=VISP_NAMESPACE_ADDRESSING vpImageMorphology::CONNEXITY_4)