image_output_1.png
from skimage.filters import gaussian

import cv2

import h5py

import matplotlib.pyplot as plt

import numpy as np

import random

event = h5py.File('../input/insar-dataset/insar_data_event.hdf5', 'r')

disp = np.zeros(shape=(16000, 40, 40))
sim = np.zeros(shape=(16000, 9, 40, 40, 1))
topo = np.zeros(shape=(16000, 1, 40, 40, 1))

for i in range(len(event.keys())):
    for j in range(100):
        disp[i * 100 + j] = np.array(event['event{}'.format(i)]['displacement'])
        sim[i * 100 + j] = np.array(event['event{}'.format(i)]['simulation'])
        topo[i * 100 + j] = np.array(event['event{}'.format(i)]['topography'])

for i in range(100):
    ind = random.randint(0, 15999)
    img = disp[ind]

for i in range(100):
    ind = random.randint(0, 15999)
    img = sim[ind][1]

img2 = np.expand_dims(sim[0][1], axis=2)

img = np.broadcast_to(sim[0][1], (40, 40, 3)).copy()

img_gaussian_opencv = cv2.GaussianBlur(sim[0][1], (3,3), 0, borderType=cv2.BORDER_CONSTANT)
#plt.imshow(img_gaussian_opencv)
fig, axes = plt.subplots(ncols=2, figsize=(15,5))
axes[0].imshow(sim[0][1], label="label")
axes[1].imshow(img_gaussian_opencv)

axes[0].set_title("noised")
axes[1].set_title("denoised")
plt.show()

img_median_opencv = cv2.medianBlur(sim[0][1].reshape(40,40), 1)
#plt.imshow(img_median_opencv)
fig, axes = plt.subplots(ncols=2, figsize=(15,5))
axes[0].imshow(sim[0][1], label="label")
axes[1].imshow(img_median_opencv)

axes[0].set_title("noised")
axes[1].set_title("denoised")
plt.show()

img = cv2.cvtColor(np.array(sim[0][1], dtype='ubyte'), cv2.COLOR_BGR2RGB)
image_bilateral_opencv = cv2.bilateralFilter(img, 5, 40, 100, borderType=cv2.BORDER_CONSTANT)

img_gaussian_scikit = gaussian(sim[0][1], sigma=1, mode='constant', cval=0)
plt.imshow(img_gaussian_scikit)
fig, axes = plt.subplots(ncols=2, figsize=(15, 5))
axes[0].imshow(sim[0][1], label='label')
axes[1].imshow(img_gaussian_scikit)
axes[0].set_title('noised')
axes[1].set_title('denoised')
plt.show()