Title: Multimedia Programming 2005
1Multimedia Programming2005
2Course Notes
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Remember to hand in your assignment before 1700
TODAY! - Assignments will be graded in the next week
- Results will be send over email
- I saw a Visual C CDROM lying around this place.
3Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
4Contents
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Introduction
- Human eye
- Computer representation
- Image types
- Computer challenges
- Image programming
- Assignment
5Introduction
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Computer images are everywhere
- Holiday pictures
- Internet pages
- Computer documents
- Icons, buttons, windows, etc.
- Different types
- GIF, PNG, BMP, JPEG, TIFF, etc..
- What are computer images?
6Human Eye
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
7Human eye vs. CCD
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- CCD charge coupled device
- Eye 150.000 elts/mm2
- CCD 4 Megapixel ?
- 4.000.000 elts/5mm2
- 160.000 elts/mm2
- Well within the realm of eye ability
- Intelligence in vision
-
8About color
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Humans discern thousands of colors
- The color spectrum contains roughly 6 colors
(violet, blue green, yellow, orange, red) - Cones are divided in categories
- Red (65), Green (33), blue (2)
9About color
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- All the colors of light are described in
combinations of RGB - Primary colors of light
- Secondary colors of light
- Colors of colorants or pigments
10Computer representation
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Divide picture in grid
- Take average color per cell
- Cells are called pixels
11Computer representation
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- RGB color space
- Give every pixel a RGB code (or index number)
- This color in RGB 255,128, 64
- This color in binary
- 00000000 010000000 10000000 11111111
- This color in hexadecimal
- 0x00 40 80 FF
12Computer representation
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
-
- type .
- .
- Width.
-
- pixel1,pixel2,pixel3,pixel4, etc
13Computer terminology
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Dimensions of image in pixels
- WRONG resolution
- RIGHT size
- Determine resolution on output-time
- Color depth
- Number of colors available per pixel
- Monochrome, grayscale, 256 colors, true colors
14Image types
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- BMP (Bitmap)
- Varies from 2 to 16 million colors
- Uncompressed
- 4 bytes per pixel. (so large file)
- GIF (Compuserve GIF)
- 256 colors (of choice)
- Compressed (LZW, patented)
- 1 byte per pixel (colors in header)
15Image Types
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- JPEG (Joint Photographic Experts Group)
- Transformed color space (brightness, color).
- Encoding () in high frequency region (human eye
can see badly) - Downsampling per 8x8 pixels.
- Vector images
16Challenges object recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
17Challenges object recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Not that different
- Main color red
- Surrounding color mostly green
18Challenges Human recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
19Challenges Human recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Not that different
- Face
- Long black hair on both sides
20Challenges texture recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
21Challenges texture recognition
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Not that different
- Main color white(ish)
- Texture shaded parts
22Visual programming
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Message loop
- while (!quit)
- readmessage()
- execute task(message)
-
- (Re)Paint the window is also a message!
23Image programming
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Simple image programming (no directX yet)
- Buffering is important!
- Disk is slow, memory is fast.
- On initialization load all images in memory to
prevent shocks - Display when needed.
24Image programming
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- All images are being displayed as uncompressed
pixels (bitmap). - Basic program flow
- Get window handle
- Create device handle
- Connect device handle to window handle
- Load image in device
25Image programming
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Start painting
- Draw bitmap
- End painting
- Invalidate window
- No worries skeleton code will be provided!
26Image programming example
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- //buffering
- hDC GetDC( hWnd )
- hdcImage CreateCompatibleDC(hDC )
- Bmp (HBITMAP)LoadImage(
- NULL,
- "..\\Images\\image01.bmp",
- IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE )
- SelectObject( hdcImage, bmp )
- //displaying
- hDC BeginPaint( hWnd, ps )
- BitBlt( hDC, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT,
- hdcImage, 0, 0, SRCCOPY )
- EndPaint( hWnd, ps )
- InvalidateRect( hWnd, NULL, FALSE )
27Image programming example 2
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- // one time
- TransparentBlt(hdc, xStart, yStart, ptSize.x,
ptSize.y,hdcTemp, 0, 0, ptSize.x, - ptSize.y, cTransparentColor)
- //draw transparent picture
- myDrawTransparentBitmap(hdcSave,bmp_transparent
,250, 0, 0x0000ff00)
28Assignment
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- Ex. Windows message loop and images.
- Click a button to change image
- Move and place partially transparent images
- Automatically cycle through images to create
(simulate video).
29Last assignment
Contents Introduction Human eye and image
physics Computer representation Image
Types Computer Challenges Image
Programming Assignment
- No correction yet.
- No chocolate bar award either.
- Any questions?