Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multimedia Programming 04: Point Processing Departments of Digital Contents Sang Il Park.

Similar presentations


Presentation on theme: "Multimedia Programming 04: Point Processing Departments of Digital Contents Sang Il Park."— Presentation transcript:

1 Multimedia Programming 04: Point Processing Departments of Digital Contents Sang Il Park

2 Outline Review Image Processing –Brightness –Contrast

3 HelloCV #include "stdafx.h" #include int _tmain(int argc, _TCHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("HelloCV"); cvShowImage("HelloCV", img); cvWaitKey(); cvDestroyWindow("HelloCV"); cvReleaseImage(&img); return 0; } http://dasan.sejong.ac.kr/~sipark/class2008/mm/code/ hellocv.cpp IplImage cvLoadImage cvReleaseImage cvNamedWindow cvShowImage cvDestroyWindow cvWaitKey

4 빈 이미지 생성하기 IplImage* cvCreateImage( CvSize size, int depth, int channels ); – 만들 빈 이미지의 크기, 허용 색상수를 설정하여 생성 – 컬러수 :color depth: 8 ( 각 채널당 8bit) channels: 1,2,3,4 (1=grey, 3=color) –Example) IplImage * img; img = cvCreateImage(cvSize(200,100), 8,3); cvSet(image, CvScalar) – 이미지를 주어진 색으로 가득 칠한다 –Example) cvSet(img, CV_RGB(255,255,255));

5 So far what you’ve learned: IplImage cvLoadImage (file_name) cvCreateImage (size, depth, channels) cvSaveImage (file_name, image) cvReleaseImage (image) cvNamedWindow (window_name) cvShowImage (window_name, image) cvDestroyWindow (window_name) cvWaitKey (delay) cvGet2D (image, y, x) cvSet2D (image, y, x, cvScalar)

6 For those who want more OpenCV Wiki-pages: http://opencvlibrary.sourceforge.nethttp://opencvlibrary.sourceforge.net For HighGUI: –http://opencvlibrary.sourceforge.net/HighGuihttp://opencvlibrary.sourceforge.net/HighGui For cxcore: –http://opencvlibrary.sourceforge.net/CxCorehttp://opencvlibrary.sourceforge.net/CxCore Supplied documentation: OpenCV/docs/index.htm, faq.htm A Korean Community: http://www.opencv.co.kr/http://www.opencv.co.kr/

7 Image Processing 1 Point processing Alexei Efros

8 이미지를 함수처럼 ? Alexei Efros

9 Image Processing image processing 이란 한 이미지 f 를 새로운 이미 지 g 로 만드는 과정 Image Processing 의 두가지 : – 이미지 f 의 색을 변경하는 것 – 이미지의 영역을 변경하는 것 What kinds of operations can each perform? Alexei Efros

10 Image Processing image filtering: 이미지의 색상 값을 변경 g(x) = h(f(x)) f x h f x f x h f x image warping: 이미지의 영역을 변경 g(x) = f(h(x)) Alexei Efros

11 Image Processing image filtering: 이미지의 색상 값을 변경 g(x) = h(f(x)) image warping: 이미지의 영역을 변경 g(x) = f(h(x)) h fg h f g Alexei Efros

12 Point Processing 가장 단순한 Image Filtering: – 이미지의 점의 위치 x,y 에 상관없이 일괄적인 변환 적 용 g = t(f) 무엇을 할 수 있을까 ? 변환 함수 t 는 어떤종류가 있을까 ? Important: 모든 이미지 점 하나하나가 독립적으 로 처리됨 – 점들의 상관관계 정보를 전혀 사용하 지 않음 Alexei Efros

13 Point Processing 이미지  각 Pixel 의 RGB 밝기정보 값의 범위 : 0~255 포인트 프로세싱의 정의 : g = t ( f ) 한 점의 밝기값 ( 칼라값 ): f 새로운 밝기값 ( 칼라값 ): g

14 Point Processing 변형함수 t 는 함수이다 : g = t ( f ) – 이미지의 칼라값 f 를 새로운 이미지의 칼라값 g 로 대응 변형함수의 모양 f 0 255 0 g f 0 0 g f 0 0 올바르지 않은 변형함수의 예 : g

15 Basic Point Processing input output picture from http://girlsgeneration.iple.com/ g = Af + B A = 1 B = 0

16 Basic Point Processing input output Brightness + g = Af + B A = 1 B > 0

17 Basic Point Processing input output Brightness – g = Af + B A = 1 B < 0

18 Basic Point Processing input output Contrast + (brightness +) g = Af + B A > 1 B = 0

19 Basic Point Processing input output Contrast + g = Af + B A > 1 B < 0 Contrast + (brightness -)

20 Basic Point Processing input output Contrast – g = Af + B A < 1 B > 0

21 Basic Point Processing input output Contrast – (brightness +) g = Af + B A < 1 B > 0+++

22 코딩 연습 이미지를 하나 열고 밝기와 대비 값을 키보드를 누름으로써 조정한다 example)1 : brightness up(+10) 2: brightness down(-10) 3 : contrast up(+0.1)4: contrast down(-0.1) input output g = Af + B g = input color value f = output color value A = contrast value ( 초기값 = 1) B = brightness value ( 초기값 = 0)

23 Hint for the exercise 키보드 입력 받는 법 : –int cvWaitKey( int delay=0 ) waits for a pressed key. After waiting for the given delay, it proceeds. Zero delay means waiting forever until user input. Delay in milliseconds.

24 More functions?

25 Power-law transformations

26 Image Enhancement

27 Example: Gamma Correction http://www.cs.cmu.edu/~efros/java/gamma/gamma.html

28 Contrast Stretching

29 Image Processing 2 Histogram Equalization Alexei Efros

30 Image Histogram Histogram: –Counting the number of pixels with the same brightness imagehistogram http://www.accusoft.com/resourcecenter/tutorials/dip/VQ/lesson1c.htm

31 Image Histogram Histogram: –Counting the number of pixels with the same brightness http://www.cambridgeincolour.com/tutorials/histograms1.htm

32 Image Histogram Example http://www.cambridgeincolour.com/tutorials/histograms1.htm

33 Image Histogram Two images http://www.cambridgeincolour.com/tutorials/histograms1.htm

34 Modify the image to have a well-distributed histogram Histogram Equalization

35 Cumulative Histogram Number of the pixels below the brightness imagehistogramCumulative histogram http://www.accusoft.com/resourcecenter/tutorials/dip/VQ/lesson1c.htm

36 Cumulative histogram Cumulative Histograms Why is it so important?

37 Why is it so important? Let’s focus on the first image. 255 192 128 64 0 input o u t p u t

38 Why is it so important? Using Cumulative histogram as a function. 255 192 128 64 0 input output input output

39 Histogram Equalization

40 Coding Practice Make your own code for histogram equalization For each color channel (R, G, B) –1. Compute the histogram –2. Compute the cumulative histogram –3. Set the maximum value as 255 –4. Using the cumulative histogram as a mapping function 255 192 128 64 0

41 A colorful underwater world! http://www.dive.snoack.de/


Download ppt "Multimedia Programming 04: Point Processing Departments of Digital Contents Sang Il Park."

Similar presentations


Ads by Google