38 #define min(a,b) ((a)>(b) ? (b) : (a))
39 #define max(a,b) ((a)>(b) ? (a) : (b))
46 for (y = 2 ; y < height -2 ; ++y) {
47 for (
x = 2;
x < width - 2;
x++) {
48 img_out[y][
x] =
max(
max(
max(
max(img[y][
x-2], img[y][
x-1]), img[y][
x]), img[y][
x+1]), img[y][
x+2]);
55 for (y = 2 ; y < height -2 ; ++y) {
56 for (
x = 2;
x < width - 2;
x++) {
57 img_out[y][
x] =
max(
max(
max(
max(img[y-2][
x], img[y-1][
x]), img[y][
x]), img[y+1][
x]), img[y+2][
x]);
64 for (y = 2 ; y < height -2 ; ++y) {
65 for (
x = 2;
x < width - 2;
x++) {
66 img_out[y][
x] =
min(
min(
min(
min(img[y][
x-2], img[y][
x-1]), img[y][
x]), img[y][
x+1]), img[y][
x+2]);
73 for (y = 2 ; y < height -2 ; ++y) {
74 for (
x = 2;
x < width - 2;
x++) {
75 img_out[y][
x] =
min(
min(
min(
min(img[y-2][
x], img[y-1][
x]), img[y][
x]), img[y+1][
x]), img[y+2][
x]);
80 void erode(
int width,
int height,
type_t img_in[width][height],
type_t img_scratch[width][height],
type_t img_out[width][height]) {
85 void dilate(
int width,
int height,
type_t img_in[width][height],
type_t img_scratch[width][height],
type_t img_out[width][height]) {
void erode_1d_v(struct image *img, struct image *img_out)
void erode_1d_h(int width, int height, type_t img[width][height], type_t img_out[width][height])
void dilate_1d_h(int width, int height, type_t img[width][height], type_t img_out[width][height])
void dilate(int width, int height, type_t img_in[width][height], type_t img_scratch[width][height], type_t img_out[width][height])
void dilate_1d_v(struct image *img, struct image *img_out)
void erode(int width, int height, type_t img_in[width][height], type_t img_scratch[width][height], type_t img_out[width][height])
code taken from http://fast-edge.googlecode.com and adapted to c99