39 #ifndef vpImageMorphology_H 40 #define vpImageMorphology_H 47 #include <visp3/core/vpImage.h> 48 #include <visp3/core/vpImageException.h> 49 #include <visp3/core/vpMatrix.h> 83 static void erosion(
vpImage<Type> &I, Type value, Type value_out, vpConnexityType connexity = CONNEXITY_4);
86 static void dilatation(
vpImage<Type> &I, Type value, Type value_out, vpConnexityType connexity = CONNEXITY_4);
109 template <
class Type>
113 std::cerr <<
"Input image is empty!" << std::endl;
119 for (
unsigned int i = 0; i < J.getHeight(); i++) {
120 if (i == 0 || i == J.getHeight() - 1) {
121 for (
unsigned int j = 0; j < J.getWidth(); j++) {
126 memcpy(J[i] + 1, I[i - 1],
sizeof(
unsigned char) * I.
getWidth());
127 J[i][J.getWidth() - 1] = value;
131 if (connexity == CONNEXITY_4) {
132 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
133 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
134 if (J[i + 1][j + 1] == value) {
136 if ((J[i][j + 1] == value_out) ||
137 (J[i + 2][j + 1] == value_out) ||
138 (J[i + 1][j] == value_out) ||
139 (J[i + 1][j + 2] == value_out)) {
146 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
147 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
148 if (J[i + 1][j + 1] == value) {
150 if ((J[i][j] == value_out) || (J[i][j + 1] == value_out) || (J[i][j + 2] == value_out) ||
151 (J[i + 1][j] == value_out) || (J[i + 1][j + 2] == value_out) || (J[i + 2][j] == value_out) ||
152 (J[i + 2][j + 1] == value_out) || (J[i + 2][j + 2] == value_out))
177 template <
class Type>
181 std::cerr <<
"Input image is empty!" << std::endl;
187 for (
unsigned int i = 0; i < J.getHeight(); i++) {
188 if (i == 0 || i == J.getHeight() - 1) {
189 for (
unsigned int j = 0; j < J.getWidth(); j++) {
194 memcpy(J[i] + 1, I[i - 1],
sizeof(
unsigned char) * I.
getWidth());
195 J[i][J.getWidth() - 1] = value_out;
199 if (connexity == CONNEXITY_4) {
200 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
201 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
202 if (J[i + 1][j + 1] == value_out) {
204 if ((J[i][j + 1] == value) ||
205 (J[i + 2][j + 1] == value) ||
206 (J[i + 1][j] == value) ||
207 (J[i + 1][j + 2] == value)) {
214 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
215 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
216 if (J[i + 1][j + 1] == value_out) {
218 if ((J[i][j] == value) || (J[i][j + 1] == value) || (J[i][j + 2] == value) || (J[i + 1][j] == value) ||
219 (J[i + 1][j + 2] == value) || (J[i + 2][j] == value) || (J[i + 2][j + 1] == value) ||
220 (J[i + 2][j + 2] == value)) {
Various mathematical morphology tools, erosion, dilatation...
static void dilatation(vpImage< Type > &I, Type value, Type value_out, vpConnexityType connexity=CONNEXITY_4)
unsigned int getWidth() const
static void erosion(vpImage< Type > &I, Type value, Type value_out, vpConnexityType connexity=CONNEXITY_4)
unsigned int getSize() const
unsigned int getHeight() const
Definition of the vpImage class member functions.