2 Answers
JW270.00
3

There is another option for it. You can do it by using the max-pooling operation of Tensorflow and it does not have to be of version 2. Here is how you can do it.

erosion = -tf.nn.max_pool2d(-x, ksize=(k, k), stride=1, name='erosion2D')
dilation = tf.nn.max_pool2d(x, ksize=(k, k), stride=1, name='dilation2D')

It is a short way to have dilation and erosion in Tensorflow overall.

Reply
JO242.00
1

There are 2 implementations in Tensorflow for erosion and dilation in 2D.

tf.nn.erosion2d(
    value,
    filters,
    strides,
    padding,
    data_format,
    dilations,
    name=None
)

tf.nn.dilation2d(
    input,
    filters,
    strides,
    padding,
    data_format,
    dilations,
    name=None
)

The official doc of this implementation is written in Tensorflow 2.*, but I believe it will work in Tensorflow 1.* as well. Here are the links of tf.nn.erosion2d and tf.nn.dilation2d.

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?