Multimedia Programming 03: Point Processing Departments of Digital Contents Sang Il Park.
-
Upload
merryl-gardner -
Category
Documents
-
view
218 -
download
0
Transcript of Multimedia Programming 03: Point Processing Departments of Digital Contents Sang Il Park.
Multimedia Programming 03:
Point ProcessingDepartments of Digital
ContentsSang Il Park
Outline
• Review• Image Processing
– Brightness– Contrast– Gamma
• QnA for the program assignment #1
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)
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;• }
Review: HelloCV2.cpp
• IplImage * img;• img = cvLoadImage("d:\\
test.jpg");
• cvNamedWindow("window");• cvShowImage("window", img);• cvWaitKey();
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;• }
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();
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;• }
Review: HelloCV2.cpp
• cvDestroyWindow("window");• cvReleaseImage(&img);• cvReleaseImage(&img2);
Image Processing 1
Point processing
Alexei Efros
Images as functions
Alexei Efros
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
Image Processing
• image filtering: change range of image• g(x) = h(f(x))
f
x
hf
x
f
x
hf
x
• image warping: change domain of
image• g(x) = f(h(x))
Alexei Efros
Image Processing
• image filtering: change range of image• g(x) = h(f(x))
• image warping: change domain of
image• g(x) = f(h(x))
hf g
hf g
Alexei Efros
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
Basic Point Processing
input
ou
tput
picture from http://girlsgeneration.iple.com/
g = Af + B
A = 1B = 0
Basic Point Processing
input
ou
tput
Brightness +
g = Af + B
A = 1B > 0
Basic Point Processing
input
ou
tput
Brightness –
g = Af + B
A = 1B < 0
Basic Point Processing
input
ou
tput
Contrast + (brightness +)
g = Af + B
A > 1B = 0
Basic Point Processing
input
ou
tput
Contrast +
g = Af + B
A > 1B < 0 Contrast + (brightness -)
Basic Point Processing
input
ou
tput
Contrast –
g = Af + B
A < 1B > 0
Basic Point Processing
input
ou
tput
Contrast – (brightness +)
g = Af + B
A < 1B > 0+++
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
ou
tput
g = Af + B
g = input color valuef = output color value
A = contrast value ( 초기값 = 1)B = brightness value ( 초기값 = 0)
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.
More functions?
Power-law transformations
Image Enhancement
Example: Gamma Correction
http://www.cs.cmu.edu/~efros/java/gamma/gamma.html
rs
/1rs
0.25.025.0.. ge
Contrast Stretching
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
In the next class…
• Point Processing2: – Image Histogram– FILTER
• Blur• Noise removal• Unsharp
– Pixelation