영상 데이터의 처리와 정보추출
이동윤
LG CNS
Advanced Analytics Center
빅데이터에서의 영상 데이터
• 영상 데이터를 정형 데이터처럼 다룰 필요성 ↑
http://www.datanami.com/2012/12/24/how_object_storage_and_information_dispersal_address_big_data_challenges/
강연자 소개
• 컴퓨터비젼, 패턴인식 전공 (석사)
• 산업계 경력 11년차
– 삼성전자 반도체연구소
• 컴퓨터비젼, 빅 데이터 (CAD)
– LG CNS 고급분석 센터
• 컴퓨터비젼, 고급분석/예측
• 페이스북 컴퓨터비젼/
패턴인식/머신러닝 그룹 관리자
(neuralix@gmail.com)
www.facebook.com/groups/cvprml
(>2,200명)
※ iPad 1, iPhone 5GS 두 모델의 개발, 제조에 참여했으며
본 강의의 내용+a가 그에 적용되었음
영상 데이터로부터의 정보추출
• 컴퓨터비젼
어떤 종류의 장면인가?
자동차가 어디에 있는가?
건물이 얼마나 멀리 있는가?
:
※ 영상으로부터 ‘정보’를 추출하는 것을 목적으로 삼아 온 공학/과학 분과
(“영상만을 보고 이해하는 컴퓨터의 실현”)
컴퓨터비젼 응용사례
http://www.theguardian.com/technology/2012/sep/30/google-self-driving-car-unemployment
http://edn.com/electronics-blogs/automotive-innovation/4402800/Self-driving-car-pushes-sensor-technology
• 구글 자동운전 자동차
※ 비디오 카메라 뿐 아니라 레이저를 이용한 LIDAR,
전파를 이용하는 RADAR에도 본 자료 내의 기술이 적용됨
이 강연에서…
• Data Type
– Image (O)
– Video (X)
• Language
– Python (2.7.X)
• Library (패키지)
– scikit-image
NOT
• GPU(CUDA), 3D, 얼굴인식,
머신러닝 관련기술,
주파수 영역분석
※ 컴퓨터비전 기술의 시도와 활용을
극히 쉽게 만들어줌
영상 인지의 특성
• Digitizing
Figure Credit : Amin Allalou
※ 가상의 격자. 이 격자로 인해 원하지 않게 문제점이 발생하기도 함
영상 인지의 특성
• 영상좌표계
Figure Credit : Alex Lin
1. 좌측상단이 원점 2. 좌표계 관례 확인 필요
영상 인지의 특성
• 256 단계 픽셀
Figure Credit : Ruye Wang
Weber-Fechner law
“한 자극의 다음 자극은 훨씬 더 커야 한다” (지수적 증가)
모든 종류의 감각자극이 이 법칙을 따름
영상 파일 포맷
• 주요 영상 파일 포맷 설명
데이터의 손실 데이터 용량 인지적 우수성 특성
BMP
無
큼
(용량고정)
N/A
색 재현성 우수, Windows OS용
TIFF 투명도 고려 가능, 가장 선호됨
PNG 위 둘보다 헤더 구조가 단순
GIF
有
작음 낮음
경계선이 부드러움, 동영상처럼
만들 수 있음(:모션 GIF)
JPG 매우 작음 매우 우수
데이터 용량이 가장 작아 네트워
크에서의 전송에 유리함
차 례
• Basic Processing
• Region Processing
• Edge/Contour
• Point/Line/Corner
• Matching
• Preprocessing
• Color
※ 내용이 어려워지는 순서
Basic Processing
“이것만 하면 다 할 수 있다.”
(단, 전문가라면...)
Load/Save and Display
• PIL (Python Image Library)
– Import Module
– Load
– Display
– Save
>> from PIL import Image
>> from pylab import *
>> Img = Image.fromarray(img)
>> Img.save('C:mandrill_new.bmp')
>> img = array(Image.open('C:mandrill.bmp'))
>> imshow(img)
코드 안내
• 그래픽 출력용 모듈인 matplotlib와 그 서브모듈인 pylab은 임포트
를 생략함
• numpy의 경우 생략
• 각 장에서, 이미 앞 부분에서 설명된 처리를 위한 모듈의 경우 임포
트가 생략되었을 수 있음
• 코드 내용의 자료 기입 이후의 수정으로 일부 비작동 사례 있을 수
있음 ( 발견 시, neuralix@gmail.com 로 inform 요망 )
Load/Save and Display
• skimage
>> from skimage import io
>> io.imsave( filename, logo )
>> imshow( img )
• opencv
>> import numpy as np
>> import cv2
>> cv2.imwrite( filename, img)
>> cv2.imshow('image', img)
>> camera = io.imread( filename ) >> img = cv2.imread( filename, 0 )
※ URL의 입력도 가능
Pixel Operation
• Get pixel value
• Put Pixel Value
• Area Operation
>> print img[ i ][ j ][ k ]
for i in range(img.shape[0]):
for j in range(img.shape[1]):
for k in range(img.shape[2]):
if i>=200 and i<300:
if j>=200 and j<300:
img[i][j][k] = 0 * img[i][j][k]
>> img[ i ][ j ][ k ] = 0
>> img[200:300][200:300] = 
0 * img[200:300][200:300]
or Simply,
Line Drawing
• DDA (Digital Differential Analyzer)
>> from skimage.draw import line, set_color
>> rr, cc = line(x1, y1, x2, y2)
>> set_color(img, (rr, cc), 1)
>> imshow(img)
※ 가장 단순한 선긋기 방법
Polygon Drawing
• 다각형 그리기
>> from skimage.draw import polygon
>> img = np.zeros((width, height), dtype=np.uint8)
>> x = np.array([x1, x2, x3, x4, …])
>> y = np.array([y1, y2, y3, y4, …])
>> rr, cc = polygon(y, x)
>> img[rr, cc] = 1
Picking Points (“ginput”)
• 클릭한 지점의 좌표를 배열로 리턴
>> from PIL import Image
>> from pylab import *
>> img = array(Image.open('C:mandrill.bmp'))
>> imshow(img)
>> print 'Please click 3 points'
>> x = ginput(3)
>> print 'you clicked:',x
>> show()
>> x
you clicked: [(16.737903225806448, 18.705645161
290249), (406.85887096774195, 23.2419354838709
18), (227.22177419354841, 242.79838709677415)]
※ 이름의 유래는 MATLAB의 함수 이름
(Graphical INPUT)에서.
워낙 많이 쓰이고 편리하여 보통명사처럼 됨.
Region Processing
※ 영역의 추출과 처리
Thresholding (Binarizing)
• Otsu’s (Automatic) Thresholding
>> from skimage import data
>> from skimage.filter import threshold_otsu, 
threshold_adaptive
>> from skimage import color
>> img = io.imread('C:Mandrill.bmp')
>> img_g = color.rgb2grey(img)
>> val_thresh = threshold_otsu(img_g)
>> img_bw = im_g > val_thresh
>> io.imshow( img_bw )
Figure Credit : https://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch7/functn_ComputeThreshold_Otsu.html
“Blob”
Labeling
• Connected Components Labeling
http://engineersphere.com/biomedical-engineering/biomedical-image-processing-iii.html
>> from skimage.morphology import label, closing, square
>> from skimage.color import label2rgb
…
>> val_thresh = threshold_otsu(img)
>> img_label = label(val_thresh)
>> image_label_rgb = label2rgb(label_image)
>> imshow(image_label_rgb)
※ Check neighborhood convention first!
(8-neighborhood is complete, 4-neighbor is not.)
Morphological Operation
http://www.dspguide.com/ch25/4.htm
>> from skimage.morphology import erosion, dilation, opening, closing, white_tophat
>> from skimage.morphology import black_tophat, skeletonize, convex_hull_image
>> from skimage.morphology import disk
…
>> selem = disk(6)
>> img_eroded = erosion(img, selem)
>> imshow(img_eroded, cmap=plt.cm.gray)
>> img_dilated = dilation(img, selem)
>> imshow(img_dilated, cmap=plt.cm.gray)
https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic4.htm
• 1) 블랍을 <뚱뚱하게/날씬하게>, 2) 서로 다른 블랍을 <붙게/떨어뜨
리게>, 3) <구멍을 메우게/돌출부를 평평하게>
※ Structuring element
(:selem)의 모양과 크기
에 의해 조정됨
※ LIDAR/RADAR 데이
터의 처리에서 중요
Boolean Operation
• Image Boolean Operations
Flood Fill
• Filling the holes
>> from scipy import ndimage
>> from skimage.filter import canny
>> img_edges = canny(img/255.)
>> img_filled = ndimage.binary_fill_holes(img_edges)
Segmentation
• Mean Shift
>> import cv2
>> import pymeanshift as pms
>> img_orig = cv2.imread("example.png")
>>(img_segmented, img_label, number_regions) = 
pms.segment(img_orig, spatial_radius=6, 
range_radius=4.5, min_density=50)
https://code.google.com/p/pymeanshift/
※ 구획화(Segmentation)는 경계를 인지, 이용
하는 방향과 내부 유사성을 인지, 이용하는 두
계열이 있음. GraphCuts, GrabCuts는 전자,
Mean Shift(:Moving Averaging)은 후자,
Chan’s Active Contour without Edges는 둘을
모두 추구함
Edge / Contour
※ 임의의 선, 곡선들
Skeletonization
• Skeletonization
http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm
>> from skimage.morphology import skeletonize
>> img_skeleton = skeletonize(image)
>> imshow(img_skeleton, cmap=plt.cm.gray)
Contour Finding
• Contour Finding
>> import numpy as np
>> import matplotlib.pyplot as plt
>> from skimage import measure
>> x, y = np.ogrid[-np.pi:np.pi:100j, -np.pi:np.pi:100j]
>> r = np.sin(np.exp((np.sin(x)**3 + np.cos(y)**2)))
>> contours = measure.find_contours(r, 0.8)
>> fig, ax = plt.subplots()
>> ax.imshow(r, interpolation='nearest', cmap=plt.cm.gray)
>> for n, contour in enumerate(contours):
ax.plot(contour[:, 1], contour[:, 0], linewidth=2)
>> plt.show()
※ 콘투어의 각 점들을 배열로 추출해줌
Edge Detection (1of2)
• Canny Edge Detection
>> import numpy as np
>> import matplotlib.pyplot as plt
>> from scipy import ndimage
>> from skimage import filter
>> img_edges = filter.canny(img, sigma=3)
>> imshow(img_edges, cmap=plt.cm.gray)
※ 콘투어가 전체에서 동일한 값인 지점을 주는 것이라
면 에지는 국소적인 조사로 최적경계를 찾으므로 대개
의 경우에 더 효과적임 (1차미분과 유사함).
※ 위의 경우는 Thresholding 후 에지 검출이 가능
Edge Detection (2of2)
• Canny Edge Detection
http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MARBLE/low/edges/canny.htm
http://news.mynavi.jp/photo/series/computer_vision/040/images/014l.jpg
http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm
※ 에지 검출 기법의 대명사와 같음 (“Canny”)
Point / Line / Corner
Hough Transform (1of2)
• Hough Transform
http://docs.opencv.org/modules/imgproc/doc/feature_detection.html
Hough Transform (2of2)
• Hough Transform
http://www.aiaa-daycin.org/node/430
http://campar.in.tum.de/Students/DaPentenrieder
>>from skimage.transform import (hough_line, hough_l
ine_peaks, probabilistic_hough_line)
>> edges = canny(image, 2, 1, 25)
>> lines = probabilistic_hough_line(edges, threshold=
10, line_length=5, line_gap=3)
>> for line in lines:
p0, p1 = line
plt.plot((p0[0], p1[0]), (p0[1], p1[1]))
>> plt.show()
※ rho, theta 평면의 한 지점은 x, y 평면의 하나
의 직선에 대응함
※ 두 점을 잇는 모든 직선을 rho, theta 평면에서
voting하여 피크지점을 추출하여 직선을 추정함
Corner Detection (1of2)
• Harris Corner Detection
http://www.krankerkaktus.de/Portfolio/GraphicsProgramming
https://www.ee.iitb.ac.in/~sumantra/courses/ip/assignment_1.html
>> from skimage.feature import corner_harris, corner
_subpix, corner_peaks
>> coords = corner_peaks(corner_harris(image), min_
distance=5)
>> coords_subpix = corner_subpix(image, coords, win
dow_size=13)
>> fig, ax = plt.subplots()
>> ax.imshow(image, interpolation='nearest', cmap=p
lt.cm.gray)
>> ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3)
>> ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r',
markersize=15)
>> ax.axis((0, 350, 350, 0))
>> plt.show()
Corner Detection (2of2)
• Harris Corner Detection
http://www.mathworks.co.kr/kr/help/images/detect-corners-in-images.html
http://miac.unibas.ch/BIA/05-LandmarkBasedRegistration.html
※ 사각형 영역을 조사해보아 주성분분석을 하였을 때,
최대값인 아이겐밸류 lambda 1, 2가 모두 0보다 꽤 크
고, 서로간에 값이 비슷하면 Corner라 판단해도 좋다.
Matching / Registration
Image Matching
• Template Matching
>>import numpy as np
>>import matplotlib.pyplot as plt
>>from skimage import data
>>from skimage.feature import match_template
>>result = match_template( img_whole, img_template )
Noise Suppression
• Denoising
• Median
>> from skimage import data, img_as_float
>> from skimage.restoration import denoise_tv_ch
ambolle, denoise_bilateral
…
>> imshow(denoise_bilateral(img, sigma_range=0.1,
sigma_spatial=15))
>> from skimage.morphology import disk
>> from skimage.filter.rank import median
…
>> img_med = median(img, disk(5))
Contrast
• Histogram Equalizing
>> from skimage import exposure
…
>> img_eq = exposure.equalize_hist(img)
Figure Credit : James Fishbaugh
※ 히스토그램 변환규칙을 만들고 그 히스토그램을 참고해 모든 픽셀의 값을 변경함. 여러
기법 중 히스토그램 이퀄라이징은 CDF가 강제로 직선이도록 변환규칙을 만들고 이를 따르
도록 하여 매 영상마다 최적에 가깝게 콘트라스트를 개선함.
Rotation
• Rotation with Interpolation
http://www.darktable.org/2012/06/upcoming-features-new-interpolation-modes-and-better-resize/dt-rotation-grid/
>> from skimage.transform import rotate
…
>> img = rotate(img, 90, resize=True).shape
>> import numpy as np
…
>> coord_center = tuple(np.array(image.shape)/2)
>> rot_mat = cv2.getRotationMatrix2D(coord_center,angle,1.0)
>> result = cv2.warpAffine(image, rot_mat, image.shape,flags=cv2.I
NTER_LINEAR)
※ 모든 rotation과 resizing은 격자 불일치를 초래해 interpolation에 의한 보정을 필
요로 함. Skimage는 이의 정밀한 보정에서 아직 빈약하여 opencv를 권장. 이때 ima
ge.shape,flags 변수의 적절한 설정이 필요함.
Color (1of3)
• RGB  Grey
Luminousity
(Grey Value)
Average LightnessOriginal
(Color)
Figure Credit : Hohn D. Cook (http://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/)
>> from skimage.color import rgb2gray
>> from skimage import data
…
>> img_gray = rgb2gray(img) // Luminousity
Color (2of3)
• Radiometry  Photometry  Colorimetry
http://www.screentekinc.com/resource-center/photometry-and-colorimetry.shtml
http://www.chromapure.com/products-d3pro.asp
Color (3of3)
• Color Space
http://en.wikipedia.org/wiki/File:RGB_sliders.svg
https://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html
※ 슬라이드에서는 1이 255에 해당
※ RGB와 CMY는 반대
(Cyan: R=0, G=255, B=255)
Kalman Filter
(linear quadratic estimation)
Kalman Filtering
• Kalman Filtering
# Kalman filter example demo in Python
# A Python implementation of the example given in pages 11-15 of "An
# Introduction to the Kalman Filter" by Greg Welch and Gary Bishop,
# University of North Carolina at Chapel Hill, Department of Computer
# Science, TR 95-041,
# http://www.cs.unc.edu/~welch/kalman/kalmanIntro.html
# by Andrew D. Straw
import numpy
import pylab
# intial parameters
n_iter = 50
sz = (n_iter,) # size of array
x = -0.37727 # truth value (typo in example at top of p. 13 calls this z)
z = numpy.random.normal(x,0.1,size=sz) # observations (normal about x, sigma=0.1)
Q = 1e-5 # process variance
# allocate space for arrays
xhat=numpy.zeros(sz) # a posteri estimate of x
P=numpy.zeros(sz) # a posteri error estimate
xhatminus=numpy.zeros(sz) # a priori estimate of x
Pminus=numpy.zeros(sz) # a priori error estimate
K=numpy.zeros(sz) # gain or blending factor
R = 0.1**2 # estimate of measurement variance, change to see effect
# intial guesses
xhat[0] = 0.0
P[0] = 1.0
for k in range(1,n_iter):
# time update
xhatminus[k] = xhat[k-1]
Pminus[k] = P[k-1]+Q
# measurement update
K[k] = Pminus[k]/( Pminus[k]+R )
xhat[k] = xhatminus[k]+K[k]*(z[k]-xhatminus[k])
P[k] = (1-K[k])*Pminus[k]
pylab.figure()
pylab.plot(z,'k+',label='noisy measurements')
pylab.plot(xhat,'b-',label='a posteri estimate')
pylab.axhline(x,color='g',label='truth value')
pylab.legend()
pylab.xlabel('Iteration')
pylab.ylabel('Voltage')
pylab.figure()
valid_iter = range(1,n_iter) # Pminus not valid at step 0
pylab.plot(valid_iter,Pminus[valid_iter],label='a priori error estimate')
pylab.xlabel('Iteration')
pylab.ylabel('$(Voltage)^2$')
pylab.setp(pylab.gca(),'ylim',[0,.01])
pylab.show()
http://wiki.scipy.org/Cookbook/KalmanFiltering
※ z : 노이즈가 가미된 입력
xhat : 추정된 출력
※ “뉴튼 물리학과 칼만 필터로 인간을 달에 보냈다.” (NASA)
“Stanley는 모든게 칼만 필터였다.” (세바스찬 스런)
※ 시계열 데이터의 예측과
평활화에 적용
부가자료
• 파이썬용 Package, Tools
– Anaconda Distribution https://store.continuum.io/cshop/anaconda
※ opencv, scikit-image, spyder를 모두 담음
– Scikit-Image Package
• http://scikit-image.org
• http://scikit-image.org/docs/dev/auto_examples
– Pycharm IDE http://www.jetbrains.com/pycharm
– 기타 Spyder IDE, iPython QTConsole, Sublime Text 2 등
• 책 (국내 및 번역서)
– http://book.naver.com/bookdb/book_detail.nhn?bid=6191572
– http://book.naver.com/bookdb/book_detail.nhn?bid=6802764
– http://book.naver.com/bookdb/book_detail.nhn?bid=6332184
– http://kangcom.com/sub/view.asp?sku=200311040002 (컬러)
• 책 (원서)
– http://www.amazon.com/Machine-Vision-Ramesh-Jain/dp/0070320187
– http://www.amazon.com/Computer-Vision-Algorithms-Applications-
Science/dp/1848829345/ref=sr_1_1?s=books&ie=UTF8&qid=1401379429&sr=1-
1&keywords=szeliski+computer+vision
끝

More Related Content

DOCX
SINTAKSIS PPG SEM 5
PPTX
Typography 1510598 박수진 (1)
PDF
소프트웨어 마케팅 전략
PPTX
Kepentingan kemahiran menulis
DOCX
apa itu papan cerita
PDF
딥러닝의 기본
PDF
UX Academy 18th 네이버 쇼핑 UX/UI 개선 프로젝트
PDF
스마일게이트 서버개발캠프 - 5vengers
SINTAKSIS PPG SEM 5
Typography 1510598 박수진 (1)
소프트웨어 마케팅 전략
Kepentingan kemahiran menulis
apa itu papan cerita
딥러닝의 기본
UX Academy 18th 네이버 쇼핑 UX/UI 개선 프로젝트
스마일게이트 서버개발캠프 - 5vengers

Viewers also liked (20)

PDF
PyCon 2017 프로그래머가 이사하는 법 2 [천원경매]
PDF
Docker
PDF
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
PDF
자동화된 소스 분석, 처리, 검증을 통한 소스의 불필요한 #if - #endif 제거하기 NDC2012
PDF
8년동안 테라에서 배운 8가지 교훈
PDF
Approximate nearest neighbor methods and vector models – NYC ML meetup
PDF
김병관 성공캠프 SNS팀 자원봉사 후기
PDF
Online game server on Akka.NET (NDC2016)
PDF
Custom fabric shader for unreal engine 4
PDF
Behavior Tree in Unreal engine 4
PDF
Re:Zero부터 시작하지 않는 오픈소스 개발
PDF
Developing Success in Mobile with Unreal Engine 4 | David Stelzer
PDF
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
PPTX
Deep learning as_WaveExtractor
PDF
Profiling - 실시간 대화식 프로파일러
PDF
게임회사 취업을 위한 현실적인 전략 3가지
PDF
Luigi presentation NYC Data Science
PDF
NDC16 스매싱더배틀 1년간의 개발일지
PDF
NDC17 게임 디자이너 커리어 포스트모템: 8년, 3개의 회사, 4개의 게임
PDF
버텍스 셰이더로 하는 머리카락 애니메이션
PyCon 2017 프로그래머가 이사하는 법 2 [천원경매]
Docker
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
자동화된 소스 분석, 처리, 검증을 통한 소스의 불필요한 #if - #endif 제거하기 NDC2012
8년동안 테라에서 배운 8가지 교훈
Approximate nearest neighbor methods and vector models – NYC ML meetup
김병관 성공캠프 SNS팀 자원봉사 후기
Online game server on Akka.NET (NDC2016)
Custom fabric shader for unreal engine 4
Behavior Tree in Unreal engine 4
Re:Zero부터 시작하지 않는 오픈소스 개발
Developing Success in Mobile with Unreal Engine 4 | David Stelzer
레퍼런스만 알면 언리얼 엔진이 제대로 보인다
Deep learning as_WaveExtractor
Profiling - 실시간 대화식 프로파일러
게임회사 취업을 위한 현실적인 전략 3가지
Luigi presentation NYC Data Science
NDC16 스매싱더배틀 1년간의 개발일지
NDC17 게임 디자이너 커리어 포스트모템: 8년, 3개의 회사, 4개의 게임
버텍스 셰이더로 하는 머리카락 애니메이션
Ad

Similar to 영상 데이터의 처리와 정보의 추출 (20)

PDF
c++ opencv tutorial
PPTX
호서대학교 - 다양한 오픈소스 활용법 (Colab을 이용하여)
PDF
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
PPTX
2015 제2회 동아리 해커 세미나 - 병렬컴퓨팅 소개 (16기 김정현)
PDF
7가지 동시성 모델 - 데이터 병렬성
PPTX
투명화 처리로 살펴 본 한층 고급화된 모바일 UX
PPTX
Python 활용: 이미지 처리와 데이터 분석
PPTX
[0326 박민근] deferred shading
PDF
모바일 앱 성능 분석 방법 101 (Mobile Application Performance Analysis Methodology 101)
PPTX
Human Pose Estimation 기술 습득과 메타버스 서비스 개발
PPTX
썬소프트 "드론을 이용한 실시간 폭력 개인 식별 시스템"재직자교육 강의안
PPTX
[박민근] 3 d렌더링 옵티마이징_2
PDF
자료구조05
PDF
자료구조05
PPTX
[Ndc11 박민근] deferred shading
PDF
[Let's Swift 2019] iOS 앱에서 머신러닝이 해결 할 수 있는 문제들
PPTX
11_빠른 개발 가능한 레벨 편집 시스템
PPTX
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
PDF
NDC 2017 하재승 NEXON ZERO (넥슨 제로) 점검없이 실시간으로 코드 수정 및 게임 정보 수집하기
PDF
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
c++ opencv tutorial
호서대학교 - 다양한 오픈소스 활용법 (Colab을 이용하여)
이미지 프로세싱 in Python Open Source - PYCON KOREA 2020
2015 제2회 동아리 해커 세미나 - 병렬컴퓨팅 소개 (16기 김정현)
7가지 동시성 모델 - 데이터 병렬성
투명화 처리로 살펴 본 한층 고급화된 모바일 UX
Python 활용: 이미지 처리와 데이터 분석
[0326 박민근] deferred shading
모바일 앱 성능 분석 방법 101 (Mobile Application Performance Analysis Methodology 101)
Human Pose Estimation 기술 습득과 메타버스 서비스 개발
썬소프트 "드론을 이용한 실시간 폭력 개인 식별 시스템"재직자교육 강의안
[박민근] 3 d렌더링 옵티마이징_2
자료구조05
자료구조05
[Ndc11 박민근] deferred shading
[Let's Swift 2019] iOS 앱에서 머신러닝이 해결 할 수 있는 문제들
11_빠른 개발 가능한 레벨 편집 시스템
[NDC14] 라이브중인 2D게임에 시스템 변경 없이 본 애니메이션 도입하기[던전앤파이터]
NDC 2017 하재승 NEXON ZERO (넥슨 제로) 점검없이 실시간으로 코드 수정 및 게임 정보 수집하기
파이썬 데이터과학 레벨2 - 데이터 시각화와 실전 데이터분석, 그리고 머신러닝 입문 (2020년 이태영)
Ad

영상 데이터의 처리와 정보의 추출

  • 1. 영상 데이터의 처리와 정보추출 이동윤 LG CNS Advanced Analytics Center
  • 2. 빅데이터에서의 영상 데이터 • 영상 데이터를 정형 데이터처럼 다룰 필요성 ↑ http://www.datanami.com/2012/12/24/how_object_storage_and_information_dispersal_address_big_data_challenges/
  • 3. 강연자 소개 • 컴퓨터비젼, 패턴인식 전공 (석사) • 산업계 경력 11년차 – 삼성전자 반도체연구소 • 컴퓨터비젼, 빅 데이터 (CAD) – LG CNS 고급분석 센터 • 컴퓨터비젼, 고급분석/예측 • 페이스북 컴퓨터비젼/ 패턴인식/머신러닝 그룹 관리자 (neuralix@gmail.com) www.facebook.com/groups/cvprml (>2,200명) ※ iPad 1, iPhone 5GS 두 모델의 개발, 제조에 참여했으며 본 강의의 내용+a가 그에 적용되었음
  • 4. 영상 데이터로부터의 정보추출 • 컴퓨터비젼 어떤 종류의 장면인가? 자동차가 어디에 있는가? 건물이 얼마나 멀리 있는가? : ※ 영상으로부터 ‘정보’를 추출하는 것을 목적으로 삼아 온 공학/과학 분과 (“영상만을 보고 이해하는 컴퓨터의 실현”)
  • 6. 이 강연에서… • Data Type – Image (O) – Video (X) • Language – Python (2.7.X) • Library (패키지) – scikit-image NOT • GPU(CUDA), 3D, 얼굴인식, 머신러닝 관련기술, 주파수 영역분석 ※ 컴퓨터비전 기술의 시도와 활용을 극히 쉽게 만들어줌
  • 7. 영상 인지의 특성 • Digitizing Figure Credit : Amin Allalou ※ 가상의 격자. 이 격자로 인해 원하지 않게 문제점이 발생하기도 함
  • 8. 영상 인지의 특성 • 영상좌표계 Figure Credit : Alex Lin 1. 좌측상단이 원점 2. 좌표계 관례 확인 필요
  • 9. 영상 인지의 특성 • 256 단계 픽셀 Figure Credit : Ruye Wang Weber-Fechner law “한 자극의 다음 자극은 훨씬 더 커야 한다” (지수적 증가) 모든 종류의 감각자극이 이 법칙을 따름
  • 10. 영상 파일 포맷 • 주요 영상 파일 포맷 설명 데이터의 손실 데이터 용량 인지적 우수성 특성 BMP 無 큼 (용량고정) N/A 색 재현성 우수, Windows OS용 TIFF 투명도 고려 가능, 가장 선호됨 PNG 위 둘보다 헤더 구조가 단순 GIF 有 작음 낮음 경계선이 부드러움, 동영상처럼 만들 수 있음(:모션 GIF) JPG 매우 작음 매우 우수 데이터 용량이 가장 작아 네트워 크에서의 전송에 유리함
  • 11. 차 례 • Basic Processing • Region Processing • Edge/Contour • Point/Line/Corner • Matching • Preprocessing • Color ※ 내용이 어려워지는 순서
  • 12. Basic Processing “이것만 하면 다 할 수 있다.” (단, 전문가라면...)
  • 13. Load/Save and Display • PIL (Python Image Library) – Import Module – Load – Display – Save >> from PIL import Image >> from pylab import * >> Img = Image.fromarray(img) >> Img.save('C:mandrill_new.bmp') >> img = array(Image.open('C:mandrill.bmp')) >> imshow(img)
  • 14. 코드 안내 • 그래픽 출력용 모듈인 matplotlib와 그 서브모듈인 pylab은 임포트 를 생략함 • numpy의 경우 생략 • 각 장에서, 이미 앞 부분에서 설명된 처리를 위한 모듈의 경우 임포 트가 생략되었을 수 있음 • 코드 내용의 자료 기입 이후의 수정으로 일부 비작동 사례 있을 수 있음 ( 발견 시, neuralix@gmail.com 로 inform 요망 )
  • 15. Load/Save and Display • skimage >> from skimage import io >> io.imsave( filename, logo ) >> imshow( img ) • opencv >> import numpy as np >> import cv2 >> cv2.imwrite( filename, img) >> cv2.imshow('image', img) >> camera = io.imread( filename ) >> img = cv2.imread( filename, 0 ) ※ URL의 입력도 가능
  • 16. Pixel Operation • Get pixel value • Put Pixel Value • Area Operation >> print img[ i ][ j ][ k ] for i in range(img.shape[0]): for j in range(img.shape[1]): for k in range(img.shape[2]): if i>=200 and i<300: if j>=200 and j<300: img[i][j][k] = 0 * img[i][j][k] >> img[ i ][ j ][ k ] = 0 >> img[200:300][200:300] = 0 * img[200:300][200:300] or Simply,
  • 17. Line Drawing • DDA (Digital Differential Analyzer) >> from skimage.draw import line, set_color >> rr, cc = line(x1, y1, x2, y2) >> set_color(img, (rr, cc), 1) >> imshow(img) ※ 가장 단순한 선긋기 방법
  • 18. Polygon Drawing • 다각형 그리기 >> from skimage.draw import polygon >> img = np.zeros((width, height), dtype=np.uint8) >> x = np.array([x1, x2, x3, x4, …]) >> y = np.array([y1, y2, y3, y4, …]) >> rr, cc = polygon(y, x) >> img[rr, cc] = 1
  • 19. Picking Points (“ginput”) • 클릭한 지점의 좌표를 배열로 리턴 >> from PIL import Image >> from pylab import * >> img = array(Image.open('C:mandrill.bmp')) >> imshow(img) >> print 'Please click 3 points' >> x = ginput(3) >> print 'you clicked:',x >> show() >> x you clicked: [(16.737903225806448, 18.705645161 290249), (406.85887096774195, 23.2419354838709 18), (227.22177419354841, 242.79838709677415)] ※ 이름의 유래는 MATLAB의 함수 이름 (Graphical INPUT)에서. 워낙 많이 쓰이고 편리하여 보통명사처럼 됨.
  • 21. Thresholding (Binarizing) • Otsu’s (Automatic) Thresholding >> from skimage import data >> from skimage.filter import threshold_otsu, threshold_adaptive >> from skimage import color >> img = io.imread('C:Mandrill.bmp') >> img_g = color.rgb2grey(img) >> val_thresh = threshold_otsu(img_g) >> img_bw = im_g > val_thresh >> io.imshow( img_bw ) Figure Credit : https://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch7/functn_ComputeThreshold_Otsu.html “Blob”
  • 22. Labeling • Connected Components Labeling http://engineersphere.com/biomedical-engineering/biomedical-image-processing-iii.html >> from skimage.morphology import label, closing, square >> from skimage.color import label2rgb … >> val_thresh = threshold_otsu(img) >> img_label = label(val_thresh) >> image_label_rgb = label2rgb(label_image) >> imshow(image_label_rgb) ※ Check neighborhood convention first! (8-neighborhood is complete, 4-neighbor is not.)
  • 23. Morphological Operation http://www.dspguide.com/ch25/4.htm >> from skimage.morphology import erosion, dilation, opening, closing, white_tophat >> from skimage.morphology import black_tophat, skeletonize, convex_hull_image >> from skimage.morphology import disk … >> selem = disk(6) >> img_eroded = erosion(img, selem) >> imshow(img_eroded, cmap=plt.cm.gray) >> img_dilated = dilation(img, selem) >> imshow(img_dilated, cmap=plt.cm.gray) https://www.cs.auckland.ac.nz/courses/compsci773s1c/lectures/ImageProcessing-html/topic4.htm • 1) 블랍을 <뚱뚱하게/날씬하게>, 2) 서로 다른 블랍을 <붙게/떨어뜨 리게>, 3) <구멍을 메우게/돌출부를 평평하게> ※ Structuring element (:selem)의 모양과 크기 에 의해 조정됨 ※ LIDAR/RADAR 데이 터의 처리에서 중요
  • 24. Boolean Operation • Image Boolean Operations
  • 25. Flood Fill • Filling the holes >> from scipy import ndimage >> from skimage.filter import canny >> img_edges = canny(img/255.) >> img_filled = ndimage.binary_fill_holes(img_edges)
  • 26. Segmentation • Mean Shift >> import cv2 >> import pymeanshift as pms >> img_orig = cv2.imread("example.png") >>(img_segmented, img_label, number_regions) = pms.segment(img_orig, spatial_radius=6, range_radius=4.5, min_density=50) https://code.google.com/p/pymeanshift/ ※ 구획화(Segmentation)는 경계를 인지, 이용 하는 방향과 내부 유사성을 인지, 이용하는 두 계열이 있음. GraphCuts, GrabCuts는 전자, Mean Shift(:Moving Averaging)은 후자, Chan’s Active Contour without Edges는 둘을 모두 추구함
  • 27. Edge / Contour ※ 임의의 선, 곡선들
  • 28. Skeletonization • Skeletonization http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm >> from skimage.morphology import skeletonize >> img_skeleton = skeletonize(image) >> imshow(img_skeleton, cmap=plt.cm.gray)
  • 29. Contour Finding • Contour Finding >> import numpy as np >> import matplotlib.pyplot as plt >> from skimage import measure >> x, y = np.ogrid[-np.pi:np.pi:100j, -np.pi:np.pi:100j] >> r = np.sin(np.exp((np.sin(x)**3 + np.cos(y)**2))) >> contours = measure.find_contours(r, 0.8) >> fig, ax = plt.subplots() >> ax.imshow(r, interpolation='nearest', cmap=plt.cm.gray) >> for n, contour in enumerate(contours): ax.plot(contour[:, 1], contour[:, 0], linewidth=2) >> plt.show() ※ 콘투어의 각 점들을 배열로 추출해줌
  • 30. Edge Detection (1of2) • Canny Edge Detection >> import numpy as np >> import matplotlib.pyplot as plt >> from scipy import ndimage >> from skimage import filter >> img_edges = filter.canny(img, sigma=3) >> imshow(img_edges, cmap=plt.cm.gray) ※ 콘투어가 전체에서 동일한 값인 지점을 주는 것이라 면 에지는 국소적인 조사로 최적경계를 찾으므로 대개 의 경우에 더 효과적임 (1차미분과 유사함). ※ 위의 경우는 Thresholding 후 에지 검출이 가능
  • 31. Edge Detection (2of2) • Canny Edge Detection http://homepages.inf.ed.ac.uk/rbf/CVonline/LOCAL_COPIES/MARBLE/low/edges/canny.htm http://news.mynavi.jp/photo/series/computer_vision/040/images/014l.jpg http://homepages.inf.ed.ac.uk/rbf/HIPR2/gsmooth.htm ※ 에지 검출 기법의 대명사와 같음 (“Canny”)
  • 32. Point / Line / Corner
  • 33. Hough Transform (1of2) • Hough Transform http://docs.opencv.org/modules/imgproc/doc/feature_detection.html
  • 34. Hough Transform (2of2) • Hough Transform http://www.aiaa-daycin.org/node/430 http://campar.in.tum.de/Students/DaPentenrieder >>from skimage.transform import (hough_line, hough_l ine_peaks, probabilistic_hough_line) >> edges = canny(image, 2, 1, 25) >> lines = probabilistic_hough_line(edges, threshold= 10, line_length=5, line_gap=3) >> for line in lines: p0, p1 = line plt.plot((p0[0], p1[0]), (p0[1], p1[1])) >> plt.show() ※ rho, theta 평면의 한 지점은 x, y 평면의 하나 의 직선에 대응함 ※ 두 점을 잇는 모든 직선을 rho, theta 평면에서 voting하여 피크지점을 추출하여 직선을 추정함
  • 35. Corner Detection (1of2) • Harris Corner Detection http://www.krankerkaktus.de/Portfolio/GraphicsProgramming https://www.ee.iitb.ac.in/~sumantra/courses/ip/assignment_1.html >> from skimage.feature import corner_harris, corner _subpix, corner_peaks >> coords = corner_peaks(corner_harris(image), min_ distance=5) >> coords_subpix = corner_subpix(image, coords, win dow_size=13) >> fig, ax = plt.subplots() >> ax.imshow(image, interpolation='nearest', cmap=p lt.cm.gray) >> ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3) >> ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) >> ax.axis((0, 350, 350, 0)) >> plt.show()
  • 36. Corner Detection (2of2) • Harris Corner Detection http://www.mathworks.co.kr/kr/help/images/detect-corners-in-images.html http://miac.unibas.ch/BIA/05-LandmarkBasedRegistration.html ※ 사각형 영역을 조사해보아 주성분분석을 하였을 때, 최대값인 아이겐밸류 lambda 1, 2가 모두 0보다 꽤 크 고, 서로간에 값이 비슷하면 Corner라 판단해도 좋다.
  • 38. Image Matching • Template Matching >>import numpy as np >>import matplotlib.pyplot as plt >>from skimage import data >>from skimage.feature import match_template >>result = match_template( img_whole, img_template )
  • 39. Noise Suppression • Denoising • Median >> from skimage import data, img_as_float >> from skimage.restoration import denoise_tv_ch ambolle, denoise_bilateral … >> imshow(denoise_bilateral(img, sigma_range=0.1, sigma_spatial=15)) >> from skimage.morphology import disk >> from skimage.filter.rank import median … >> img_med = median(img, disk(5))
  • 40. Contrast • Histogram Equalizing >> from skimage import exposure … >> img_eq = exposure.equalize_hist(img) Figure Credit : James Fishbaugh ※ 히스토그램 변환규칙을 만들고 그 히스토그램을 참고해 모든 픽셀의 값을 변경함. 여러 기법 중 히스토그램 이퀄라이징은 CDF가 강제로 직선이도록 변환규칙을 만들고 이를 따르 도록 하여 매 영상마다 최적에 가깝게 콘트라스트를 개선함.
  • 41. Rotation • Rotation with Interpolation http://www.darktable.org/2012/06/upcoming-features-new-interpolation-modes-and-better-resize/dt-rotation-grid/ >> from skimage.transform import rotate … >> img = rotate(img, 90, resize=True).shape >> import numpy as np … >> coord_center = tuple(np.array(image.shape)/2) >> rot_mat = cv2.getRotationMatrix2D(coord_center,angle,1.0) >> result = cv2.warpAffine(image, rot_mat, image.shape,flags=cv2.I NTER_LINEAR) ※ 모든 rotation과 resizing은 격자 불일치를 초래해 interpolation에 의한 보정을 필 요로 함. Skimage는 이의 정밀한 보정에서 아직 빈약하여 opencv를 권장. 이때 ima ge.shape,flags 변수의 적절한 설정이 필요함.
  • 42. Color (1of3) • RGB  Grey Luminousity (Grey Value) Average LightnessOriginal (Color) Figure Credit : Hohn D. Cook (http://www.johndcook.com/blog/2009/08/24/algorithms-convert-color-grayscale/) >> from skimage.color import rgb2gray >> from skimage import data … >> img_gray = rgb2gray(img) // Luminousity
  • 43. Color (2of3) • Radiometry  Photometry  Colorimetry http://www.screentekinc.com/resource-center/photometry-and-colorimetry.shtml http://www.chromapure.com/products-d3pro.asp
  • 44. Color (3of3) • Color Space http://en.wikipedia.org/wiki/File:RGB_sliders.svg https://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html ※ 슬라이드에서는 1이 255에 해당 ※ RGB와 CMY는 반대 (Cyan: R=0, G=255, B=255)
  • 46. Kalman Filtering • Kalman Filtering # Kalman filter example demo in Python # A Python implementation of the example given in pages 11-15 of "An # Introduction to the Kalman Filter" by Greg Welch and Gary Bishop, # University of North Carolina at Chapel Hill, Department of Computer # Science, TR 95-041, # http://www.cs.unc.edu/~welch/kalman/kalmanIntro.html # by Andrew D. Straw import numpy import pylab # intial parameters n_iter = 50 sz = (n_iter,) # size of array x = -0.37727 # truth value (typo in example at top of p. 13 calls this z) z = numpy.random.normal(x,0.1,size=sz) # observations (normal about x, sigma=0.1) Q = 1e-5 # process variance # allocate space for arrays xhat=numpy.zeros(sz) # a posteri estimate of x P=numpy.zeros(sz) # a posteri error estimate xhatminus=numpy.zeros(sz) # a priori estimate of x Pminus=numpy.zeros(sz) # a priori error estimate K=numpy.zeros(sz) # gain or blending factor R = 0.1**2 # estimate of measurement variance, change to see effect # intial guesses xhat[0] = 0.0 P[0] = 1.0 for k in range(1,n_iter): # time update xhatminus[k] = xhat[k-1] Pminus[k] = P[k-1]+Q # measurement update K[k] = Pminus[k]/( Pminus[k]+R ) xhat[k] = xhatminus[k]+K[k]*(z[k]-xhatminus[k]) P[k] = (1-K[k])*Pminus[k] pylab.figure() pylab.plot(z,'k+',label='noisy measurements') pylab.plot(xhat,'b-',label='a posteri estimate') pylab.axhline(x,color='g',label='truth value') pylab.legend() pylab.xlabel('Iteration') pylab.ylabel('Voltage') pylab.figure() valid_iter = range(1,n_iter) # Pminus not valid at step 0 pylab.plot(valid_iter,Pminus[valid_iter],label='a priori error estimate') pylab.xlabel('Iteration') pylab.ylabel('$(Voltage)^2$') pylab.setp(pylab.gca(),'ylim',[0,.01]) pylab.show() http://wiki.scipy.org/Cookbook/KalmanFiltering ※ z : 노이즈가 가미된 입력 xhat : 추정된 출력 ※ “뉴튼 물리학과 칼만 필터로 인간을 달에 보냈다.” (NASA) “Stanley는 모든게 칼만 필터였다.” (세바스찬 스런) ※ 시계열 데이터의 예측과 평활화에 적용
  • 47. 부가자료 • 파이썬용 Package, Tools – Anaconda Distribution https://store.continuum.io/cshop/anaconda ※ opencv, scikit-image, spyder를 모두 담음 – Scikit-Image Package • http://scikit-image.org • http://scikit-image.org/docs/dev/auto_examples – Pycharm IDE http://www.jetbrains.com/pycharm – 기타 Spyder IDE, iPython QTConsole, Sublime Text 2 등 • 책 (국내 및 번역서) – http://book.naver.com/bookdb/book_detail.nhn?bid=6191572 – http://book.naver.com/bookdb/book_detail.nhn?bid=6802764 – http://book.naver.com/bookdb/book_detail.nhn?bid=6332184 – http://kangcom.com/sub/view.asp?sku=200311040002 (컬러) • 책 (원서) – http://www.amazon.com/Machine-Vision-Ramesh-Jain/dp/0070320187 – http://www.amazon.com/Computer-Vision-Algorithms-Applications- Science/dp/1848829345/ref=sr_1_1?s=books&ie=UTF8&qid=1401379429&sr=1- 1&keywords=szeliski+computer+vision
  • 48.