影像修復

Python 影像處理

Rebeca Gonzalez

Data Engineer

還原影像

Python 影像處理

影像重建

  • 修補受損影像
  • 去除文字
  • 去除商標
  • 去除物件

Python 影像處理

影像重建

修補(Inpainting)
  • 重建遺失影像區塊
  • 參考未受損區域

Python 影像處理

影像重建

Python 影像處理

在 scikit-image 進行影像重建

from skimage.restoration import inpaint

# 取得遮罩 mask = get_mask(defect_image)
# 使用遮罩對受損影像進行修補 restored_image = inpaint.inpaint_biharmonic(defect_image, mask, multichannel=True)
# 顯示結果影像 show_image(restored_image)
Python 影像處理

在 scikit-image 進行影像重建

# 顯示受損與修復後影像
show_image(defect_image, 'Image to restore')
show_image(restored_image, 'Image restored')

Python 影像處理

遮罩(Masks)

Python 影像處理

遮罩(Masks)

def get_mask(image):
    ''' Creates mask with three defect regions '''
    mask = np.zeros(image.shape[:-1])

    mask[101:106, 0:240] = 1

    mask[152:154, 0:60] = 1
    mask[153:155, 60:100] = 1
    mask[154:156, 100:120] = 1
    mask[155:156, 120:140] = 1

    mask[212:217, 0:150] = 1
    mask[217:222, 150:256] = 1
    return mask
Python 影像處理

一起來練習吧!

Python 影像處理

Preparing Video For Download...