실제 활용

Python으로 배우는 이미지 처리

Rebeca Gonzalez

Data engineer

활용 분야

  • 가장자리/코너 검출 전 그레이스케일 변환
  • 노이즈 감소 및 이미지 복원
  • 검출된 얼굴 흐림 처리
  • 객체 크기 근사값 추정

Python으로 배우는 이미지 처리

개인정보 보호

Python으로 배우는 이미지 처리

개인정보 보호

# Import Cascade of classifiers and gaussian filter
from skimage.feature import Cascade

from skimage.filters import gaussian
Python으로 배우는 이미지 처리

개인정보 보호

# Detect the faces
detected = detector.detect_multi_scale(img=image, 
                                       scale_factor=1.2, step_ratio=1, 
                                       min_size=(50, 50), max_size=(100, 100))

# For each detected face for d in detected: # Obtain the face cropped from detected coordinates face = getFace(d)
Python으로 배우는 이미지 처리

개인정보 보호

def getFace(d):
    ''' Extracts the face rectangle from the image using the
    coordinates of the detected.'''
    # X and Y starting points of the face rectangle
    x, y  = d['r'], d['c']

# The width and height of the face rectangle width, height = d['r'] + d['width'], d['c'] + d['height']
# Extract the detected face face= image[x:width, y:height] return face
Python으로 배우는 이미지 처리

개인정보 보호

# Detect the faces
detected = detector.detect_multi_scale(img=image, 
                                       scale_factor=1.2, step_ratio=1, 
                                       min_size=(50, 50), max_size=(100, 100))

# For each detected face for d in detected: # Obtain the face cropped from detected coordinates face = getFace(d)
# Apply gaussian filter to extracted face gaussian_face = gaussian(face, multichannel=True, sigma = 10)
# Merge this blurry face to our final image and show it resulting_image = mergeBlurryFace(image, gaussian_face)
Python으로 배우는 이미지 처리

개인정보 보호

def mergeBlurryFace(original, gaussian_image):
    # X and Y starting points of the face rectangle
    x, y  = d['r'], d['c']
    # The width and height of the face rectangle
    width, height = d['r'] + d['width'],  d['c'] + d['height']

    original[ x:width, y:height] =  gaussian_image
    return original
Python으로 배우는 이미지 처리

개인정보 보호

Python으로 배우는 이미지 처리

추가 사례

Python으로 배우는 이미지 처리

연습해 봅시다!

Python으로 배우는 이미지 처리

Preparing Video For Download...