Bitmap (Raster) Images
CO2016 Multimedia and Computer Graphics
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 1
Bitmap (Raster) Images CO2016 Multimedia and Computer Graphics Roy - - PowerPoint PPT Presentation
Bitmap (Raster) Images CO2016 Multimedia and Computer Graphics Roy Crole: Bitmap Images (CO2016, 2014/2015) p. 1 Overview of Lectures on Images Part I: Image Transformations Examples of images; key attributes/properties. The standard
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 1
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 2
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 3
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 3
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 3
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 4
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 5
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 6
downto i=0 di ∗ 16i = dn−1 ∗ 16n−1 + . . . + d1 ∗ 161 + d0
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 7
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 8
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 9
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 10
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 11
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 12
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 13
theta h
(I , J)
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 14
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 15
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 16
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 17
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 18
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 19
☛ ✟ ✞ ☎
int red , green , blue , col . . . blue = ( col & 0 x f f ) ; green = ( col & 0 xff00 ) >> 8; red = ( col & 0xff0000 ) >> 16;
✡ ✠ ✝ ✆
☛ ✟ ✞ ☎
col = red << 16 | green << 8 | blue ; / /
a l t e r n a t i v e l y col = red ∗ 16^4 + green ∗ 16^2 + blue ;
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 20
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 21
☛ ✟ ✞ ☎
private BufferedImage f i l t e r ( BufferedImage img , int choice ) { BufferedImage ans = new BufferedImage ( img . getWidth ( ) , img . getHeight ( ) , BufferedImage .TYPE_INT_RGB ) ; int g r a y l v l ; for ( int x=0; x<img . getWidth ( ) ; x++) { for ( int y=0;y<img . getHeight ( ) ; y++) { switch ( choice ) { case BLUE : g r a y l v l= ( img . getRGB( x , y ) & 0 x f f ) ; ans . setRGB( x , y , g r a y l v l ) ; break ; case GREEN : g r a y l v l =(img . getRGB( x , y ) & 0 xff00 ) ; ans . setRGB( x , y , g r a y l v l ) ; break ; case RED : g r a y l v l = ( img . getRGB( x , y ) & 0xff0000 ) ; ans . setRGB( x , y , g r a y l v l ) ; } } } return ans ; }
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 22
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 23
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 24
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 25
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 26
☛ ✟ ✞ ☎
begin for x = 0 to x_max for y = 0 to y_max i f ( OriginalImageColor ( x , y ) > 127 ) DitheredImageColor ( x , y ) = 1; / / White ! ! else DitheredImageColor ( x , y ) = 0; / / Black ! ! end
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 27
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 28
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 29
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 29
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 29
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 30
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 31
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 32
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 33
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 34
☛ ✟ ✞ ☎
for x = 0 to x_max for y = 0 to y_max / / note row i correspond to coordinate y ! ! ! ! i = y mod n j = x mod n i f IntensityLevelOf_OriginalImageColor ( x , y ) > DM( i , j ) DitheredImageColor ( x , y ) = 1 else DitheredImageColor ( x , y ) = 0
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 35
☛ ✟ ✞ ☎
private BufferedImage basicDither ( BufferedImage img , int b ) { BufferedImage ans = new BufferedImage ( img . getWidth ( ) , img . getHeight ( ) , BufferedImage .TYPE_BYTE_BINARY ) ; for ( int i =0; i <img . getWidth ( ) ; i ++ ) { for ( int j =0; j <img . getHeight ( ) ; j ++ ) { / / select 8−b i t gray data i n t e n s i t y L e v e l = ( int ) ( ( img . getRGB( x , y ) & 0 x f f ) ) ; i f ( i n t e n s i t y L e v e l > b ) ans . setRGB( i , j ,0 x f f f f f f ) ; / / set
color to white else ans . setRGB( i , j ,0 x000000 ) ; / / set
color to black } } return ans ; }
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 36
☛ ✟ ✞ ☎
private BufferedImage expansiveDither ( BufferedImage img , int [ ] [ ] dm) { int n = dm. length ; int i n t e n s i t y L e v e l ; BufferedImage ans = new BufferedImage ( n∗img . getWidth ( ) , n∗img . getHeight ( ) , BufferedImage .TYPE_BYTE_BINARY ) ; for ( int x=0; x<img . getWidth ( ) ; x++ ) { for ( int y=0;y<img . getHeight ( ) ; y++ ) { / / select 8−b i t gray data ; l i n e a r l y map to 0 to n∗n i n t e n s i t y L e v e l = ( int ) ( ( img . getRGB( x , y ) & 0 x f f ) ∗ ( ( n∗n +1 ) / 2 5 6 ) ) ; for ( int i =0; i <n ; ++ i ) { for ( int j =0; j <n ; ++ j ) { i f ( i n t e n s i t y L e v e l > dm[ i ] [ j ] ) ans . setRGB( n∗x+i , n∗y+j ,0 x f f f f f f ) ; else ans . setRGB( n∗x+i , n∗y+j ,0 x000000 ) ; } } } } return ans ; }
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 37
☛ ✟ ✞ ☎
private BufferedImage
( BufferedImage img , int [ ] [ ] dm) { BufferedImage ans = new BufferedImage ( img . getWidth ( ) , img . getHeight ( ) , BufferedImage .TYPE_BYTE_BINARY ) ; int i , j ; int n = dm. length ; for ( int x=0; x<img . getWidth ( ) ; x++ ) { for ( int y=0;y<img . getHeight ( ) ; y++ ) { i n t e n s i t y L e v e l = ( int ) ( ( img . getRGB( x , y ) & 0 x f f ) ∗ ( ( n∗n +1 ) / 2 5 6 ) ) ; / / why would i = x%n ; j = y%n ; s t i l l y i e l d a correct program? i = y%n ; j = x%n ; i f ( i n t e n s i t y L e v e l > dm[ i ] [ j ] ) ans . setRGB ( x , y ,0 x f f f f f f ) ; else ans . setRGB ( x , y ,0 x000000 ) ; } } return ans ; }
✡ ✠ ✝ ✆
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 38
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 39
Roy Crole: Bitmap Images (CO2016, 2014/2015) – p. 40