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>
82 static void erosion(
vpImage<Type> &I, Type value, Type value_out,
83 vpConnexityType connexity = CONNEXITY_4);
86 static void dilatation(
vpImage<Type> &I, Type value, Type value_out,
87 vpConnexityType connexity = CONNEXITY_4);
117 std::cerr <<
"Input image is empty!" << std::endl;
123 for (
unsigned int i = 0; i < J.getHeight(); i++) {
124 if (i == 0 || i == J.getHeight() - 1) {
125 for (
unsigned int j = 0; j < J.getWidth(); j++) {
130 memcpy(J[i]+1, I[i-1],
sizeof(
unsigned char)*I.
getWidth());
131 J[i][J.getWidth() - 1] = value;
136 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
137 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
138 if (J[i+1][j+1] == value) {
140 if ((J[i][j+1] == value_out) ||
141 (J[i+2][j+1] == value_out) ||
142 (J[i+1][j] == value_out) ||
143 (J[i+1][j+2] == value_out)) {
151 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
152 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
153 if (J[i+1][j+1] == value) {
155 if ((J[i][j] == value_out) ||
156 (J[i][j+1] == value_out) ||
157 (J[i][j+2] == value_out) ||
158 (J[i+1][j] == value_out) ||
159 (J[i+1][j+2] == value_out) ||
160 (J[i+2][j] == value_out) ||
161 (J[i+2][j+1] == value_out) ||
162 (J[i+2][j+2] == value_out) )
163 I[i][j] = value_out ;
194 std::cerr <<
"Input image is empty!" << std::endl;
200 for (
unsigned int i = 0; i < J.getHeight(); i++) {
201 if (i == 0 || i == J.getHeight() - 1) {
202 for (
unsigned int j = 0; j < J.getWidth(); j++) {
207 memcpy(J[i]+1, I[i-1],
sizeof(
unsigned char)*I.
getWidth());
208 J[i][J.getWidth() - 1] = value_out;
213 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
214 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
215 if (J[i+1][j+1] == value_out) {
217 if ((J[i][j+1] == value) ||
218 (J[i+2][j+1] == value) ||
219 (J[i+1][j] == value) ||
220 (J[i+1][j+2] == value)) {
228 for (
unsigned int i = 0; i < I.
getHeight(); i++) {
229 for (
unsigned int j = 0; j < I.
getWidth(); j++) {
230 if (J[i+1][j+1] == value_out) {
232 if ((J[i][j] == value) ||
233 (J[i][j+1] == value) ||
234 (J[i][j+2] == value) ||
235 (J[i+1][j] == value) ||
236 (J[i+1][j+2] == value) ||
237 (J[i+2][j] == value) ||
238 (J[i+2][j+1] == value) ||
239 (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.