This forum thread from an active Kaggle competition mentions something the author calls a "reflective center pad". Basically this is a transformation that takes the edges of the image and reflects them outwards, causing mirroring on the edges of the image, which the author shows slightly but noticeably improves model performance.
For reference, here is the image they post demonstrating this technique:

My question is twofold:
numpy and something like skimage?Does this transformation have a canonical name? "Reflective center pad" sounds unofficial.
"Symmetric padding" is a commonly used expression to refer to this transformation.
What's a simple way of expressing this transformation in code
I think the simplest way to achieve that would be using Numpy's pad with mode='symmetric'.
import numpy as np
from skimage import data
import matplotlib.pyplot as plt
img = data.astronaut()
padded = np.pad(img, pad_width=((100, 200), (100, 500), (0, 0)), mode='symmetric')
fig, (ax1, ax2) = plt.subplots(2, 1)
ax1.imshow(img)
ax2.imshow(padded)
fig.show()

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With