SlideShare a Scribd company logo
1 of 149
Download to read offline
Êส‹‹Çว¹น»ปÃรÐะ¡กÍอºบÁมÑัÅลµตÔิÁมÕีàเ´ดÕีÂย
              [ÃรÙู»ปÀภÒา¾พ]
              2 ¡กÃร¡ก®ฎÒา¤คÁม 2555




                                              1
ia Systems
520251: Multimed




            Êส‹‹Çว¹น»ปÃรÐะ¡กÍอºบÁมÑัÅลµตÔิÁมÕีàเ´ดÕีÂย
                              [ÃรÙู»ปÀภÒา¾พ]
                              2 ¡กÃร¡ก®ฎÒา¤คÁม 2555




                                                          1
Raster vs vector


                   2
Raster Graphics vs Vector Graphics




                                     3
Raster Graphics vs Vector Graphics




Raster graphics
(bitmap image)

                                     3
Raster Graphics vs Vector Graphics




Raster graphics       Vector graphics
(bitmap image)           (drawing)

                                        3
Raster Graphics vs Vector Graphics




Raster graphics       Vector graphics
(bitmap image)           (drawing)

                                        4
Raster Graphics vs Vector Graphics




Raster graphics       Vector graphics
(bitmap image)           (drawing)

                                        4
Raster Graphics vs Vector Graphics




Raster graphics       Vector graphics
(bitmap image)           (drawing)

                                        5
Raster Graphics vs Vector Graphics




Raster graphics       Vector graphics
(bitmap image)           (drawing)

                                        5
ÀภÒา¾พáแºบºบ raster
»ปÃรÐะ¡กÍอºบ´ดŒŒÇวÂย¨จØุ´ด (x,y) àเÃรÕีÂย¡กÇว‹‹Òา pixel




                                                            6
ÀภÒา¾พáแºบºบ raster
áแµต‹‹ÅลÐะ pixel ¤ค×ืÍอ¢ขŒŒÍอÁมÙูÅล




                                        7
ÀภÒา¾พáแºบºบ raster
¢ขŒŒÍอÁมÙูÅลµตŒŒÍอ§งãใªชŒŒ¾พ×ื้¹น·ท∙Õี่ãใ¹น¡กÒาÃร¨จÑั´ดàเ¡ก็ºบ




                                                                    8
ÀภÒา¾พáแºบºบ raster
àเÃรÒาÍอÒา¨จàเÃรÕีÂย¡กÇว‹‹ÒาÀภÒา¾พ bitmap




                                             9
»ป˜˜¨จ¨จÑัÂย·ท∙Õี่ºบ‹‹§ง¢ข¹นÒา´ด
           ¨จÓำ¹นÇว¹น pixel (resolution)




             lena_color_256.tif,
              256x256, 201 KB

                                                                              lena_color_512.tif,
ที่มา: http://www.imageprocessingplace.com/root_files_V3/image_databases.htm    512x512, 791 KB
                                                                                                    10
»ป˜˜¨จ¨จÑัÂย·ท∙Õี่ºบ‹‹§ง¢ข¹นÒา´ด
           ¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕี (color depth)




             lena_color_256.tif,                                              lena_gray_256.tif,
              256x256, 201 KB                                                  256x256, 70 KB


ที่มา: http://www.imageprocessingplace.com/root_files_V3/image_databases.htm
                                                                                                   11
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                12
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                12
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                12
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                12
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                12
Color Depth




ที่มา: http://en.wikipedia.org/wiki/Color_depth
                                                                13
Color Depth




ที่มา: http://www.gimvic.org/predmeti/informatika/gradiva/navodila-strani/Uporaba_grafike.html
                                                                                                14
Color Depth




ที่มา: http://www.gimvic.org/predmeti/informatika/gradiva/navodila-strani/Uporaba_grafike.html
                                                                                                15
CHAPTER
                  5 Color Palettes                                                    RGB COLOUR




Figure 5.6. Images and their palettes

pots of paint of a particular colour.When we use indexed colour, pixels don’t store a 24-bit colour
value, but instead store a small number that identifies a 24-bit colour from the palette associated
with the image. Just as each painting by numbers outfit includes only those paints that are needed
to colour in one picture, so each palette includes only the 24-bit RGB values for the colours used    16
Color Palettes
166   COLOUR


 1A        1C      20       21        1F       1E                    If the palettes were interchanged, the
 0D        16      17       1B        22       23                    dark blue of the sea would turn maroon,
 0A        13      09       15        18       1D                    and the maroon areas of the flower would
 03        10      08       01        00       07                    turn blue. The result of exchanging the
 05        02      11       0E        04       06
                                                                     entire colour tables between these two
 10        14      0B       0C        12       09
                                                                     images is shown in Figure 5.8. By swap-
                                      stored values
                                                                     ping the two tables we have in effect
                                                                     assigned an arbitrary palette to each
      00     99141B
                                                                     image, which produces a visual incoher-
      01     A0191C
      02     A23E1A                                                  ence more pronounced than you would
      03     A51B1C                                                  perhaps have expected. This illustrates
      04     A51D1C                                                  just how important colour values are
      05     A65619                                                  in the representation and interpretation
      06     A9191C                                                  of coloured images. It also shows why
      07     A92E1C
                                                                     it is usually unwise to use an arbitrary
      08     AB201C
      09     AC111C                                                  colour palette, of course.
      0A     AC191D
                                        displayed pixels
      0B     AC4C1A                                                   If indexed colour is to be used, an
      0C     AC5219                                                   image file needs to store the colour
      0D     AD111D                                                   table along with the actual image data,
      0E     AD331C
                                                                      but the image data itself can be smaller
      0F     AD401B       Colour Lookup Table
           etc                                                        by a factor of three, since it only needs
                                                                      8 bits per pixel. For any reasonably
 Figure 5.7. Using a colour table                                     sized image there will therefore be a
                                                                      net saving of space. This saving may be
            increased further if the file format allows tables with fewer than 256 entries to be stored with
            images that have fewer colours, and uses the minimum number of bits required to index the
                                                                                                             17
            palette for each colour value.
CHAPTER
                  5                            Color Palettes                           RGB COLOUR      165




                              CHAPTER
Figure 5.6. Images and their palettes
                                             5                                                                RGB COLOUR    167


pots of paint of a particular colour.When we use indexed colour, pixels don’t store a 24-bit colour
value, but instead storeWhat can be that identifies a the areas offrom the palette associated
                          a small number done with 24-bit colour
with the image. Just as the image that should be includes onlyin
                         each painting by numbers outfit displayed those paints that are needed
to colour in one picture, so each palettewhich is not available invalues for the colours used
                        some colour includes only the 24-bit RGB
in one particular image. When the image is displayed, the colour from the palette corresponding
                        the reduced palette?
to each single-byte value stored at each pixel, is used as the colour of that pixel. Figure 5.6 shows
two images with different colour characteristics, together with the palettes used when they are
                        Obviously, any missing colour must be
stored using indexed colour.
                       replaced by one of those that is in the
The mapping from stored values to colours can be efficiently implemented using a table. Hence,
                       palette. There are two popular ways
instead of trying to use 8 bits to hold an RGB value, we use it to hold an index into a table with
256 entries, each of which doing full 24-bit RGB colourto replace
                       of holds a this. The first is value. For example, if a particular pixel
was to be displayed as the colour whose 24-bit RGB value was #A23E1A, instead of storing that
                        the colour value of each individual
value in the image, wepixel store anthe colour table index of in which it was stored.
                         could with index identifying the table location
Supposing #A23E1A was held in the third entry of the table, the pixel would hold the offset 2 (see
                       the colour closest to it. This can have
Figure 5.7). Such an indexed table of colour values is called a colour table.The colours represented
in the colour table make up the image’s palette,notthe colour table itself is Figure 5.8. called a
                       undesirable effects: so only may the                    often loosely Exchanging the colour tables
palette too.           colours be distorted, but detail may
                       be lost when two similar colours are
With indexing, a colour value does not identify a colour absolutely, but only relative to a palette.
                       replaced by the same one, and banding and other visible artefacts may appear where gradations
It may help you to understand what is going on if you consider what would happen if the
                       of colour are replaced by sharp boundaries. As we noted previously, these effects are collectively         18
Color Depth




ที่มา: http://www.gimvic.org/predmeti/informatika/gradiva/navodila-strani/Uporaba_grafike.html
                                                                                                19
»ปÃรÐะàเ´ด็¹นµต‹‹Òา§งæๆ¢ขÍอ§ง raster graphics

resolution x color depth
àเ·ท∙¤คâโ¹นâโÅลÂยÕีÍอØุ»ป¡กÃร³ณàเ¡กÕี่ÂยÇว¡กÑัºบÀภÒา¾พ
¡กÒาÃร¾พÑั²ฒ¹นÒาàเ·ท∙¤คâโ¹นâโÅลÂยÕี image processing
      ÍอÑัÅล¡กÍอÃรÔิ¸ธÖึÁมàเ¾พ×ื่Íอ¡กÒาÃรáแÊส´ด§ง¼ผÅลÀภÒา¾พ
      ¡กÒาÃรºบÕีºบÍอÑั´ด¢ขŒŒÍอÁมÙูÅล


                                                              20
àเ·ท∙¤คâโ¹นâโÅลÂยÕีÍอØุ»ป¡กÃร³ณàเ¡กÕี่ÂยÇว¡กÑัºบÀภÒา¾พ




                                                           21
Input




        22
Output




         23
Device Resolution
ÍอØุ»ป¡กÃร³ณµต‹‹Òา§งæๆ¨จÐะÁมÕี¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ด¢ขÍอ§งÀภÒา¾พ·ท∙Õี่ÃรÑัºบ
àเ¢ขŒŒÒาÁมÒาËหÃร×ืÍอáแÊส´ด§งÍอÍอ¡กäไ»ปÍอÂย‹‹Òา§งäไÃร¹นÑั้¹น ¢ขÖึ้¹นÍอÂยÙู‹‹¡กÑัºบ
¤คÇวÒาÁมËห¹นÒาáแ¹น‹‹¹น¢ขÍอ§ง¨จØุ´ดÀภÒา¾พ (pixel density)
      scanner ¨จÐะÁมÕี pixel density àเ»ปšš¹น dpi
      (dots per inch)
      àเÇวÅลÒา·ท∙Õี่àเÃรÒาàเÅล×ืÍอ¡ก«ซ×ื้Íอ ¨จÐะµตŒŒÍอ§ง¾พÔิ¨จÒาÃร³ณÒา spec
      Çว‹‹ÒาÊสÒาÁมÒาÃร¶ถÊสáแ¡ก¹นÀภÒา¾พ·ท∙Õี่¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ดàเ·ท∙‹‹ÒาäไÃร


                                                                                       24
25
Scanner




          26
Scanner




          26
Scanners




Flatbed              Sheet-fed



                                 27
Scanners




Handheld                   Drum
                 Use photomultiplier tube (PMT)
               instead of CCD (read more on wiki)
                                                    28
Scanned Image Size (in 24-bit color)
  Resolution
                          image dimension
    (dpi)
                1”x1”         4”x6”         8.5”x11”

     72         15 KB         356 KB        1,420 KB

     100        29 KB         703 KB        2,739 KB

     300       264 KB        6,328 KB       24,653 KB

     600       1,055 KB     25,313 KB       98,613 KB



                                                        29
Device Resolution
ãใ¹นàเ¤คÃร×ื่Íอ§ง inkjet printer ¨จÐะÁมÕี¡กÒาÃรºบ‹‹§ง
resolution àเ»ปšš¹น lines per inch (lpi)
àเ¹น×ื่Íอ§ง¨จÒา¡ก¡กÒาÃร¾พÔิÁม¾พËห¹นÖึ่§ง¨จØุ´ดÊสÕี (pixel) ¢ขÍอ§ง
ÀภÒา¾พ¨จÐะ»ปÃรÐะ¡กÍอºบ´ดŒŒÇวÂย¡กÅลØุ‹‹Áม¢ขÍอ§งËหÁมÖึ¡ก




                                                                      30
Device Resolution

¨จÍอÀภÒา¾พÁมÑั¡กºบ‹‹§ง¤ค‹‹Òา pixel density ÍอÂยÙู‹‹·ท∙Õี่ 72 dpi




                                                                      31
density must be associated with a digital photograph, it is taken to be 72 dpi, to match the assumed
               resolution of a computer screen. As we will see in a moment, this is not very convenient.

               Image Resolution
                                              Image Resolution
               Now consider bitmapped images. An image is an array of pixel values, so it necessarily has pixel
               dimensions. Unlike a printed photograph or original artwork on paper, a bitmapped image has
               no physical dimensions. In the absence of any further information, the physical size of an image
               when it is displayed will depend on the pixel density of the device it is to be displayed on.

                                                                                                      pixel dimension
               For example, the image in Figure 4.1 is 198 pixels wide and 149 high. If it could be displayed
                    physical dimension =
               at the nominal screen resolution of 72 dpi it would be 70 mm by 52.5 mm. Displayed without
                                                                                                       pixel density
               scaling on an actual monitor at 115 dpi, it will only be a little over 43.5 mm wide. If it is printed


               72 dpi   70 mm x 52.5 mm
                                                                       115 dpi   43.5 mm x 33 mm

                                                                                                              600 dpi   8.5 mm x 0.25 mm




               Figure 4.1. Device resolution and image size



Ex Libris                             ÃรÙู»ป¹นÕี้ÁมÕี resolution ·ท∙Õี่ 198 x 149 (WxH)
            apisake@gmail.com......................................................           © M a c Avo n M e d i a




                                                                                                                                           32
density is specified in pixels per inch, the physical dimension will be in inches, and so on.)

It follows that if two images seem to be the same physical size on devices with different resolu-
                       Image Resolution
tions, the images must have different pixel dimensions. Since the pixels on the two devices are of
different sizes, the images will display different amounts of detail. This is illustrated in Figure 4.2.

72 dpi, 198 × 149 px




600 dpi, 1654 × 1240 px




Figure 4.2. Resolution and pixel dimensions

                                                                                                           33
ÍอÑัÅล¡กÍอÃรÔิ¸ธÖึÁมãใ¹น¡กÒาÃรáแÊส´ด§ง¼ผÅลÀภÒา¾พ


                                                   34
Resampling

¡กÒาÃรÅล´ด¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ดàเÃรÕีÂย¡กÇว‹‹Òา downsampling
¡กÒาÃรàเ¾พÔิ่Áม¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ดàเÃรÕีÂย¡กÇว‹‹Òา upsampling
àเÃรÕีÂย¡กÃรÇวÁมæๆ¡กÑั¹นÇว‹‹Òา resampling




                                                                    35
108   BITMAPPED IMAGES




         Figure 4.3. Scaling pixels

         the enlarged image undefined. This emphasizes that, in constructing a scaled-up image, we must
         use some interpolation method to compute values for some pixels.

         An alternative approach to performing the scaling is to compute the transformed image by finding
         a corresponding pixel in the original image for each pixel in the new image. The advantage
                                                                                                            36
CHAPTER
                  4                                                                RESOLUTION     109




Figure 4.4. Scaling pixels using a reverse mapping

of course, we combine the reconstruction and resampling into a single operation, because we can
only work with discrete representations.

We know that, for general images which may contain arbitrarily high frequencies because of
sharp edges, the reconstruction cannot be done perfectly.We also know from sampling theory that         37
CHAPTER
                   4                                                                        RESOLUTION   111




Figure 4.7. Nearest-neighbour (left), bilinear (middle) and bicubic (right) interpolation

assumed to lie along a Bézier curve connecting the stored pixels, instead of a straight line. These
are used for the same reason they are used for drawing curves: they join together smoothly. As a
result, the resampled image is smooth as well.

                                                                                                               38
Anti-aliasing
aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ




                                              39
Anti-aliasing
aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ

                    jaggies




                                              39
Anti-aliasing
aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ   anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth

                    jaggies




                                                                                              39
Anti-aliasing
aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ   anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth

                    jaggies




                                                                                              39
Anti-aliasing
aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ   anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth

                    jaggies




                                                                                              39
Anti-aliasing




ที่มา: http://flasheandoblog.wordpress.com/2009/11/29/flash-   ที่มา: http://www.pixelburg.com/am_glossary/
performance-series-quality-adjustments/

                                                                                                            40
Dithering
aliasing = àเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÅลÇว§งµตÒาÁม¹นØุÉษÂยãใ¹น¡กÒาÃร
(àเËหÁม×ืÍอ¹น¡กÑัºบ)àเ¾พÔิ่Áม»ปÃรÔิÁมÒา³ณ color depth
ÀภÒาÂยãใµตŒŒ»ปÃรÔิÁมÒา³ณÊสÕี (color palette) ·ท∙Õี่ÁมÕี
¨จÓำ¡กÑั´ด




                                                                 ที่มา: http://en.wikipedia.org/wiki/Dithering

                                                                                                                 41
Dithering
aliasing = àเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÅลÇว§งµตÒาÁม¹นØุÉษÂยãใ¹น¡กÒาÃร
(àเËหÁม×ืÍอ¹น¡กÑัºบ)àเ¾พÔิ่Áม»ปÃรÔิÁมÒา³ณ color depth
ÀภÒาÂยãใµตŒŒ»ปÃรÔิÁมÒา³ณÊสÕี (color palette) ·ท∙Õี่ÁมÕี
¨จÓำ¡กÑั´ด




                                                                 ที่มา: http://en.wikipedia.org/wiki/Dithering

                                                                                                                 41
168    COLOUR




Dithering
                           Figure 5.9. Dithering in black and white

                           If each pixel can be one of 256 different colours, instead of just black or white, then the corre-
                           sponding patterns can simulate millions of colours. However, these simulated colours are, in effect,
                           being applied to pixels four times the area of those actually on the screen. This means that the
                           effective resolution of the image is being halved, resulting in a loss of detail. While this is usually
                           acceptable for printing, where resolutions in excess of 600 dpi are common, it is often intrusive
                           when images are being displayed on 72 dpi monitors. Other artefacts may also be generated when
                           the patterns are superimposed; these can be minimized by clever choice of dot patterns for the
                           generated colours, although this has the effect of cutting down the number of different colours
                           that can be simulated.

                           This leaves the question of which colours should be used in a palette. Ideally, you will fill the
                           palette with the most important colours in your image. Often, these will be the most common,
                           in which case it is easy for a program like Photoshop to construct the palette automatically by
                           examining the original 24-bit version when it converts it to indexed colour. Sometimes, though,
                           the use of colour will be more complex, and it may be necessary to construct the palette by
                           hand (or, more likely, edit an automatically constructed palette), making subjective judgements to
                           ensure that all the colours considered to be vital are present in the palette.



            Ex Libris   apisake@gmail.com......................................................            © MacAvon Media




                               ที่มา: http://commons.wikimedia.org/wiki/File:Dithering_algorithms.png
                                                                                                                                     42
Dithering




            ที่มา: http://en.wikipedia.org/wiki/Dithering
                                                            43
Dithering




            ที่มา: http://en.wikipedia.org/wiki/Dithering
                                                            43
Dithering




            ที่มา: http://en.wikipedia.org/wiki/Dithering
                                                            43
Dithering




            ที่มา: http://en.wikipedia.org/wiki/Dithering
                                                            43
Dithering




ที่มา: http://www.gimvic.org/predmeti/informatika/gradiva/navodila-strani/Uporaba_grafike.html
                                                                                                44
Image Compression
                            ion i s the
                omp    ress
   Ima   ge c                 data
 “
              l icatio  n of           ages.
         app              digi tal im
            ssio   n on              is to
co   mpre               obje  ctive
      n effe ct  , the               f the
    I                   nda  ncy o
        d uce     redu           to be    able
      re             in o rder
        ge da    ta               data   in an
 ima                  tran smit
        sto re or               m....”
   to
               effi   cien t for
                                                 45
Image Compression



lossless       lossy




                       46
lossless




           47
Image Compression



lossless       lossy




                       48
hi-quality comp: 83,261 Bytes                      lossy

                                lo-quality comp: 4,787 Bytes




                                        ที่มา: http://en.wikipedia.org/wiki/Jpeg
                                                                                   49
Image File Format


                    50
JPEG




       51
JPEG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression




                                                                    51
JPEG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression
   âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก
   ÍอÍอ¡กäไ»ป




                                                                                                         51
JPEG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression
    âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก
    ÍอÍอ¡กäไ»ป
àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด
(âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย)




                                                                                                          51
JPEG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression
    âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก
    ÍอÍอ¡กäไ»ป
àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด
(âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย)
äไ¿ฟÅลàเÅล็¡กáแµต‹‹àเ¡ก็ºบÃรÒาÂยÅลÐะàเÍอÕีÂย´ดÊสÙู§ง



                                                                                                          51
JPEG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression
    âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก
    ÍอÍอ¡กäไ»ป
àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด
(âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย)
äไ¿ฟÅลàเÅล็¡กáแµต‹‹àเ¡ก็ºบÃรÒาÂยÅลÐะàเÍอÕีÂย´ดÊสÙู§ง
àเ¡ก็ºบÀภÒา¾พÊสÕีäไ´ดŒŒËหÅลÒา¡กËหÅลÒาÂย¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕี

                                                                                                          51
ที่มา: http://upload.wikimedia.org/wikipedia/commons/c/ce/Quality_comparison_jpg_vs_saveforweb.jpg

                                                                                                     52
ที่มา: http://upload.wikimedia.org/wikipedia/commons/c/ce/Quality_comparison_jpg_vs_saveforweb.jpg

                                                                                                     53
ที่มา: http://en.wikipedia.org/wiki/JPEG

                                           54
http://regex.info/blog/lightroom-goodies/jpeg-quality

                                                        55
56
57
JPEG vs JPEG2000




 ที่มา: www.lithium.it/050702_ jp2_qualitvergl_e.jpg

                                                       58
59
JPEG



             ☹
jpg




gif
         not suitable for
         line drawing or
           images with
               text



                            60
61
GIF




      62
GIF
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression (LZW)




                                                           62
GIF
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression (LZW)
¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕีäไ´ดŒŒàเ¾พÕีÂย§ง 8-bit




                                                           62
GIF
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression (LZW)
¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕีäไ´ดŒŒàเ¾พÕีÂย§ง 8-bit
àเËหÁมÒาÐะ¡กÑัºบÀภÒา¾พ·ท∙Õี่ÁมÕีÅลÑั¡กÉษ³ณÐะÅลÒาÂยàเÊสŒŒ¹น äไÁม‹‹àเËหÁมÒาÐะ¡กÑัºบ
ÀภÒา¾พ¶ถ‹‹ÒาÂย




                                                                                      62
GIF
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression (LZW)
¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕีäไ´ดŒŒàเ¾พÕีÂย§ง 8-bit
àเËหÁมÒาÐะ¡กÑัºบÀภÒา¾พ·ท∙Õี่ÁมÕีÅลÑั¡กÉษ³ณÐะÅลÒาÂยàเÊสŒŒ¹น äไÁม‹‹àเËหÁมÒาÐะ¡กÑัºบ
ÀภÒา¾พ¶ถ‹‹ÒาÂย




                                                                                      62
GIF (Transparent)




                    63
GIF (Transparent)




                    63
GIF (Transparent)




                    63
GIF89a (Animation)




                     64
PNG




      65
PNG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression




                                                           65
PNG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression
true color




                                                           65
PNG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression
true color
web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png




                                                           65
PNG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression
true color
web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png
ÊสÒาÁมÒาÃร¶ถÃรÍอ§งÃรÑัºบ transparency ·ท∙Õี่«ซÑัºบ«ซŒŒÍอ¹นäไ´ดŒŒ




                                                                     65
PNG
ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless
compression
true color
web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png
ÊสÒาÁมÒาÃร¶ถÃรÍอ§งÃรÑัºบ transparency ·ท∙Õี่«ซÑัºบ«ซŒŒÍอ¹นäไ´ดŒŒ




                                                                     65
âโ»ปÃรáแ¡กÃรÁมµตºบáแµต‹‹§งÀภÒา¾พ


                                    66
67
68
69
70
Digital Camera & VDO Camera




                              71
Digital Camera & VDO Camera




                              71
Digital Camera & VDO Camera




                              71
Digital Camera & VDO Camera




                              72
JPEG vs RAW

• Normally, digital cameras save their images in
  the JPEG format.
 • Automatically adjusts: white-balance and all.
• RAW format is exactly what the camera sees
  when it takes the picture; NO adjustments
  have been made to the images. BUT, the file is
  a lot bigger in size...


                                                   73
Type of image Min resolution Camera Spec.

 Web images      640x480     1 megapixel +


   5”x7”        2048x1536   3 megapixels +


   8”x10”       2272x1704   4 megapixels +


  16”x20”       3072x2048   6 megapixels +



                                             74
Editing Raster Images

• Selecting an Area
• Cropping
• Image resizing & canvas size
• Rotating
• Adjusting the balance

                                 75
Editing Raster Images


• Sharping the contrast
• Adjusting the resolution
• Saving and exporting


                             76
Vector Graphics



                  77
Vector Graphics ?

• An elegant way of constructing digital images
  whose representation is:
 • compact
 • scalable
 • resolution-independent
 • easy to edit

                                                  78
Vector Graphics




                  79
Vector Graphics




                  80
Vector Graphics




                  80
Vector Graphics




                  80
81
81
Adobe Illustrator    Scaleable Vector
    format           Graphics format




                    standard web vector
                          graphics
                                          82
Fundamental


• images are built up using shapes that can easily
  be described mathematically
 • therefore, reviewing the basic concepts are
   needed




                                                     83
asily be described mathematically.
ments of coordinate geometry, the
vector graphics. For the benefit of
                                     Coordinates
 lines in terms of coordinates and              62       V E C TO R G R A P H I C S
 oncepts.

                                                     0         1       2     3         The coordi
                0 1 2 3 4 5 6 7
xplained      0 O                                                                     xzero and th
                                                                                       and y coord
y giving      1
                                                 1                                     in a device
mber the      2                                                                        system whe
mage to       3               B                                                        identifying
                                                 2
 tified by    4                                                                        geometrica
 er and y     5                                  3                                     for exampl
                                                                  (2.35,2.95)
  at (7,3).   6                                                                        to any fini
              7       A                                  y                             with negat
                                                                                       with negat
              Figure 3.1. Pixel coordinates     Figure 3.2. Real coordinates and axes  through th
                                                                                       dinate of z
                                                           the origin is the x-axis. We can label
 .....................        © MacAvon Media              spaced points to produce the familiar g
                                                           can easily be read off.Vector drawing p
                                                           rulers) along the edges of your drawin
                                                                                                84
Vectors
                                            FUNDAMENTALS             63



t only to define points, but                    x2 − x1
 ement. For example, to get P
                               1
  move 4 units to the right
er way, −4 units down (the




                                                                y2 − y1
                                            P
 ). So we can specify the                    2 −
                                                  P
 r (4,−4). In general, for any                     1


= (x2,y2), the displacement
 hich we write as (P2 − P1)                                    P2
values is used to specify a
  two-dimensional vector. A Figure 3.3. A vector
a magnitude (length). The
− P2, since moving from P1 to P2 is different from moving in
1. They have the same length but opposite directions.


                                                                          85
Looking back at Figure 3.4, you will see that the staircase effect is a result of the


                                        Drawing a line
                     pronounced contrast between black and white pixels. We can soften the effect
                     by using intermediate grey values for some pixels. In terms of the frequency
                     domain representation, we are removing the spurious high frequencies, and
                     replacing them with lower frequencies. We cannot simply tone down the black
               64      V E C TO R G R A P H I C S
                     pixels to produce a grey line instead U Na blackEone; weSwant65 try to use a pixel approximation to a
                                                              F of DA M N TA L                                Figure 3.5. The single
                                                                                           to
                     range of greys to somehow convey to the eye and brain of someone looking at straight line
                     the displayed line an appearance of smoothness that cannot actually be achieved
                                                    from these. A bit of simple algebraic manipulation, which many readers will
  representation in the the finitefrequency domain of
                         (spatial) pixels.
                     by
clude infinitely high frequencies. Consequently, no have done at school, demonstrates that, if the line passes through (x1,y1) and
ate to ensure perfect reconstruction. In other(x2,y2), m is equal to orientation of−the)pixel cgrid, at to (x2y1 − x1y2)/(x2 − x1).
                                                     words,
                     If we did not have to be concerned about the 2 1
                                                                           (y − y )/(x2 x1 and is equal
no matter how high the resolution that isa used for line coordinates of the shown in Figure 3.5. on their own to specify
                     best we could produce smooth
                                                    Hence, the
                                                                  one pixel wide, as
                                                                                     end points are enough
                                                    both the extent of the line and the constants in its equation, so they alone
                     Our original attempt at rendering the line on the basis of its defining equa-
                                                    would be used to represent the line.
                     tion had the effect of setting to black those pixels whose intersection with this
ancial considerations impose a limit on the available
                     one-pixel-wide rectangle was at least half the area of the pixel. Anti-aliasing is
 tor graphics that are used in multimedia presenta-in a shade of necessary tobrightness vector drawing, the stored values are
                     achieved by colouring each pixel it becomes grey whose render a is propor-
                                                    When
ed on a monitor with a resolution betweenintersection, as shown with the general form of the description of each class of
                     tional to the area of the used, in conjunction in Figure 3.6. The number of
                                                    72 and
sing may be readily visible. To reduce its impact is to set the values of but if we formthe grey of the object described.
                     pixels that are no longer white a greater than before, pixels to take an image
                                                    object,
 asing is often employed. and multiply the area of each one byathe value end points (0,31)the total 1), we could compute the
                     pixels                         For example, if line has used to colour it, and (12,
                     amount of greyness, as it y coordinatesame as that produced by only using aas x was stepped from 0 to
                                                    were, is the corresponding to each integer value
 you will see that the staircase effect is acolour of Remember that a pixel’s coordinates magnifica- integers (whole numbers),
                     single black level to result the original collection of pixels. At this are always
                                                    12. the
en black and whitetion the We can soften the effect cannotifset the value book at part of a pixel. This means that the pixel
                       pixels. result looks fairly incoherent, but you hold the of just arm’s length it
                                                    and we
  values for some pixels. In terms of the frequencycan onlybeen subdued somewhat.ideal mathematical object which the
                     should be apparent that the jaggedness has ever approximate the At normal
                                                    image
 are removing the viewing resolutions anti-aliasing can significantly reduce example, the line just described has equation
                      spurious high frequencies, and model describes. For aliasing effects, albeit
                                                    vector
                     at the expense of a certainy = 31 − 5x/2, so for any odd integer value of x, y must be rounded down to
 requencies. We cannot simply tone down thefuzziness. black
                 Figure 3.4. Approximating          get its corresponding integral value. The coordinates Figure 3.6. Anti-aliased
                                                                Figure 3.5. The single                        of pixels along the line
ne instead of a a straight line want to try to use a pixel approximation to a
                 black one; we                                                                                line
                                                    would be (0,31), (1,28), (2,26), (3,23)….To get a continuous line, we set blocks
 convey to the eye and brain of someone looking at straight line
                                                    of pixels to the desired colour of the line, but the height of the blocks alternates
ance of smoothness that cannot actually be achieved
                             between 2 and 3 pixels, so that the ideal straight line is approximated by an uneven staircase, as
                       Ex Libris apisake@gmail.com......................................................               © MacAvon Media
                             shown in Figure 3.4.This is inevitable, since the output devices we are using are based on a grid of          86
VECTOR OBJECTS                  67




                                               Vector Objects
 program allows you to work with shapes is a reflection
presented in graphics files. For example, in Illustrator you
clicking the mouse or pressure-sensitive pen at each end
 ented by the coordinates of its end points. In SVG, which
ram, a line can be represented by a line element, with the
 uch as <line x1="300" y1="0" x2="0" y2="300"/>.

rograms provide
                               (x1, y1)
 d in much the
 e different ways                         w = x2 − x1                 68    V E C TO R G R A P H I C S
 nce, a rectangle
an be drawn by                    h = y2 − y1
                                                                                    (x1, y1)
 own the mouse
  dragging to the
 ly be completely                                                  dra                                            ry = (y2−y1)/2
                                                        (x2, y2)      g                                                                       rx = (x2−x1)/2
 pposite corners,
and where it is                                                                                                          c = (x1+rx, y1+ry)
 s a rect element,           M x1, y1           H x2 − x1
inates of the top                                                                                                                                                         dra
                                                                                                                                                               (x2, y2)       g
which can easily      V y1 − y2
 he bottom right
ple in Chapter 2                                                                 Figure 3.8. Drawing an ellipse

ed as a sequence                                                                 Squares and circles are special cases of rectangles and ellipses, respectively, and so do not need any
ure 3.7.) As well                                              V y2 − y1         special representation of their own. It is helpful when drawing to be able to ask the program to
                                                                                 restrict rectangles and ellipses to squares and circles. In Illustrator this is done by holding down
 ent in SVG, this                  H x1 − x2                                     the shift key while using the rectangle or ellipse tool.
 gles in PDF and
  necessary values   Figure 3.7. Drawing a rectangle                             Curves
 can be deduced                                                                  Lines, rectangles and ellipses are sufficient for drawing many sorts of technical diagrams (particu-
                                                                                 larly when your lines can be decorated with arrowheads, as they can be in all professional drawing
                                                                                 programs). Less constrained drawing and illustration requires more versatile shapes, which are
                                                                                 supplied by Bézier curves.
 appropriate tool and dragging from one point on the
                                                                                                                                                                                          87
Curves
    CHAPTER
                 3                                                              V E C TO R O B J E C T S   69



                      P2                  P3




                                                                                          P4

     P1

Figure 3.9. A cubic Bézier curve

Bézier curves of degree 3, commonly called “cubic Bézier curves”, are the type most commonly
found in vector graphics. They have just four control points: as always, two are the end points.
The other two, which do not usually lie on the curve itself, are called direction points. The name
indicates the purpose of these points: being on tangents to the curve, they show the direction in
which it sets off from each end point. This is shown in Figure 3.9: P1 and P4 are the end points of
                                                                                                            88
hics. They have just four control points: as always, two are the end points.
h do not usually lie on the curve itself, are called direction points. The name
  of these points: being on tangents to the curve, they show the direction in


                                                  Curves
 each end point. This is shown in Figure 3.9: P1 and P4 are the end points of
 re its direction points, and you can see that the curve is accurately described
 s at P1, setting off towards P2, and curving round so that it arrives at P4 from
 aying within the quadrilateral convex hull P1P2P3P4 throughout.

ines from each end point to its neigh-
                                                          direction
oint determine how wide a sweep the                         lines
n think of the lengths of these lines as




                                                    g
d with which the curve sets off towards


                                                  dra
 he faster it goes, the further out it will



  of the curve is the basis for the way
wn interactively. After selecting the appro-
 pen), you click at the first end point and               end points
ds the first control point, as if you were




                                                                                    dra
ards it.You will usually see a direction line




                                                                                      g
 you have pulled. In most applications, for
explained in the next section, the direc-
                                                Figure 3.10. Drawing a curve with the pen
nds away from the end point both in the         tool
d symmetrically in the opposite direction.


                                                                                            89
Curves
70    VECTOR GRAPHICS


      P2       P3                          P2       P3                         P2       P3



                                P4                                  P4                                  P4

 P1                                  P1                                  P1

Figure 3.11. P1, P2, P4, P3          Figure 3.12. P2, P1, P4, P3         Figure 3.13. P3, P1, P4, P2

           Once you have the first one right, you click at the point where you want the curve to end, and
           drag away from the direction point (see Figure 3.10).You will see the curve being formed as you
           move the cursor. If you do not like the result when you have finished, you can subsequently select
           any of the control points and drag it around to change the shape and extent of your curve. For
           more information on drawing Bézier curves, consult our book Digital Media Tools.

           You can construct a cubic Bézier curve using any set of four control points, but the result is not
           necessarily going to be useful or lovely. Nor is it always obvious (until you have acquired some
                                                                                                                90
You can construct a cubic Bézier curve using any

     Curves
          necessarily going to be useful or lovely. Nor is it
          experience using these curves) exactly what the c
          to look like. Figures 3.11 to 3.13 show curves pro
          in Figure 3.9, but in different orders.

                P2                    Bézier curves of degr
                                      only use one directio
                                      shown in Figure 3.14
                                      cubic ones so they are
P1                                    one fewer control po
                                  P3  are preferred in some
                                      to download are wan
Figure 3.14. A quadratic Bézier curve curves – even though
                                      SWF graphics lets yo
          tool, these are approximated by quadratic curves
          curves are also used in TrueType fonts (see Chapt
                                                          91
between them, as shown on the left of Figure 3.15. The join on the right is smoother still, because
we have made sure that the length of the direction lines is the same on each side of P4. If you
think of the line as a trajectory through space, this ensures that it passes through the shared end


                                        Paths
point at a constant velocity, whereas, if we only make sure the three points are in a straight line,
the direction is constant but the speed changes.

The smoothness of joins when control points line up and direction lines are the same length
is the reason behind the display of direction lines in drawing programs. When you drag away
from an end point, as we saw earlier in Figure 3.10, direction lines are displayed both to and
from it. In other words, you are shown two direction points: one belonging to the curve you are

     P2         P3                                      P2       P3




                                                                 =
                              P4                                                P4

P1                                       P5        P1
                         P7                                                P7




                                                                                          =
                                                                                                  P5
                                   P6                                                P6

Figure 3.15. Joining two Bézier curves



 Ex Libris   apisake@gmail.com......................................................          © M a c Avo n M e d i



                                                                                                               92
Figure 3.17 shows an open and a closed path. Open paths have end points, closed paths do not.
               Each individual line or curve is called a segment of the path; the points where segments join (the
               original end points of the segments) are called the path’s anchor points.

                                                       Paths
               Because cubic Bézier curves can be drawn efficiently and they are so good at approximating other
               curved shapes, they are frequently used as the only curve-drawing primitive in graphics languages,
               even though programs generating documents in those languages may provide drawing tools for
               other shapes. In particular, PDF does not have any primitive operations for drawing anything but
               line and curve segments. Every object is built as a path made up of such segments. (In contrast,
               SVG has elements for all of the primitive shapes we described earlier.) This means that it is not




               Figure 3.17. An open path (left) and a closed one (right)



Ex Libris   apisake@gmail.com......................................................        © M a c Avo n M e d i a




                                                                                                                     93
As we noted earlier, som
                                                                                                        natural media, such as ch
                                                                                                        as ribbons and Celtic d

                              Strokes                          Figure 3.19. Dashed effects
                                                                                                        line, though, not by app

                                                                             As well as applying a stroke to a path, you c
                                                                             only fill a closed path, but most drawing pro
74   VECTOR GRAPHICS
                                                                             operation implicitly closes the path with a

                              Combining different line caps with dash patterns provides a range of effects,
                                                                                                       The        simplest fill is a sing
                              as shown in Figure 3.19.
                                                                                                           fill (or, indeed, a stroke)
                              Joins at corner points also need consideration, because wide lines can only This applies to a whit
                                                                                                           it.
                              meet cleanly if they do so at 90°; when they meet at any other angle an
                                                                  Mitre                                    shape on a white backgr
                              unsightly gap or overlap will result. This can be removed in several ways. The
                              three styles of line join provided by Illustrator are a mitre – as in a picture if it overlaps any oth
                                                                                                           but
                              frame, the outside edges of the lines are extended to meet at a point; round – a
                                                                                                           you must explicitly set i
                              circular arc is used to produce a rounded corner; and bevel – the segments are
                              finished off square where they join, and the resulting notch is filled in with
                              a triangle to produce a flat ended joint. If mitred joins are used on segments
                                                                    Rounded spikes will result. To avoid        Normally, there is no
                              that meet at a very narrow angle, long projecting
                                                                                                                you were using waterc
                              this, a limit can be specified, and if the ratio of the spike’s length to the stroke
                              width exceeds it, mitres will be replaced by bevels. Figure 3.20 illustrates the  other possibilities, you c
                              different joining styles.
                                                                                                              knock out areas of obje
                                                                  Bevel
                              As we noted earlier, some drawing programs can apply strokes that simulate      programs have allowed
                                                                                                              anything beneath it to
                              natural media, such as charcoal or painted brush-strokes, or special effects, such
                              as ribbons and Celtic designs. This is done by stretching an image along the
Figure 3.19. Dashed effects                                      Figure 3.20. Joining styles
                              line, though, not by applying a stroke to it directly.
                                                                                                              sense to consider combi

           As well as applying a stroke to a path, you can use it as an outline and fill it. In principle you can
           only fill a closed path, but most drawing programsEx Librisyou to fill an open path – the filling
                                                               also allow apisake@gmail.com............................
           operation implicitly closes the path with a straight line between its end points.
                                                                                                                                     94
PTER
        3                                                     Fills     VECTOR OBJECTS              75



ways, using blending modes – an established technique in bitmapped images, as discussed
er 4. SWF, SVG and PDF all support transparency, with PDF having the most elaborate
or blending modes.

 eresting and sometimes more attrac-
 ts than those permitted by solid or
 sparent colours can be produced by
 dient fills and patterns. Figure 3.21
 me basic examples of gradient fills.
e of fill is characterized by a gradual
   between colours or tones. In the
case – a linear gradient – the colours
end of a region are specified, and a
 lend of intermediate colours is gener-
etween.

   provides controls to let you specify
iate colours, adjust the midpoint of Figure 3.21. Linear (top) and radial (bottom) gradient fills
 ent (where the two colours being
 re of equal intensity) and the line along which the gradient varies, to get more compli-
 , such as the ones on the right of Figure 3.21. An alternative form of blending, shown
ttom of Figure 3.21, has the colour varying outwards from a centre point to the outside
. This is called a radial gradient.                                                                      95
Fills
76   VECTOR GRAPHICS




        Figure 3.22. Gradient mesh

        made using the facilities provided by your drawing program (possibly including the facility to
        import bitmaps as objects, as described later).The name embodies the analogy normally employed
        for describing how an area is filled with a pattern. Imagine that the artwork is rendered onto a
        rectangular ceramic tile, such as you might use in your bathroom. Copies of the tile are arranged   96
right, add one to the winding number;
                                                every time the path crosses from right
                                                to left, subtract one from the winding
                                                number. After all the crossings have


                                                                                    Fills
                                                been counted, if the winding number
                                                is zero then the point is outside the
                                                path, otherwise it is inside. Note that
                                                this algorithm depends on the path’s
                                                having a direction, which will depend
                                                            VECTOR OBJECTS          77
                                                on the order in which anchor points
                                                were added to it.                                Figure 3.23. Pattern fills
ws one answer
   the non-zero                                 An alternative way of distinguishing
 hich may be
                                                the inside of a path from its outside is
  as follows. To
                                                the even–odd rule. Again, to determine
  nt is inside a
                                                whether a point is inside the path, a
y infinite) line
                                                line is constructed from it, extending
 irection. Start
                                                in any direction. The number of path
  mber to zero.
 ne, and every                                  segments crossing the line is counted. If
   from left to                                 it is odd, the point is inside, if it is even,
 ding number;                                   it is outside.
  es from right
    the winding                                 For many shapes, including our example
 rossings have                                  at the top of Figure 3.24, both rules
  ding number                                   give the same result, but in some cases
 s outside the                                  they will define the inside differently.
de. Note that                                   The lower pair of shapes in Figure 3.24
on the path’s                                   shows a classic example.
h will depend                                                                                    Figure 3.24. Filling complex shapes
anchor points
                   Figure 3.23. Pattern fills
                                                  Ex Libris   apisake@gmail.com......................................................   © M a c Avo n M e d i a
distinguishing
 its outside is
to determine
                                                                                                                                                                  97
Figure 3.25. Any modern drawing program will allow you to perform these transformations by
direct manipulation of objects on the screen. For example, you would translate an object simply
by dragging it to its new position.



                  Transformation
Figure 3.25 illustrates another feature of all vector graphics programs. Several objects – in this
case, four coloured squares – can be grouped and manipulated as a single entity. Grouping may
be implemented entirely within the drawing program, as a convenience to designers; it is also
supported within some graphics languages, including SVG. In a related feature, some programs and
languages allow an object or a group of objects to be defined as a symbol, which is a reusable entity.




Figure 3.25. An object being scaled, rotated, reflected, sheared and translated




  Ex Libris   apisake@gmail.com......................................................          © M a c Avo n M e d i a
                                                                                                                         98
the y direction by sy, (x,y) must be changed to (sx x, sy y). (Valu
            object to shrink in the corresponding direction.) Thus, to do
            coordinates must be multiplied by two. However, this has the

Transformation
            the object. (For example, if a unit square has its corners at
            moves them to (2,4) and (4,2), which are the corners of a squ
            is now in the wrong place.) To scale an object in place, the m
            suitable, easily computed displacement to restore it to its orig

                                           Rotation about the origin a
  y                                        simple to achieve. To rotate a
                                           clockwise direction by an angl
                                           (x cos − y sin , x sin + y cos
                                           trigonometry if you wish).

                                           To reflect it in the x-axis, simp
                                           to (−x,y).

                                           When an object is sheared, it is
                                    x
                                           it upwards, through an angle ,
                                           an angle (see Figure 3.26). Yo
  Figure 3.26. Skewed axes
                                           can be achieved by moving (x, y

            Applying these operations to all the points of an object will tr
            general operations of rotation about an arbitrary point and99re
e-tune the shape of objects.

s which fall between the highly structured transformations and
                                  Distortion
 l points are provided by way of parameterized commands in
 hese are referred to as filters, by analogy with the filters available
n programs. An object is selected and an operation is chosen from
 osen filter is then applied to the selected object.

 es of
 Bloat
 ult is
 point
  then
either
 effect
o give
          Figure 3.27. Pucker and bloat


..................................................              © MacAvon Media
                                                                                  100
3D Graphics



              101
3D Graphics
84   VECTOR GRAPHICS




        Figure 3.28. Different two-dimensional views of a three-dimensional model

        3-D graphics – as we call vector graphics based on three-dimensional models – is a complicated
        subject, though, requiring tools that are hard to master, and it should be left to specialists most of
        the time. Here, we can only outline the main features of 3-D technology, in order to provide an
        appreciation of the difficulties it presents and the opportunities it has to offer.

        In abstract mathematical terms, generalizing coordinate geometry from two dimensions to three
        is straightforward. The x- and y-axes of a two-dimensional coordinate system are perpendicular to        102
In abstract mathematical terms, generalizing coordinate geometry from two dimension
               is straightforward. The x- and y-axes of a two-dimensional coordinate system are perpen
               each other. If you imagine drawing a set of axes on a flat sheet of paper and pinning it to


        3D Graphics
               wall, you can see that we can place a third axis perpendicular to the other two, coming
               paper horizontally and projecting from the wall. Just as we can use x and y coordinates t
               point’s horizontal and vertical distance along the wall from the origin, we can use a z c
               measured along our third axis, to define its distance from the wall. The three coordinate
               define a point in three-dimensional space (see Figure 3.29).

                                  y                               The primitive geometrical shapes
                                                                  graphics are replaced by 3-D objects:
                                                                  a circle, we have a sphere; instead of
                                                                  a cube, and so on. By an obvious ex
                                                                  three-dimensional vector defines a disp
                                                                  using three components in the same
                                        (x, y, z)                 the two-dimensional vectors we us
                                                                  define displacements using two com
                                                          x       This allows us to describe translations
                                                                  in three-dimensional space. We certain
                                                                  basis for 3-D vector graphics, but we
                                                                  some new problems.
                  z
                                                                  When we introduced a third dimen
               Figure 3.29. Axes in three dimensions              stated that the z-axis points out of the




Ex Libris   apisake@gmail.com......................................................           © MacAvon
                                                                                                     103
described in terms of the set theoretical operators union, intersection and difference.

These operations only affect two objects that are placed in such a way that they share some of the


                             3D Models
space that they occupy – normally a physical impossibility, but no problem for a computer model.
Their union is a new object made out of the space occupied by the two together.The intersection
of two objects is the space that the two have in common. Finally, the difference of two objects is
the space occupied by the first but not the second; this operation is useful for knocking holes out
of solid objects. Figure 3.32 shows the objects formed by applying these operations to a vertical
cylinder and a horizontal ellipsoid. (The shadows and tiled pattern are just cosmetic additions,
which should help make it easier to see the third dimension in these illustrations.) The difference
operation is not commutative: in Figure 3.32 we have taken the cylinder away from the ellipsoid.
You would get a very different object by taking the ellipsoid away from the cylinder.




Figure 3.32. The union, intersection and difference of two solid objects




  Ex Libris   apisake@gmail.com......................................................       © MacAvon Media




                                                                                                              104
The simplest path is a straight line. A shape
                                  creates an object with a uniform cross-section
                                  as it travels along a straight line. For example, a
                                  circle creates a cylinder in this way. Figure 3.33



                                                  3D Models
                                  shows a slightly more elaborate example. This
                                  process is known as extrusion, since the objects
                                  it produces resemble those that can be made by
                                  industrial processes in which plastic or metal is
                                  forced out through an opening. Extruded text is
                                  one application of 3-D GRAPHICS been
                                                       this technique that has      89
                                  so widely used in producing corporate logos as Figure 3.33. Extrusion
                                  to have become a cliché.
 -dimensional
 ine a volume                     To produce more elaborate objects, a curved
  ong a path.                     path can be used, and the size of the cross-
                                  section can be altered as it moves along it. If
 ine. A shape
                                  the path is a conventional Bézier path, organic
  cross-section
                                  shapes can be generated.
or example, a
 . Figure 3.33                  If the path is a circle, the resulting objects
 xample. This                   exhibit radial symmetry. This special case is
 e the objects                  often called lathing because of the resemblance
n be made by                    of the resulting objects to traditional turned
                                artefacts. If a suitable shape is chosen, circular
  c or metal is
                                paths can be used to generate many types of
truded text is
                                drinking vessel and vase, as well as mechanical
  hat has been                  components and, as Figure 3.34 shows, some
orate logos as    Figure 3.33. Extrusionhat.
                                styles of                                             Figure 3.34. Lathing


                                  The third approach to modelling is procedural modelling. Here, instead of using models that can
cts, a curved                     be described by equations, and storing only the constants that define a particular instance, we use
                                  objects that are described by an algorithm or procedure. Thus, returning to two dimensions for a
of the cross-
                                  moment, instead of defining a circle by the equation x2+y2 = r2, we could define it by some
s along it. If
                                  procedure such as “draw a curve that maintains a constant distance r from the origin”. In this case,   105
3D Models
90   V E C TO R G R A P H I C S




          Figure 3.35. Constructing a well-known fractal curve

          tractable structure, algorithms may provide a description where equations cannot.The best known
          procedural modelling techniques are based on fractals. These are often described as shapes that
          exhibit the same structure at all levels of detail. Figure 3.35 shows a famous example of such a
          shape, and its construction.

             IN DETAIL                                                                                       106
3D Models
92   V E C TO R G R A P H I C S




          Figure 3.39. Fractal terrain

          arbitrarily fine detail with the irregular appearance of natural terrain, as exhibited by the land-
          scapes in Figures 3.39 and 3.40.

          Rendering
                                                                                                                107
3D Rendering
    CHAPTER
                  3                                                                3-D GRAPHICS      93




Figure 3.40. Photo-realistic rendering

Wire frames are often used as preview images in modelling programs. They can also be useful
in computer-aided design systems, since they contain enough information to provide answers to
questions such as “Does the door provide adequate clearance for the piano when it is fully open?”.        108
to determine the orientations of objects unambigu-
ugh an object, it becomes difficult or impossible to

                       3D Rendering
 u look at Figure 3.41, you can probably see the hat
  down on the side towards you. If you stare at it for
 er curve of the brim, you will probably be able to



2 demon-
of a back-
he object
 hen wire
modelling
in, neutral

              Figure 3.41. Wire frame rendering

 ......................................        © MacAvon Media
                                                                 109
3D Rendering
94   VECTOR GRAPHICS




        Figure 3.42. Wire frame, flat, Gouraud and Phong shading

        In order to show the surfaces of objects, it is necessary to determine which of them are visible.The
        far sides of objects are considered hidden in perspective views, as are surfaces, or parts of surfaces,
        with other objects in front of them. Determining which surfaces are visible, starting only from
                                                                                                                  110

More Related Content

Similar to 04 image andgraphics

Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdfssuserff72e4
 
Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdfssuserff72e4
 
Unit i mm_chap3_graphics and image data representation
Unit i mm_chap3_graphics and image data representationUnit i mm_chap3_graphics and image data representation
Unit i mm_chap3_graphics and image data representationEellekwameowusu
 
Multimedia digital images
 Multimedia  digital images Multimedia  digital images
Multimedia digital imagesMohammad Dwikat
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representationMazin Alwaaly
 
Image Printing Based on Halftoning
Image Printing Based on HalftoningImage Printing Based on Halftoning
Image Printing Based on HalftoningCody Ray
 
WEB I - 08 - Digital Media
WEB I - 08 - Digital MediaWEB I - 08 - Digital Media
WEB I - 08 - Digital MediaRandy Connolly
 
Second Quarter Awarding of Certificates.pptx
Second Quarter Awarding of Certificates.pptxSecond Quarter Awarding of Certificates.pptx
Second Quarter Awarding of Certificates.pptxHannahKrystalRosales1
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsMichael Heron
 
Lecture5 graphics
Lecture5   graphicsLecture5   graphics
Lecture5 graphicsMr SMAK
 

Similar to 04 image andgraphics (12)

03 image andgraphics
03 image andgraphics03 image andgraphics
03 image andgraphics
 
Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdf
 
Lecture 2-2023.pdf
Lecture 2-2023.pdfLecture 2-2023.pdf
Lecture 2-2023.pdf
 
Unit i mm_chap3_graphics and image data representation
Unit i mm_chap3_graphics and image data representationUnit i mm_chap3_graphics and image data representation
Unit i mm_chap3_graphics and image data representation
 
Multimedia digital images
 Multimedia  digital images Multimedia  digital images
Multimedia digital images
 
Multimedia graphics and image data representation
Multimedia graphics and image data representationMultimedia graphics and image data representation
Multimedia graphics and image data representation
 
06_features_slides.pdf
06_features_slides.pdf06_features_slides.pdf
06_features_slides.pdf
 
Image Printing Based on Halftoning
Image Printing Based on HalftoningImage Printing Based on Halftoning
Image Printing Based on Halftoning
 
WEB I - 08 - Digital Media
WEB I - 08 - Digital MediaWEB I - 08 - Digital Media
WEB I - 08 - Digital Media
 
Second Quarter Awarding of Certificates.pptx
Second Quarter Awarding of Certificates.pptxSecond Quarter Awarding of Certificates.pptx
Second Quarter Awarding of Certificates.pptx
 
GRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D GraphicsGRPHICS01 - Introduction to 3D Graphics
GRPHICS01 - Introduction to 3D Graphics
 
Lecture5 graphics
Lecture5   graphicsLecture5   graphics
Lecture5 graphics
 

More from อภิเษก หงษ์วิทยากร (10)

Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1
 
01 fundamental of multimedia
01 fundamental of multimedia01 fundamental of multimedia
01 fundamental of multimedia
 
00 welcome slide
00 welcome slide00 welcome slide
00 welcome slide
 
03 digital mediafundamental
03 digital mediafundamental03 digital mediafundamental
03 digital mediafundamental
 
Slide05 Message Passing Architecture
Slide05 Message Passing ArchitectureSlide05 Message Passing Architecture
Slide05 Message Passing Architecture
 
Slide06 Networked Computing
Slide06 Networked ComputingSlide06 Networked Computing
Slide06 Networked Computing
 
03 digital mediafundamental
03 digital mediafundamental03 digital mediafundamental
03 digital mediafundamental
 
03 digital media fundamental
03 digital media fundamental03 digital media fundamental
03 digital media fundamental
 
02 multimedia andinteractivity
02 multimedia andinteractivity02 multimedia andinteractivity
02 multimedia andinteractivity
 
01 fundamental of multimedia
01 fundamental of multimedia01 fundamental of multimedia
01 fundamental of multimedia
 

Recently uploaded

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

04 image andgraphics

  • 1. Êส‹‹Çว¹น»ปÃรÐะ¡กÍอºบÁมÑัÅลµตÔิÁมÕีàเ´ดÕีÂย [ÃรÙู»ปÀภÒา¾พ] 2 ¡กÃร¡ก®ฎÒา¤คÁม 2555 1
  • 2. ia Systems 520251: Multimed Êส‹‹Çว¹น»ปÃรÐะ¡กÍอºบÁมÑัÅลµตÔิÁมÕีàเ´ดÕีÂย [ÃรÙู»ปÀภÒา¾พ] 2 ¡กÃร¡ก®ฎÒา¤คÁม 2555 1
  • 4. Raster Graphics vs Vector Graphics 3
  • 5. Raster Graphics vs Vector Graphics Raster graphics (bitmap image) 3
  • 6. Raster Graphics vs Vector Graphics Raster graphics Vector graphics (bitmap image) (drawing) 3
  • 7. Raster Graphics vs Vector Graphics Raster graphics Vector graphics (bitmap image) (drawing) 4
  • 8. Raster Graphics vs Vector Graphics Raster graphics Vector graphics (bitmap image) (drawing) 4
  • 9. Raster Graphics vs Vector Graphics Raster graphics Vector graphics (bitmap image) (drawing) 5
  • 10. Raster Graphics vs Vector Graphics Raster graphics Vector graphics (bitmap image) (drawing) 5
  • 12. ÀภÒา¾พáแºบºบ raster áแµต‹‹ÅลÐะ pixel ¤ค×ืÍอ¢ขŒŒÍอÁมÙูÅล 7
  • 15. »ป˜˜¨จ¨จÑัÂย·ท∙Õี่ºบ‹‹§ง¢ข¹นÒา´ด ¨จÓำ¹นÇว¹น pixel (resolution) lena_color_256.tif, 256x256, 201 KB lena_color_512.tif, ที่มา: http://www.imageprocessingplace.com/root_files_V3/image_databases.htm 512x512, 791 KB 10
  • 16. »ป˜˜¨จ¨จÑัÂย·ท∙Õี่ºบ‹‹§ง¢ข¹นÒา´ด ¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕี (color depth) lena_color_256.tif, lena_gray_256.tif, 256x256, 201 KB 256x256, 70 KB ที่มา: http://www.imageprocessingplace.com/root_files_V3/image_databases.htm 11
  • 25. CHAPTER 5 Color Palettes RGB COLOUR Figure 5.6. Images and their palettes pots of paint of a particular colour.When we use indexed colour, pixels don’t store a 24-bit colour value, but instead store a small number that identifies a 24-bit colour from the palette associated with the image. Just as each painting by numbers outfit includes only those paints that are needed to colour in one picture, so each palette includes only the 24-bit RGB values for the colours used 16
  • 26. Color Palettes 166 COLOUR 1A 1C 20 21 1F 1E If the palettes were interchanged, the 0D 16 17 1B 22 23 dark blue of the sea would turn maroon, 0A 13 09 15 18 1D and the maroon areas of the flower would 03 10 08 01 00 07 turn blue. The result of exchanging the 05 02 11 0E 04 06 entire colour tables between these two 10 14 0B 0C 12 09 images is shown in Figure 5.8. By swap- stored values ping the two tables we have in effect assigned an arbitrary palette to each 00 99141B image, which produces a visual incoher- 01 A0191C 02 A23E1A ence more pronounced than you would 03 A51B1C perhaps have expected. This illustrates 04 A51D1C just how important colour values are 05 A65619 in the representation and interpretation 06 A9191C of coloured images. It also shows why 07 A92E1C it is usually unwise to use an arbitrary 08 AB201C 09 AC111C colour palette, of course. 0A AC191D displayed pixels 0B AC4C1A If indexed colour is to be used, an 0C AC5219 image file needs to store the colour 0D AD111D table along with the actual image data, 0E AD331C but the image data itself can be smaller 0F AD401B Colour Lookup Table etc by a factor of three, since it only needs 8 bits per pixel. For any reasonably Figure 5.7. Using a colour table sized image there will therefore be a net saving of space. This saving may be increased further if the file format allows tables with fewer than 256 entries to be stored with images that have fewer colours, and uses the minimum number of bits required to index the 17 palette for each colour value.
  • 27. CHAPTER 5 Color Palettes RGB COLOUR 165 CHAPTER Figure 5.6. Images and their palettes 5 RGB COLOUR 167 pots of paint of a particular colour.When we use indexed colour, pixels don’t store a 24-bit colour value, but instead storeWhat can be that identifies a the areas offrom the palette associated a small number done with 24-bit colour with the image. Just as the image that should be includes onlyin each painting by numbers outfit displayed those paints that are needed to colour in one picture, so each palettewhich is not available invalues for the colours used some colour includes only the 24-bit RGB in one particular image. When the image is displayed, the colour from the palette corresponding the reduced palette? to each single-byte value stored at each pixel, is used as the colour of that pixel. Figure 5.6 shows two images with different colour characteristics, together with the palettes used when they are Obviously, any missing colour must be stored using indexed colour. replaced by one of those that is in the The mapping from stored values to colours can be efficiently implemented using a table. Hence, palette. There are two popular ways instead of trying to use 8 bits to hold an RGB value, we use it to hold an index into a table with 256 entries, each of which doing full 24-bit RGB colourto replace of holds a this. The first is value. For example, if a particular pixel was to be displayed as the colour whose 24-bit RGB value was #A23E1A, instead of storing that the colour value of each individual value in the image, wepixel store anthe colour table index of in which it was stored. could with index identifying the table location Supposing #A23E1A was held in the third entry of the table, the pixel would hold the offset 2 (see the colour closest to it. This can have Figure 5.7). Such an indexed table of colour values is called a colour table.The colours represented in the colour table make up the image’s palette,notthe colour table itself is Figure 5.8. called a undesirable effects: so only may the often loosely Exchanging the colour tables palette too. colours be distorted, but detail may be lost when two similar colours are With indexing, a colour value does not identify a colour absolutely, but only relative to a palette. replaced by the same one, and banding and other visible artefacts may appear where gradations It may help you to understand what is going on if you consider what would happen if the of colour are replaced by sharp boundaries. As we noted previously, these effects are collectively 18
  • 29. »ปÃรÐะàเ´ด็¹นµต‹‹Òา§งæๆ¢ขÍอ§ง raster graphics resolution x color depth àเ·ท∙¤คâโ¹นâโÅลÂยÕีÍอØุ»ป¡กÃร³ณàเ¡กÕี่ÂยÇว¡กÑัºบÀภÒา¾พ ¡กÒาÃร¾พÑั²ฒ¹นÒาàเ·ท∙¤คâโ¹นâโÅลÂยÕี image processing ÍอÑัÅล¡กÍอÃรÔิ¸ธÖึÁมàเ¾พ×ื่Íอ¡กÒาÃรáแÊส´ด§ง¼ผÅลÀภÒา¾พ ¡กÒาÃรºบÕีºบÍอÑั´ด¢ขŒŒÍอÁมÙูÅล 20
  • 31. Input 22
  • 32. Output 23
  • 33. Device Resolution ÍอØุ»ป¡กÃร³ณµต‹‹Òา§งæๆ¨จÐะÁมÕี¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ด¢ขÍอ§งÀภÒา¾พ·ท∙Õี่ÃรÑัºบ àเ¢ขŒŒÒาÁมÒาËหÃร×ืÍอáแÊส´ด§งÍอÍอ¡กäไ»ปÍอÂย‹‹Òา§งäไÃร¹นÑั้¹น ¢ขÖึ้¹นÍอÂยÙู‹‹¡กÑัºบ ¤คÇวÒาÁมËห¹นÒาáแ¹น‹‹¹น¢ขÍอ§ง¨จØุ´ดÀภÒา¾พ (pixel density) scanner ¨จÐะÁมÕี pixel density àเ»ปšš¹น dpi (dots per inch) àเÇวÅลÒา·ท∙Õี่àเÃรÒาàเÅล×ืÍอ¡ก«ซ×ื้Íอ ¨จÐะµตŒŒÍอ§ง¾พÔิ¨จÒาÃร³ณÒา spec Çว‹‹ÒาÊสÒาÁมÒาÃร¶ถÊสáแ¡ก¹นÀภÒา¾พ·ท∙Õี่¤คÇวÒาÁมÅลÐะàเÍอÕีÂย´ดàเ·ท∙‹‹ÒาäไÃร 24
  • 34. 25
  • 35. Scanner 26
  • 36. Scanner 26
  • 37. Scanners Flatbed Sheet-fed 27
  • 38. Scanners Handheld Drum Use photomultiplier tube (PMT) instead of CCD (read more on wiki) 28
  • 39. Scanned Image Size (in 24-bit color) Resolution image dimension (dpi) 1”x1” 4”x6” 8.5”x11” 72 15 KB 356 KB 1,420 KB 100 29 KB 703 KB 2,739 KB 300 264 KB 6,328 KB 24,653 KB 600 1,055 KB 25,313 KB 98,613 KB 29
  • 40. Device Resolution ãใ¹นàเ¤คÃร×ื่Íอ§ง inkjet printer ¨จÐะÁมÕี¡กÒาÃรºบ‹‹§ง resolution àเ»ปšš¹น lines per inch (lpi) àเ¹น×ื่Íอ§ง¨จÒา¡ก¡กÒาÃร¾พÔิÁม¾พËห¹นÖึ่§ง¨จØุ´ดÊสÕี (pixel) ¢ขÍอ§ง ÀภÒา¾พ¨จÐะ»ปÃรÐะ¡กÍอºบ´ดŒŒÇวÂย¡กÅลØุ‹‹Áม¢ขÍอ§งËหÁมÖึ¡ก 30
  • 42. density must be associated with a digital photograph, it is taken to be 72 dpi, to match the assumed resolution of a computer screen. As we will see in a moment, this is not very convenient. Image Resolution Image Resolution Now consider bitmapped images. An image is an array of pixel values, so it necessarily has pixel dimensions. Unlike a printed photograph or original artwork on paper, a bitmapped image has no physical dimensions. In the absence of any further information, the physical size of an image when it is displayed will depend on the pixel density of the device it is to be displayed on. pixel dimension For example, the image in Figure 4.1 is 198 pixels wide and 149 high. If it could be displayed physical dimension = at the nominal screen resolution of 72 dpi it would be 70 mm by 52.5 mm. Displayed without pixel density scaling on an actual monitor at 115 dpi, it will only be a little over 43.5 mm wide. If it is printed 72 dpi 70 mm x 52.5 mm 115 dpi 43.5 mm x 33 mm 600 dpi 8.5 mm x 0.25 mm Figure 4.1. Device resolution and image size Ex Libris ÃรÙู»ป¹นÕี้ÁมÕี resolution ·ท∙Õี่ 198 x 149 (WxH) apisake@gmail.com...................................................... © M a c Avo n M e d i a 32
  • 43. density is specified in pixels per inch, the physical dimension will be in inches, and so on.) It follows that if two images seem to be the same physical size on devices with different resolu- Image Resolution tions, the images must have different pixel dimensions. Since the pixels on the two devices are of different sizes, the images will display different amounts of detail. This is illustrated in Figure 4.2. 72 dpi, 198 × 149 px 600 dpi, 1654 × 1240 px Figure 4.2. Resolution and pixel dimensions 33
  • 46. 108 BITMAPPED IMAGES Figure 4.3. Scaling pixels the enlarged image undefined. This emphasizes that, in constructing a scaled-up image, we must use some interpolation method to compute values for some pixels. An alternative approach to performing the scaling is to compute the transformed image by finding a corresponding pixel in the original image for each pixel in the new image. The advantage 36
  • 47. CHAPTER 4 RESOLUTION 109 Figure 4.4. Scaling pixels using a reverse mapping of course, we combine the reconstruction and resampling into a single operation, because we can only work with discrete representations. We know that, for general images which may contain arbitrarily high frequencies because of sharp edges, the reconstruction cannot be done perfectly.We also know from sampling theory that 37
  • 48. CHAPTER 4 RESOLUTION 111 Figure 4.7. Nearest-neighbour (left), bilinear (middle) and bicubic (right) interpolation assumed to lie along a Bézier curve connecting the stored pixels, instead of a straight line. These are used for the same reason they are used for drawing curves: they join together smoothly. As a result, the resampled image is smooth as well. 38
  • 51. Anti-aliasing aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth jaggies 39
  • 52. Anti-aliasing aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth jaggies 39
  • 53. Anti-aliasing aliasing = ÃรÍอÂยËหÂยÑั¡กºบÃรÔิàเÇว³ณ¢ขÍอºบ anti-aliasing = ·ท∙ÓำãใËหŒŒ¢ขÍอºบ´ดÙู smooth jaggies 39
  • 54. Anti-aliasing ที่มา: http://flasheandoblog.wordpress.com/2009/11/29/flash- ที่มา: http://www.pixelburg.com/am_glossary/ performance-series-quality-adjustments/ 40
  • 55. Dithering aliasing = àเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÅลÇว§งµตÒาÁม¹นØุÉษÂยãใ¹น¡กÒาÃร (àเËหÁม×ืÍอ¹น¡กÑัºบ)àเ¾พÔิ่Áม»ปÃรÔิÁมÒา³ณ color depth ÀภÒาÂยãใµตŒŒ»ปÃรÔิÁมÒา³ณÊสÕี (color palette) ·ท∙Õี่ÁมÕี ¨จÓำ¡กÑั´ด ที่มา: http://en.wikipedia.org/wiki/Dithering 41
  • 56. Dithering aliasing = àเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÅลÇว§งµตÒาÁม¹นØุÉษÂยãใ¹น¡กÒาÃร (àเËหÁม×ืÍอ¹น¡กÑัºบ)àเ¾พÔิ่Áม»ปÃรÔิÁมÒา³ณ color depth ÀภÒาÂยãใµตŒŒ»ปÃรÔิÁมÒา³ณÊสÕี (color palette) ·ท∙Õี่ÁมÕี ¨จÓำ¡กÑั´ด ที่มา: http://en.wikipedia.org/wiki/Dithering 41
  • 57. 168 COLOUR Dithering Figure 5.9. Dithering in black and white If each pixel can be one of 256 different colours, instead of just black or white, then the corre- sponding patterns can simulate millions of colours. However, these simulated colours are, in effect, being applied to pixels four times the area of those actually on the screen. This means that the effective resolution of the image is being halved, resulting in a loss of detail. While this is usually acceptable for printing, where resolutions in excess of 600 dpi are common, it is often intrusive when images are being displayed on 72 dpi monitors. Other artefacts may also be generated when the patterns are superimposed; these can be minimized by clever choice of dot patterns for the generated colours, although this has the effect of cutting down the number of different colours that can be simulated. This leaves the question of which colours should be used in a palette. Ideally, you will fill the palette with the most important colours in your image. Often, these will be the most common, in which case it is easy for a program like Photoshop to construct the palette automatically by examining the original 24-bit version when it converts it to indexed colour. Sometimes, though, the use of colour will be more complex, and it may be necessary to construct the palette by hand (or, more likely, edit an automatically constructed palette), making subjective judgements to ensure that all the colours considered to be vital are present in the palette. Ex Libris apisake@gmail.com...................................................... © MacAvon Media ที่มา: http://commons.wikimedia.org/wiki/File:Dithering_algorithms.png 42
  • 58. Dithering ที่มา: http://en.wikipedia.org/wiki/Dithering 43
  • 59. Dithering ที่มา: http://en.wikipedia.org/wiki/Dithering 43
  • 60. Dithering ที่มา: http://en.wikipedia.org/wiki/Dithering 43
  • 61. Dithering ที่มา: http://en.wikipedia.org/wiki/Dithering 43
  • 63. Image Compression ion i s the omp ress Ima ge c data “ l icatio n of ages. app digi tal im ssio n on is to co mpre obje ctive n effe ct , the f the I nda ncy o d uce redu to be able re in o rder ge da ta data in an ima tran smit sto re or m....” to effi cien t for 45
  • 65. lossless 47
  • 67. hi-quality comp: 83,261 Bytes lossy lo-quality comp: 4,787 Bytes ที่มา: http://en.wikipedia.org/wiki/Jpeg 49
  • 69. JPEG 51
  • 71. JPEG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก ÍอÍอ¡กäไ»ป 51
  • 72. JPEG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก ÍอÍอ¡กäไ»ป àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด (âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย) 51
  • 73. JPEG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก ÍอÍอ¡กäไ»ป àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด (âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย) äไ¿ฟÅลàเÅล็¡กáแµต‹‹àเ¡ก็ºบÃรÒาÂยÅลÐะàเÍอÕีÂย´ดÊสÙู§ง 51
  • 74. JPEG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossy compression âโÂย¹น¢ขŒŒÍอÁมÙูÅลÊส‹‹Çว¹น·ท∙Õี่µตÒาÁม¹นØุÉษÂยÁมÍอ§งàเËห็¹น¤คÇวÒาÁมáแµต¡กµต‹‹Òา§งäไ´ดŒŒÂยÒา¡ก ÍอÍอ¡กäไ»ป àเ»ปšš¹นÃรÙู»ปáแºบºบäไ¿ฟÅล·ท∙Õี่¹นÔิÂยÁมãใªชŒŒãใ¹น www ÁมÒา¡ก·ท∙Õี่ÊสØุ´ด (âโ´ดÂยàเ©ฉ¾พÒาÐะÀภÒา¾พ¶ถ‹‹ÒาÂย) äไ¿ฟÅลàเÅล็¡กáแµต‹‹àเ¡ก็ºบÃรÒาÂยÅลÐะàเÍอÕีÂย´ดÊสÙู§ง àเ¡ก็ºบÀภÒา¾พÊสÕีäไ´ดŒŒËหÅลÒา¡กËหÅลÒาÂย¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕี 51
  • 79. 56
  • 80. 57
  • 81. JPEG vs JPEG2000 ที่มา: www.lithium.it/050702_ jp2_qualitvergl_e.jpg 58
  • 82. 59
  • 83. JPEG ☹ jpg gif not suitable for line drawing or images with text 60
  • 84. 61
  • 85. GIF 62
  • 88. GIF ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless compression (LZW) ¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕีäไ´ดŒŒàเ¾พÕีÂย§ง 8-bit àเËหÁมÒาÐะ¡กÑัºบÀภÒา¾พ·ท∙Õี่ÁมÕีÅลÑั¡กÉษ³ณÐะÅลÒาÂยàเÊสŒŒ¹น äไÁม‹‹àเËหÁมÒาÐะ¡กÑัºบ ÀภÒา¾พ¶ถ‹‹ÒาÂย 62
  • 89. GIF ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless compression (LZW) ¤คÇวÒาÁมÅลÖึ¡ก¢ขÍอ§งÊสÕีäไ´ดŒŒàเ¾พÕีÂย§ง 8-bit àเËหÁมÒาÐะ¡กÑัºบÀภÒา¾พ·ท∙Õี่ÁมÕีÅลÑั¡กÉษ³ณÐะÅลÒาÂยàเÊสŒŒ¹น äไÁม‹‹àเËหÁมÒาÐะ¡กÑัºบ ÀภÒา¾พ¶ถ‹‹ÒาÂย 62
  • 94. PNG 65
  • 97. PNG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless compression true color web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png 65
  • 98. PNG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless compression true color web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png ÊสÒาÁมÒาÃร¶ถÃรÍอ§งÃรÑัºบ transparency ·ท∙Õี่«ซÑัºบ«ซŒŒÍอ¹นäไ´ดŒŒ 65
  • 99. PNG ãใªชŒŒàเ·ท∙¤ค¹นÔิ¤ค¡กÒาÃรÂย‹‹Íอäไ¿ฟÅลáแºบºบ lossless compression true color web browser ÃรØุ‹‹¹นãใËหÁม‹‹æๆ Êส¹นÑัºบÊส¹นØุ¹น png ÊสÒาÁมÒาÃร¶ถÃรÍอ§งÃรÑัºบ transparency ·ท∙Õี่«ซÑัºบ«ซŒŒÍอ¹นäไ´ดŒŒ 65
  • 101. 67
  • 102. 68
  • 103. 69
  • 104. 70
  • 105. Digital Camera & VDO Camera 71
  • 106. Digital Camera & VDO Camera 71
  • 107. Digital Camera & VDO Camera 71
  • 108. Digital Camera & VDO Camera 72
  • 109. JPEG vs RAW • Normally, digital cameras save their images in the JPEG format. • Automatically adjusts: white-balance and all. • RAW format is exactly what the camera sees when it takes the picture; NO adjustments have been made to the images. BUT, the file is a lot bigger in size... 73
  • 110. Type of image Min resolution Camera Spec. Web images 640x480 1 megapixel + 5”x7” 2048x1536 3 megapixels + 8”x10” 2272x1704 4 megapixels + 16”x20” 3072x2048 6 megapixels + 74
  • 111. Editing Raster Images • Selecting an Area • Cropping • Image resizing & canvas size • Rotating • Adjusting the balance 75
  • 112. Editing Raster Images • Sharping the contrast • Adjusting the resolution • Saving and exporting 76
  • 114. Vector Graphics ? • An elegant way of constructing digital images whose representation is: • compact • scalable • resolution-independent • easy to edit 78
  • 119. 81
  • 120. 81
  • 121. Adobe Illustrator Scaleable Vector format Graphics format standard web vector graphics 82
  • 122. Fundamental • images are built up using shapes that can easily be described mathematically • therefore, reviewing the basic concepts are needed 83
  • 123. asily be described mathematically. ments of coordinate geometry, the vector graphics. For the benefit of Coordinates lines in terms of coordinates and 62 V E C TO R G R A P H I C S oncepts. 0 1 2 3 The coordi 0 1 2 3 4 5 6 7 xplained 0 O xzero and th and y coord y giving 1 1 in a device mber the 2 system whe mage to 3 B identifying 2 tified by 4 geometrica er and y 5 3 for exampl (2.35,2.95) at (7,3). 6 to any fini 7 A y with negat with negat Figure 3.1. Pixel coordinates Figure 3.2. Real coordinates and axes through th dinate of z the origin is the x-axis. We can label ..................... © MacAvon Media spaced points to produce the familiar g can easily be read off.Vector drawing p rulers) along the edges of your drawin 84
  • 124. Vectors FUNDAMENTALS 63 t only to define points, but x2 − x1 ement. For example, to get P 1 move 4 units to the right er way, −4 units down (the y2 − y1 P ). So we can specify the 2 − P r (4,−4). In general, for any 1 = (x2,y2), the displacement hich we write as (P2 − P1) P2 values is used to specify a two-dimensional vector. A Figure 3.3. A vector a magnitude (length). The − P2, since moving from P1 to P2 is different from moving in 1. They have the same length but opposite directions. 85
  • 125. Looking back at Figure 3.4, you will see that the staircase effect is a result of the Drawing a line pronounced contrast between black and white pixels. We can soften the effect by using intermediate grey values for some pixels. In terms of the frequency domain representation, we are removing the spurious high frequencies, and replacing them with lower frequencies. We cannot simply tone down the black 64 V E C TO R G R A P H I C S pixels to produce a grey line instead U Na blackEone; weSwant65 try to use a pixel approximation to a F of DA M N TA L Figure 3.5. The single to range of greys to somehow convey to the eye and brain of someone looking at straight line the displayed line an appearance of smoothness that cannot actually be achieved from these. A bit of simple algebraic manipulation, which many readers will representation in the the finitefrequency domain of (spatial) pixels. by clude infinitely high frequencies. Consequently, no have done at school, demonstrates that, if the line passes through (x1,y1) and ate to ensure perfect reconstruction. In other(x2,y2), m is equal to orientation of−the)pixel cgrid, at to (x2y1 − x1y2)/(x2 − x1). words, If we did not have to be concerned about the 2 1 (y − y )/(x2 x1 and is equal no matter how high the resolution that isa used for line coordinates of the shown in Figure 3.5. on their own to specify best we could produce smooth Hence, the one pixel wide, as end points are enough both the extent of the line and the constants in its equation, so they alone Our original attempt at rendering the line on the basis of its defining equa- would be used to represent the line. tion had the effect of setting to black those pixels whose intersection with this ancial considerations impose a limit on the available one-pixel-wide rectangle was at least half the area of the pixel. Anti-aliasing is tor graphics that are used in multimedia presenta-in a shade of necessary tobrightness vector drawing, the stored values are achieved by colouring each pixel it becomes grey whose render a is propor- When ed on a monitor with a resolution betweenintersection, as shown with the general form of the description of each class of tional to the area of the used, in conjunction in Figure 3.6. The number of 72 and sing may be readily visible. To reduce its impact is to set the values of but if we formthe grey of the object described. pixels that are no longer white a greater than before, pixels to take an image object, asing is often employed. and multiply the area of each one byathe value end points (0,31)the total 1), we could compute the pixels For example, if line has used to colour it, and (12, amount of greyness, as it y coordinatesame as that produced by only using aas x was stepped from 0 to were, is the corresponding to each integer value you will see that the staircase effect is acolour of Remember that a pixel’s coordinates magnifica- integers (whole numbers), single black level to result the original collection of pixels. At this are always 12. the en black and whitetion the We can soften the effect cannotifset the value book at part of a pixel. This means that the pixel pixels. result looks fairly incoherent, but you hold the of just arm’s length it and we values for some pixels. In terms of the frequencycan onlybeen subdued somewhat.ideal mathematical object which the should be apparent that the jaggedness has ever approximate the At normal image are removing the viewing resolutions anti-aliasing can significantly reduce example, the line just described has equation spurious high frequencies, and model describes. For aliasing effects, albeit vector at the expense of a certainy = 31 − 5x/2, so for any odd integer value of x, y must be rounded down to requencies. We cannot simply tone down thefuzziness. black Figure 3.4. Approximating get its corresponding integral value. The coordinates Figure 3.6. Anti-aliased Figure 3.5. The single of pixels along the line ne instead of a a straight line want to try to use a pixel approximation to a black one; we line would be (0,31), (1,28), (2,26), (3,23)….To get a continuous line, we set blocks convey to the eye and brain of someone looking at straight line of pixels to the desired colour of the line, but the height of the blocks alternates ance of smoothness that cannot actually be achieved between 2 and 3 pixels, so that the ideal straight line is approximated by an uneven staircase, as Ex Libris apisake@gmail.com...................................................... © MacAvon Media shown in Figure 3.4.This is inevitable, since the output devices we are using are based on a grid of 86
  • 126. VECTOR OBJECTS 67 Vector Objects program allows you to work with shapes is a reflection presented in graphics files. For example, in Illustrator you clicking the mouse or pressure-sensitive pen at each end ented by the coordinates of its end points. In SVG, which ram, a line can be represented by a line element, with the uch as <line x1="300" y1="0" x2="0" y2="300"/>. rograms provide (x1, y1) d in much the e different ways w = x2 − x1 68 V E C TO R G R A P H I C S nce, a rectangle an be drawn by h = y2 − y1 (x1, y1) own the mouse dragging to the ly be completely dra ry = (y2−y1)/2 (x2, y2) g rx = (x2−x1)/2 pposite corners, and where it is c = (x1+rx, y1+ry) s a rect element, M x1, y1 H x2 − x1 inates of the top dra (x2, y2) g which can easily V y1 − y2 he bottom right ple in Chapter 2 Figure 3.8. Drawing an ellipse ed as a sequence Squares and circles are special cases of rectangles and ellipses, respectively, and so do not need any ure 3.7.) As well V y2 − y1 special representation of their own. It is helpful when drawing to be able to ask the program to restrict rectangles and ellipses to squares and circles. In Illustrator this is done by holding down ent in SVG, this H x1 − x2 the shift key while using the rectangle or ellipse tool. gles in PDF and necessary values Figure 3.7. Drawing a rectangle Curves can be deduced Lines, rectangles and ellipses are sufficient for drawing many sorts of technical diagrams (particu- larly when your lines can be decorated with arrowheads, as they can be in all professional drawing programs). Less constrained drawing and illustration requires more versatile shapes, which are supplied by Bézier curves. appropriate tool and dragging from one point on the 87
  • 127. Curves CHAPTER 3 V E C TO R O B J E C T S 69 P2 P3 P4 P1 Figure 3.9. A cubic Bézier curve Bézier curves of degree 3, commonly called “cubic Bézier curves”, are the type most commonly found in vector graphics. They have just four control points: as always, two are the end points. The other two, which do not usually lie on the curve itself, are called direction points. The name indicates the purpose of these points: being on tangents to the curve, they show the direction in which it sets off from each end point. This is shown in Figure 3.9: P1 and P4 are the end points of 88
  • 128. hics. They have just four control points: as always, two are the end points. h do not usually lie on the curve itself, are called direction points. The name of these points: being on tangents to the curve, they show the direction in Curves each end point. This is shown in Figure 3.9: P1 and P4 are the end points of re its direction points, and you can see that the curve is accurately described s at P1, setting off towards P2, and curving round so that it arrives at P4 from aying within the quadrilateral convex hull P1P2P3P4 throughout. ines from each end point to its neigh- direction oint determine how wide a sweep the lines n think of the lengths of these lines as g d with which the curve sets off towards dra he faster it goes, the further out it will of the curve is the basis for the way wn interactively. After selecting the appro- pen), you click at the first end point and end points ds the first control point, as if you were dra ards it.You will usually see a direction line g you have pulled. In most applications, for explained in the next section, the direc- Figure 3.10. Drawing a curve with the pen nds away from the end point both in the tool d symmetrically in the opposite direction. 89
  • 129. Curves 70 VECTOR GRAPHICS P2 P3 P2 P3 P2 P3 P4 P4 P4 P1 P1 P1 Figure 3.11. P1, P2, P4, P3 Figure 3.12. P2, P1, P4, P3 Figure 3.13. P3, P1, P4, P2 Once you have the first one right, you click at the point where you want the curve to end, and drag away from the direction point (see Figure 3.10).You will see the curve being formed as you move the cursor. If you do not like the result when you have finished, you can subsequently select any of the control points and drag it around to change the shape and extent of your curve. For more information on drawing Bézier curves, consult our book Digital Media Tools. You can construct a cubic Bézier curve using any set of four control points, but the result is not necessarily going to be useful or lovely. Nor is it always obvious (until you have acquired some 90
  • 130. You can construct a cubic Bézier curve using any Curves necessarily going to be useful or lovely. Nor is it experience using these curves) exactly what the c to look like. Figures 3.11 to 3.13 show curves pro in Figure 3.9, but in different orders. P2 Bézier curves of degr only use one directio shown in Figure 3.14 cubic ones so they are P1 one fewer control po P3 are preferred in some to download are wan Figure 3.14. A quadratic Bézier curve curves – even though SWF graphics lets yo tool, these are approximated by quadratic curves curves are also used in TrueType fonts (see Chapt 91
  • 131. between them, as shown on the left of Figure 3.15. The join on the right is smoother still, because we have made sure that the length of the direction lines is the same on each side of P4. If you think of the line as a trajectory through space, this ensures that it passes through the shared end Paths point at a constant velocity, whereas, if we only make sure the three points are in a straight line, the direction is constant but the speed changes. The smoothness of joins when control points line up and direction lines are the same length is the reason behind the display of direction lines in drawing programs. When you drag away from an end point, as we saw earlier in Figure 3.10, direction lines are displayed both to and from it. In other words, you are shown two direction points: one belonging to the curve you are P2 P3 P2 P3 = P4 P4 P1 P5 P1 P7 P7 = P5 P6 P6 Figure 3.15. Joining two Bézier curves Ex Libris apisake@gmail.com...................................................... © M a c Avo n M e d i 92
  • 132. Figure 3.17 shows an open and a closed path. Open paths have end points, closed paths do not. Each individual line or curve is called a segment of the path; the points where segments join (the original end points of the segments) are called the path’s anchor points. Paths Because cubic Bézier curves can be drawn efficiently and they are so good at approximating other curved shapes, they are frequently used as the only curve-drawing primitive in graphics languages, even though programs generating documents in those languages may provide drawing tools for other shapes. In particular, PDF does not have any primitive operations for drawing anything but line and curve segments. Every object is built as a path made up of such segments. (In contrast, SVG has elements for all of the primitive shapes we described earlier.) This means that it is not Figure 3.17. An open path (left) and a closed one (right) Ex Libris apisake@gmail.com...................................................... © M a c Avo n M e d i a 93
  • 133. As we noted earlier, som natural media, such as ch as ribbons and Celtic d Strokes Figure 3.19. Dashed effects line, though, not by app As well as applying a stroke to a path, you c only fill a closed path, but most drawing pro 74 VECTOR GRAPHICS operation implicitly closes the path with a Combining different line caps with dash patterns provides a range of effects, The simplest fill is a sing as shown in Figure 3.19. fill (or, indeed, a stroke) Joins at corner points also need consideration, because wide lines can only This applies to a whit it. meet cleanly if they do so at 90°; when they meet at any other angle an Mitre shape on a white backgr unsightly gap or overlap will result. This can be removed in several ways. The three styles of line join provided by Illustrator are a mitre – as in a picture if it overlaps any oth but frame, the outside edges of the lines are extended to meet at a point; round – a you must explicitly set i circular arc is used to produce a rounded corner; and bevel – the segments are finished off square where they join, and the resulting notch is filled in with a triangle to produce a flat ended joint. If mitred joins are used on segments Rounded spikes will result. To avoid Normally, there is no that meet at a very narrow angle, long projecting you were using waterc this, a limit can be specified, and if the ratio of the spike’s length to the stroke width exceeds it, mitres will be replaced by bevels. Figure 3.20 illustrates the other possibilities, you c different joining styles. knock out areas of obje Bevel As we noted earlier, some drawing programs can apply strokes that simulate programs have allowed anything beneath it to natural media, such as charcoal or painted brush-strokes, or special effects, such as ribbons and Celtic designs. This is done by stretching an image along the Figure 3.19. Dashed effects Figure 3.20. Joining styles line, though, not by applying a stroke to it directly. sense to consider combi As well as applying a stroke to a path, you can use it as an outline and fill it. In principle you can only fill a closed path, but most drawing programsEx Librisyou to fill an open path – the filling also allow apisake@gmail.com............................ operation implicitly closes the path with a straight line between its end points. 94
  • 134. PTER 3 Fills VECTOR OBJECTS 75 ways, using blending modes – an established technique in bitmapped images, as discussed er 4. SWF, SVG and PDF all support transparency, with PDF having the most elaborate or blending modes. eresting and sometimes more attrac- ts than those permitted by solid or sparent colours can be produced by dient fills and patterns. Figure 3.21 me basic examples of gradient fills. e of fill is characterized by a gradual between colours or tones. In the case – a linear gradient – the colours end of a region are specified, and a lend of intermediate colours is gener- etween. provides controls to let you specify iate colours, adjust the midpoint of Figure 3.21. Linear (top) and radial (bottom) gradient fills ent (where the two colours being re of equal intensity) and the line along which the gradient varies, to get more compli- , such as the ones on the right of Figure 3.21. An alternative form of blending, shown ttom of Figure 3.21, has the colour varying outwards from a centre point to the outside . This is called a radial gradient. 95
  • 135. Fills 76 VECTOR GRAPHICS Figure 3.22. Gradient mesh made using the facilities provided by your drawing program (possibly including the facility to import bitmaps as objects, as described later).The name embodies the analogy normally employed for describing how an area is filled with a pattern. Imagine that the artwork is rendered onto a rectangular ceramic tile, such as you might use in your bathroom. Copies of the tile are arranged 96
  • 136. right, add one to the winding number; every time the path crosses from right to left, subtract one from the winding number. After all the crossings have Fills been counted, if the winding number is zero then the point is outside the path, otherwise it is inside. Note that this algorithm depends on the path’s having a direction, which will depend VECTOR OBJECTS 77 on the order in which anchor points were added to it. Figure 3.23. Pattern fills ws one answer the non-zero An alternative way of distinguishing hich may be the inside of a path from its outside is as follows. To the even–odd rule. Again, to determine nt is inside a whether a point is inside the path, a y infinite) line line is constructed from it, extending irection. Start in any direction. The number of path mber to zero. ne, and every segments crossing the line is counted. If from left to it is odd, the point is inside, if it is even, ding number; it is outside. es from right the winding For many shapes, including our example rossings have at the top of Figure 3.24, both rules ding number give the same result, but in some cases s outside the they will define the inside differently. de. Note that The lower pair of shapes in Figure 3.24 on the path’s shows a classic example. h will depend Figure 3.24. Filling complex shapes anchor points Figure 3.23. Pattern fills Ex Libris apisake@gmail.com...................................................... © M a c Avo n M e d i a distinguishing its outside is to determine 97
  • 137. Figure 3.25. Any modern drawing program will allow you to perform these transformations by direct manipulation of objects on the screen. For example, you would translate an object simply by dragging it to its new position. Transformation Figure 3.25 illustrates another feature of all vector graphics programs. Several objects – in this case, four coloured squares – can be grouped and manipulated as a single entity. Grouping may be implemented entirely within the drawing program, as a convenience to designers; it is also supported within some graphics languages, including SVG. In a related feature, some programs and languages allow an object or a group of objects to be defined as a symbol, which is a reusable entity. Figure 3.25. An object being scaled, rotated, reflected, sheared and translated Ex Libris apisake@gmail.com...................................................... © M a c Avo n M e d i a 98
  • 138. the y direction by sy, (x,y) must be changed to (sx x, sy y). (Valu object to shrink in the corresponding direction.) Thus, to do coordinates must be multiplied by two. However, this has the Transformation the object. (For example, if a unit square has its corners at moves them to (2,4) and (4,2), which are the corners of a squ is now in the wrong place.) To scale an object in place, the m suitable, easily computed displacement to restore it to its orig Rotation about the origin a y simple to achieve. To rotate a clockwise direction by an angl (x cos − y sin , x sin + y cos trigonometry if you wish). To reflect it in the x-axis, simp to (−x,y). When an object is sheared, it is x it upwards, through an angle , an angle (see Figure 3.26). Yo Figure 3.26. Skewed axes can be achieved by moving (x, y Applying these operations to all the points of an object will tr general operations of rotation about an arbitrary point and99re
  • 139. e-tune the shape of objects. s which fall between the highly structured transformations and Distortion l points are provided by way of parameterized commands in hese are referred to as filters, by analogy with the filters available n programs. An object is selected and an operation is chosen from osen filter is then applied to the selected object. es of Bloat ult is point then either effect o give Figure 3.27. Pucker and bloat .................................................. © MacAvon Media 100
  • 140. 3D Graphics 101
  • 141. 3D Graphics 84 VECTOR GRAPHICS Figure 3.28. Different two-dimensional views of a three-dimensional model 3-D graphics – as we call vector graphics based on three-dimensional models – is a complicated subject, though, requiring tools that are hard to master, and it should be left to specialists most of the time. Here, we can only outline the main features of 3-D technology, in order to provide an appreciation of the difficulties it presents and the opportunities it has to offer. In abstract mathematical terms, generalizing coordinate geometry from two dimensions to three is straightforward. The x- and y-axes of a two-dimensional coordinate system are perpendicular to 102
  • 142. In abstract mathematical terms, generalizing coordinate geometry from two dimension is straightforward. The x- and y-axes of a two-dimensional coordinate system are perpen each other. If you imagine drawing a set of axes on a flat sheet of paper and pinning it to 3D Graphics wall, you can see that we can place a third axis perpendicular to the other two, coming paper horizontally and projecting from the wall. Just as we can use x and y coordinates t point’s horizontal and vertical distance along the wall from the origin, we can use a z c measured along our third axis, to define its distance from the wall. The three coordinate define a point in three-dimensional space (see Figure 3.29). y The primitive geometrical shapes graphics are replaced by 3-D objects: a circle, we have a sphere; instead of a cube, and so on. By an obvious ex three-dimensional vector defines a disp using three components in the same (x, y, z) the two-dimensional vectors we us define displacements using two com x This allows us to describe translations in three-dimensional space. We certain basis for 3-D vector graphics, but we some new problems. z When we introduced a third dimen Figure 3.29. Axes in three dimensions stated that the z-axis points out of the Ex Libris apisake@gmail.com...................................................... © MacAvon 103
  • 143. described in terms of the set theoretical operators union, intersection and difference. These operations only affect two objects that are placed in such a way that they share some of the 3D Models space that they occupy – normally a physical impossibility, but no problem for a computer model. Their union is a new object made out of the space occupied by the two together.The intersection of two objects is the space that the two have in common. Finally, the difference of two objects is the space occupied by the first but not the second; this operation is useful for knocking holes out of solid objects. Figure 3.32 shows the objects formed by applying these operations to a vertical cylinder and a horizontal ellipsoid. (The shadows and tiled pattern are just cosmetic additions, which should help make it easier to see the third dimension in these illustrations.) The difference operation is not commutative: in Figure 3.32 we have taken the cylinder away from the ellipsoid. You would get a very different object by taking the ellipsoid away from the cylinder. Figure 3.32. The union, intersection and difference of two solid objects Ex Libris apisake@gmail.com...................................................... © MacAvon Media 104
  • 144. The simplest path is a straight line. A shape creates an object with a uniform cross-section as it travels along a straight line. For example, a circle creates a cylinder in this way. Figure 3.33 3D Models shows a slightly more elaborate example. This process is known as extrusion, since the objects it produces resemble those that can be made by industrial processes in which plastic or metal is forced out through an opening. Extruded text is one application of 3-D GRAPHICS been this technique that has 89 so widely used in producing corporate logos as Figure 3.33. Extrusion to have become a cliché. -dimensional ine a volume To produce more elaborate objects, a curved ong a path. path can be used, and the size of the cross- section can be altered as it moves along it. If ine. A shape the path is a conventional Bézier path, organic cross-section shapes can be generated. or example, a . Figure 3.33 If the path is a circle, the resulting objects xample. This exhibit radial symmetry. This special case is e the objects often called lathing because of the resemblance n be made by of the resulting objects to traditional turned artefacts. If a suitable shape is chosen, circular c or metal is paths can be used to generate many types of truded text is drinking vessel and vase, as well as mechanical hat has been components and, as Figure 3.34 shows, some orate logos as Figure 3.33. Extrusionhat. styles of Figure 3.34. Lathing The third approach to modelling is procedural modelling. Here, instead of using models that can cts, a curved be described by equations, and storing only the constants that define a particular instance, we use objects that are described by an algorithm or procedure. Thus, returning to two dimensions for a of the cross- moment, instead of defining a circle by the equation x2+y2 = r2, we could define it by some s along it. If procedure such as “draw a curve that maintains a constant distance r from the origin”. In this case, 105
  • 145. 3D Models 90 V E C TO R G R A P H I C S Figure 3.35. Constructing a well-known fractal curve tractable structure, algorithms may provide a description where equations cannot.The best known procedural modelling techniques are based on fractals. These are often described as shapes that exhibit the same structure at all levels of detail. Figure 3.35 shows a famous example of such a shape, and its construction. IN DETAIL 106
  • 146. 3D Models 92 V E C TO R G R A P H I C S Figure 3.39. Fractal terrain arbitrarily fine detail with the irregular appearance of natural terrain, as exhibited by the land- scapes in Figures 3.39 and 3.40. Rendering 107
  • 147. 3D Rendering CHAPTER 3 3-D GRAPHICS 93 Figure 3.40. Photo-realistic rendering Wire frames are often used as preview images in modelling programs. They can also be useful in computer-aided design systems, since they contain enough information to provide answers to questions such as “Does the door provide adequate clearance for the piano when it is fully open?”. 108
  • 148. to determine the orientations of objects unambigu- ugh an object, it becomes difficult or impossible to 3D Rendering u look at Figure 3.41, you can probably see the hat down on the side towards you. If you stare at it for er curve of the brim, you will probably be able to 2 demon- of a back- he object hen wire modelling in, neutral Figure 3.41. Wire frame rendering ...................................... © MacAvon Media 109
  • 149. 3D Rendering 94 VECTOR GRAPHICS Figure 3.42. Wire frame, flat, Gouraud and Phong shading In order to show the surfaces of objects, it is necessary to determine which of them are visible.The far sides of objects are considered hidden in perspective views, as are surfaces, or parts of surfaces, with other objects in front of them. Determining which surfaces are visible, starting only from 110