Download presentation
Presentation is loading. Please wait.
Published byMerryl Gardner Modified over 9 years ago
1
Multimedia Programming 03: Point Processing Departments of Digital Contents Sang Il Park
2
Outline Review Image Processing –Brightness –Contrast –Gamma QnA for the program assignment #1
3
Review IplImage cvLoadImage (file_name) cvCreateImage (size, depth, channels) cvSaveImage (file_name, image) cvReleaseImage (image) cvNamedWindow (window_name) cvShowImage (window_name, image) cvDestroyWindow (window_name) int cvWaitKey (delay) Scalar cvGet2D (image, y, x) cvSet2D (image, y, x, Scalar)
4
Review: HelloCV2.cpp int main(int argc, CHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("window"); cvShowImage("window", img); cvWaitKey(); IplImage * img2; img2 = cvCreateImage(cvSize(300,300), IPL_DEPTH_8U, 3); int x,y; for(x=0; x<300; x++) for(y=0; y<300; y++) { CvScalar s = cvGet2D(img, y,x); s.val[0] +=80; s.val[1] +=80; s.val[2] +=80; cvSet2D(img2,y,x,s); } cvShowImage("window", img2); cvWaitKey(); cvDestroyWindow("window"); cvReleaseImage(&img); cvReleaseImage(&img2); return 0; }
5
Review: HelloCV2.cpp IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("window"); cvShowImage("window", img); cvWaitKey();
6
Review: HelloCV2.cpp int main(int argc, CHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("window"); cvShowImage("window", img); cvWaitKey(); IplImage * img2; img2 = cvCreateImage(cvSize(300,300), IPL_DEPTH_8U, 3); int x,y; for(x=0; x<300; x++) for(y=0; y<300; y++) { CvScalar s = cvGet2D(img, y,x); s.val[0] +=80; s.val[1] +=80; s.val[2] +=80; cvSet2D(img2,y,x,s); } cvShowImage("window", img2); cvWaitKey(); cvDestroyWindow("window"); cvReleaseImage(&img); cvReleaseImage(&img2); return 0; }
7
Review: HelloCV2.cpp IplImage * img2; img2 = cvCreateImage(cvSize(300,300), IPL_DEPTH_8U, 3); int x,y; for(x=0; x<300; x++) for(y=0; y<300; y++) { CvScalar s = cvGet2D(img, y,x); s.val[0] +=80; s.val[1] +=80; s.val[2] +=80; cvSet2D(img2,y,x,s); } cvShowImage("window", img2); cvWaitKey();
8
Review: HelloCV2.cpp int main(int argc, CHAR* argv[]) { IplImage * img; img = cvLoadImage("d:\\test.jpg"); cvNamedWindow("window"); cvShowImage("window", img); cvWaitKey(); IplImage * img2; img2 = cvCreateImage(cvSize(300,300), IPL_DEPTH_8U, 3); int x,y; for(x=0; x<300; x++) for(y=0; y<300; y++) { CvScalar s = cvGet2D(img, y,x); s.val[0] +=80; s.val[1] +=80; s.val[2] +=80; cvSet2D(img2,y,x,s); } cvShowImage("window", img2); cvWaitKey(); cvDestroyWindow("window"); cvReleaseImage(&img); cvReleaseImage(&img2); return 0; }
9
Review: HelloCV2.cpp cvDestroyWindow("window"); cvReleaseImage(&img); cvReleaseImage(&img2);
10
Image Processing 1 Point processing Alexei Efros
11
Images as functions Alexei Efros
12
Image Processing An image processing operation typically defines a new image g in terms of an existing image f. We can transform either the range of f. Or the domain of f: What kinds of operations can each perform? Alexei Efros
13
Image Processing image filtering: change range of image g(x) = h(f(x)) f x h f x f x h f x image warping: change domain of image g(x) = f(h(x)) Alexei Efros
14
Image Processing image filtering: change range of image g(x) = h(f(x)) image warping: change domain of image g(x) = f(h(x)) h fg h f g Alexei Efros
15
Point Processing The simplest kind of range transformations are these independent of position x,y: g = t(f) This is called point processing. What can they do? What’s the form of t? Important: every pixel for himself – spatial information completely lost! Alexei Efros
16
Basic Point Processing input output picture from http://girlsgeneration.iple.com/ 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 Brightness – g = Af + B A = 1 B < 0
19
Basic Point Processing input output Contrast + (brightness +) g = Af + B A > 1 B = 0
20
Basic Point Processing input output Contrast + g = Af + B A > 1 B < 0 Contrast + (brightness -)
21
Basic Point Processing input output Contrast – g = Af + B A < 1 B > 0
22
Basic Point Processing input output Contrast – (brightness +) g = Af + B A < 1 B > 0+++
23
A coding exercise Open image and adjust brightness/contrast by pressing keyboard 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)
24
Hint for the exercise How to get the key input? –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.
25
More functions?
26
Power-law transformations
27
Image Enhancement
28
Example: Gamma Correction http://www.cs.cmu.edu/~efros/java/gamma/gamma.html
29
Contrast Stretching
30
Programming Assignment #1 How to compare R,G,B channels? No right answer –Sum of Squared Differences (SSD): –Will it be enough? Change in size Change in brightness
31
In the next class… Point Processing2: –Image Histogram –FILTER Blur Noise removal Unsharp –Pixelation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.