Vous êtes sur la page 1sur 96

Computer Graphics

W Computer graphic is generally


regarded as a branch of computer
science that deals with the theory and
technology for computerized image
synthesis.
W computer generated image can
depict simple objects such as outline of
geometrical shapes line triangles,
circle, curves, rectangles, square etc to
complex combination of above to
depict a picture.
ntroduction
W %o generate a picture, the computer
uses a set of description about an
object to a group of objects to from
an image.
W computer graphics is the interface
between the description of an object
or scene and image of that object or
scene using a computer.
PROCESS OF OBJEC% FORM%ON
W n object can be formed from basic
geometric primitives point, line,
polyline, polygon, filled regions.
W n point is a 1 D representation of a
location and expressed by a value in
a defined coordinate system (x, y) or
(rows, columns)
W line is represented by a set of two
points connecting them, where each
point is referent to as a vertices.
W polyline is a finite sequence of line
segments joined end to end. %hese
line segments are called edges.
W single line is a special case of poly
line having one segment.
W f a single line extends to infinity on
both side, it known as an infinite line
and is not considered as a polyline.
W ployline is called closed if it ends
at the point from where it had
started.
W t the poly lines do not self intersect,
then it is called a simple polyline
W simple closed poly line is called a
polygon
W polyline in the plane can be represented
simply as a sequence of (x, y) coordinates
of its vertices.
W %his is sufficient to encode the geometry
of the polygon
W %o render the polyline, a set of
determined properties known as graphical
attributes are required.
W %hese could be
line width,
line style and colour
connectivity between consecutive lines.
Filled regions
W ny simple closed polyline in the
plane defines a region consisting of
an inside and outside. ny such
region can be filled with a colour or
pattern.
W n some cases the bounding polyline
may be drawn then it is known as
polyline with boundary
W f the bounding polyline is not drawn
it is known as polyline without
boundary
W polyline with embedded notes also
naturally define a region that can be
filled.
%ext
W Generally not considered as a part of
graphics, yet it appears on
engineering diagrams.
W text can be through as a sequence
of characters in some font.
W Similar to polylines, there are a
number of attributes which define
how a text may appear.
W Font face - Times Roman
Helvetica
Courier etc.
W Font Weight - Normal
BoId.
W Font Style - Normal
Italics
W Font size - usually expressed
in point printer unit
- of an inch.
W Font colour - red, blue
72
1
RS%ER MGES
W n simple are it is a computer
generated image and is a 2 D array
of square or rectangular cells called
pixels. lso known as pixel maps.
W raster image is arranged in a raw
and column fashion to form a
rectangular picture area.
W %he total number of pixels in an
image is a function of the size of the
image and the number of pixel per
unit length both in horizontal and
vertical direction.
W %he number of pixels per unit length
is known as the resolution of the
picture.
W So it an image has 200 pixels per
inch and the size of the image is 43
inches, then the image will have 800
pixels in the horizontal directors and
600 pixel in the vertical direction and
total no. of pixels would be 480,000
pixels.
W Further more, each image conforms
to a certain norm of size known as
aspect ratio i.e. Horizontal size by
vertical size.
W %he standard value is 4/3 thus
standard image size are 640 by 480
pixels, 1024 by 768 pixels etc.
W
W %ypically, the image is defined by a
coordinate system with the lower left
corner being the origin so for a
640480 pixel.
(139,479)
(639,0) (0,0)
(0,479)
W simple example of image representation
is a black and white image consisting of
black & white pixel, where each pixel is
represented by a single bit.
W (0 for black and 1 for white). %his is known
as bit map.
W For gray scale images (or monochrome)
raster images, each pixel is represented
by assigning a numerical value over a
range (0 to 255 where 0 represent black
and 255 represents white)
W Further the image may be encoded
as colour images.
W Colour is a complex inter displinary
subject ranging from physics to
psychology.
COLOUR MODELS
W %he purpose of a colour model (also
called colour space or colour system)
is to facilitate the specification of
colours in some standard, generally
accepted way.
W n essence, a colour model is a
specification of a coordinate system
and a subspace within that system
where each colour is represented by
a single point.
W Most colour models in use today are
oriented either toward hardware
(such as for colour monitors and
printers) or toward application where
colour manipulation is a goal (such
as in the creation of colour graphics
for animation).
W Hardware-oriented models most
commonly used in practice are the RGB
(red, green, blue) model for colour
monitors and a broad class of colour
video cameras;
W CMY (cyan, magenta, yellow) and CMYK
(cyan, magenta, yellow, black,) models
for colour printing; and
W HS (hue, saturation, intensity) model,
which corresponds closely within the way
humans describe and interpret colour.
W %he HS model also has the advantage
that it decouples the colour and gray-
scale information in an image, making
it suitable for many of the gray-scale
techniques.
The RGB modeI
W %echnology for creating and
displaying colour is based on the
empirical observation that a wide
variety of colours can be obtained by
mixing red, green and blue light in
different proportions.
W For this reason, red (R), green (G)
and blue (B) are described as the
primary colours of the additive colour
system.
W However not all colours can obtained
in this way.
W %hus, colour image can be formed by
making three measurements of scene
brightness at each pixel using the red,
green and blue components of the
detected light.
W %his can be done either using a colour
camera where the sensor is able to
measure radiation at red, green and blue
wavelengths for all points in the image
W or by using a monochrome camera in
conjunction with three special filters that
blocks all but a narrow band of
wavelengths centered on red, green and
blue, respectively.
W n a colour image conforming to the RGB
model, the value of each 1 (x, y) is a
vector of three components,
corresponding to R, G and B.
W n a normalized model, these components
can vary between 0.0 and 1.0.
W R, G and B can be regarded as
orthogonal axes defining a three-
dimensional colour space.
W Every possible value of 1 (x, y) is a point in
this colour -cube
Magenta
(1,0,1)
Red (1,0,0)
BIue (0,0,1)
Cyan (0,1,1)
YeIIow (1,1,0)
BIack (0,0,0)
White
(1,1,1)
G
B
R
1
1
1
0
Green (0,1,0)
Fig 2.6 The RGB CoIour ModeI
W %he primary colours red, green and blue
are at the corners (1, 0, 0), (0, 1, 0) and
(0, 0.1);
W the colours cyan, magenta and yellow
are at the opposite corners while black
is at the origin and white is at the corner
furthest from the origin.
W Points on a straight line joining the
origin to the most distant corner
represent various shades of grey.
W Since each of the three components red,
green and blue is normally quantized
using 8 bits, an image made up of these
components is commonly described as a
24-bit colour image.
W s each primary colour is represented to
a precision of 1 part in 256, it is possible
to specify any arbitrary colour to a
precision of about 1 part in 16 million.
W Hence, in a 24 bit image 16.7 million
colours are available.
CMY ModeI
W %he CMY model has as its primaries
cyan (C), magenta (M) and yellow (Y).
W %hese are the primary colours of the
subtractive system that describes how
colour is produced from pigments.
W CMY colour is derived from an RGB
colour as follows:

1
1
1

1
1
1

1
1
1

1
1
1
W %heoretical almost any colour can be
produced on paper by mixing cyan,
magenta and yellow pigments.
W However this approach cannot produce
a satisfactory black, so a fourth
component labelled as and
representing black pigment is added,
resulting in the CMYK model.
W %his is the model that is used when
generating hardcopy versions of digital
images using colour printers.
SI ModeI
W HS model is more suitable than the RGB
model for many image processing tasks.
W %he three components are hue (H),
saturation (S) and intensity (I).
W H and S specify colour where
W H specifies the dominant pure colour as
perceived by an observer
W S measures the degree to which that pure
colour has been diluted by white light.
W Since colour and intensity are
independent, it is possible to manipulate
one without affecting the other.
W HS colour space is
described by a cylindrical
coordinate system and is
commonly represented as a
'double cone'.
W colour is a single point
inside or on the surface of
the double cone, while the
height of the point
corresponds to intensity.
W f a point lies in a horizontal
plane, a vector can defined
in this plane from the axis of
the cones to that point, the
saturation is the length of
this vector and hue is its
orientation, expressed as an
angle in degrees.
I
Green
S
H
Cyan
Blue
Magenta
Yellow
Red
black
White
SI ModeI
Conversion of coIour
RGB to SI
W Given an image in RGB colour
format, the Hue (H) component of
each RGB pixel is obtained by using
the equation
W Hue can be normalized to the range
[0,1] by dividing by 360
0
all values

=
iI 360
iI
H

Where
%he saturation (S) component is given by
and, the intensity (I) component is given by
)
)

R R
R R
2
1
cos
2 / 1
2
1

+
+
=


) R min
R
3
1 S
+ +
=
R
3
1
I + + =
W t is assumed that the RGB values
have been normalized to the range [0,
1] and that angle is measured with
respect to the red axis of the HS
space,.
W %he other two HS components already
are in this range if the given RGB
values are in the interval [0,1].
SI to RGB
W Given values of HS in the interval [0,1], find
the corresponding RGB values in the same
range.
W %he %ransforming equations depend on the
values of H.
W %here are three sectors of interest,
corresponding to the 120
o
intervals in the
separation of primaries .
W First multiply H by 360
0
, such that the hue
returns to its original range of [0
0
, 360
0
].
W Depending on the value of H, three cases can
be defined.
Case I
W f Hue (H) has value between 0
0
to 120
0
i.e., H is
between Red and Green colour,
W the RGB components can be expressed by the
following equations:
S 1 ( I =

+ =
H 60 cos
H cos S
1 I R
0
R ( 1 + =
R
G
B
Case II
W f the colour point is located such that Hue lies
within the range of (120
0
<H <240
0
) i.e., Hue is
within GB sector than first subtract 120
0
from it:
0
120 H H =
R
G
B
%hen the RGB components are
calculated as
and
S 1 ( I R =

+ =
H 60 cos
H cos S
1 I
0
R ( 1 + =
Case III
W f the colour point is located such
that Hue lies (240
0
<H<360
0
), then
BR sector i.e., H is in this range, first
subtract 240
0
0
240 H H =
R
B
(c)
W %hen the RGB components are computed
as following
S 1 ( I =

+ =
H 60 cos(
H cos S
1 I
0
( 1 R + =
IMAGE FILE FORMATS
IMAGE STORAGE
W Short term storage
W Online Storage
W rchival Storage
Generally memory based monitors.
t is fast to display and is volatile in nature
destroys with shut down of power supply.
Non valitile and relatively rapid display.
Storage within the computer' own hard disk.
Cheaper than short term storage.
Used for long term storage on removable media.
Data access is slow.
Data can be exchanged easily.
FILE FORMAT
W When placing an image, suitable format is
needed so that the image data can be
read properly.
W t determines How the data stored
W dditional information regarding the image
SIMPLE MODEL
eader
Image fiIe
Header - Width & height of the image pixel
- Signature or magic number to identify it as an
image file & format type.
Categories of FLE formats
W Device speciaIized
Formats
W Specific to pieces of Hardware.
W %he structure allows for rapid display.
W No portability between systems or
machines is possible.
W nefficient
W Obselete when hardware or OS
changes.
W Designed by software specialist.
W Designed to facilitate exchange of
image data between users through
various media and computer networks.
W Usable with the widest possible range
of hardware & software.
W mage compression is a standard
feature reduces storage
requirements and transmission times.
WSoftware Specialised
Format
WInterchangeable Format
COMMON INTERCANGEABLE FORMATS
i) BMP (Bitmap)
ii) %FF (%agged mage File
Format)
iii) GF (Graphics
nterchangeable Format)
iv) JPEG ( Joint Photographic
Expert Graphics)
v) PNG (Portable Network
Graphics)
W Essentially an image is in the form of bitmap, i.e. an array of
pixel values.
W For a B&W image, it is just grid of pixels where each pixel is
either ON/OFF or B/W.
BMP (Bit Map)
W For b/w printers and monitors .
W With CG, EG and then VG screens capable of showing
16, 64 and 256 different colours, the simple on-off bitmap was
no longer adequate.
W %he solution was simple enough increase the bit-depth.
W Rather than storing one pixel value per bit - simply allocate
more bits per pixel.
W With two bits you could define four colours, with three you
could define eight and by the time you reached 8-bits you had
the necessary 256.
W Various bitmap standards emerged to support the new
display-based demands, such as PCX, but the most important
survivor today is Microsoft's BMP, Windows' native bitmap
format.
BMP (Bit Map)
BMP format was successful for its support for indexing
through 4 and 8-bit palettes.
Rather than storing each o1 the necessary RGB values 1or
each pixel, Microso1t instead added 1irst a 1ixed and then a
customisable palette to its BMP 1ormat.
Each pixel's colour could then be defined by storing its
associated index number rather than the much longer RGB
value.
%his look-up table approach is inherently more e11icient 1or
handling images with up to 256 colours as each pixel can be
stored in eight bits o1 in1ormation rather than twenty 1our
DISADVANTAGES
BMP never took off as a universal 24-bit true colour
standard as it is inefficient when photographs are to
handled and printed .
ts compression scheme is typical.
%he only compression BMP offers is Run Length
Encoding (RLE) which works by taking repeated
sequences and expressing them in two bytes so that
three hundred white pixels in a row can be represented
as 300W.
TIFF (Tagged Image File Format)
W xtendibility.
W the ability to add new image types without
invalidating older types
W to add new informational fields to the format
without impacting the ability of older applications
to read the image files.
W Designed to be independent of the hardware
platform and the operating system on which it
executes.
W %FF makes very few demands upon its operating
environment - perform equally well in both the "BM
and pple Macintosh's environments and UNX.
W %FF is designed to be an efficient medium for
exchanging image information.
W to be usable as a native internal data format for
image editing applications.
W %he %agged mage File Format (%FF) was designed from the ground up
to alleviate the problems associated with fixed file formats.
W %FF file format had three important goals in mind:
WPortability.
WRevisability.
Features
W olour spaces
supported includes.
Grayscale Pseudocolor (any size)
RGB YCbCr CMYK CELab
Raw uncompressed PackBits
Lempel-Ziv-Welch (LZW)
CC%% Fax 3 & 4 JPEG
1-64 bit integer, signed or unsigned
32 or 64 bit EEE floating point
W %heoretically, %FF can support imagery with multiple bands (up to
64K bands), arbitrary No. of bits per pixel, data cubes, and multiple
images per file, including thumbnail subsampled images.
W ompression
%ypes include.
W Pixel 1ormats
supported include
TE TIFF FILE STRUCTURE
W %FF files are made up of three unique
data structures.
W %he first data structure found in every %FF
file is called the mage File Header (FH).
W %his structure is the only portion of a %FF
file that has a fixed location.
W %his 8-byte structure must be located at
offset zero in the file.
W %his field indicates the byte-ordering that was used when the %FF file was
created. %his is especially important because %FF files can be moved
between the BM PC world (based upon ntel processors) and the
Macintosh world (based upon the Motorola series of processors).
8-byte structure Iocated at
start of image fiIe
W %he FH contains important information
necessary to correctly interpret the
remainder of the %FF file.
W %he first field within the FH, and
possibly the most important, is the byte-
ordering field.
TE TIFF FILE STRUCTURE
W Without knowing the order of bytes used when an
image file is created, a %FF file reader would have little
hope of recovering the image.
W %his ordering affects any items read from a %FF file
that are longer than one byte in length.
W I1 the byte ordering utilized in the 1ile di11ers 1rom that o1
the computer on which the image 1ile is being read, all
subsequent 16- and 32-bit integer values will have to
have their byte ordering reversed.
W I1 the byte ordering is the same, integer and long values
can be read and used without modi1ication.
TE TIFF FILE STRUCTURE
Wll current data-compression methods utilized by the %FF
standard are byte oriented.
Wf a word- or integer-oriented compression method is utilized,
byte ordering of the image data would have to be taken into
consideration as the data is read from the file.
WSwapping each word of compressed image data as a file is
being read would be a computationally expensive process.
%he next 1ield in the IFH always contains the decimal value
o1 2
10
. %his 1ield can be used to 1urther veri1y that a 1ile is a
%IFF 1ile.
TE TIFF FILE STRUCTURE
W %he final field in the FH
contains the offset in
bytes from the start of the
file to the mage File
Directory, or FD,
structure.
W %his is the second of the
three data structures
contained in a %FF file.
Directory Entry, or DE
W t is the final data structure
within the %FF file format. t is
the format of the DE's that gives
%FF its flexibility.
W Each DE is exactly 12 bytes in
length and is segmented into
the four fields shown in Fig.1
W %he first field of the DE is the
tag field.
W s the full name of this image-
file format indicates, the tag is
the foundation on which this file
structure is based.
W %he raster data contained in a
%FF file is defined by the tags
to which it is attached.
Directory Entry, or DE
W n all, 45 tags are defined in version 5.0 of the %FF
specification.
W %he final field in a DE is the "value offset" field. %his field
usually contains the file offset to the actual data
associated with the tag.
W n other words, the data associated with a DE does not
have to be physically stored with the DE but can reside
anywhere in the %FF file.
dvantages of a %agged mage File
a. pplication programs such as %FF readers can sa1ely
ignore any tags they do not understand.
b. New tags can be added at any time without invalidating any
of the older tags. n a sense, this prevents the %FF file
format from becoming obsolete.
c. Private tags can be defined to contain proprietary
information within a %FF file without affecting other
application programs. %he tags with values between 32,768
and 65,535 are reserved for just this purpose.
%FF Data Compression
W s pointed out earlier, bit-mapped images require an
incredible amount of memory for storage.
W %o reduce the size of %FF image files, the %FF
specification recommends support for four different types
of data compression.
W %FF writer must support at least one of the
compression methods.
W %FF reader should be able to understand all of the
compression methods.
W %he method utilized to compress an image is stored in
the "compression" tag.
W %FF reader must read the "Compression" tag to
determine the type of data expansion to apply to the
raster data contained in the %FF file.
%FF Classes
W %FF's extreme flexibility places a burden on software
developers who support this format.
W t requires a considerable amount of code to handle all of
the options available.
W n application program wanting to import any %FF image
has no choice other than to handle all of the options.
W %hat is the only way to guarantee the image can be
displayed exactly as it was produced.
W %o reduce some of this burden, %FF version 5.0 has
introduced the concept of %IFF con1ormant classes.
%FF Categories
W n general, three different categories of images can be
contained in a %FF file.
W %hese are:
a. Black and white images. %hese utilize one bit Per pixel
for display.
b. Gray-scale images. %hese utilize between two and
eight bits per pixel, which results in 4 to 256 levels of
gray available in an image.
c. olor images. %hese are of both the palette and RGB
varieties, with up to 24 bits of color data per pixel.
%FF Classes
W %he %FF classes quantify which image types fit into which
class along with the compliment of %FF tags required by
each class.
W Four %FF Classes are defined:
W Class B (also called %FF B) for bi-level, 1-bit images
W Class G (also called %FF G) for gray-scale images
W Class P (also called %FF P) for palette-color images
W Class R (also called %FF R) for RGB full-color images
W %FF X class combines all four of the above.
General %ags in %FF
W ll %FF classes are required to support the following tags:
1. NewSubfile%ype
2. lmageWidth
3. mageLength
4. RowsPerStrip
5. StripOffsets
6. StripByteCounts
7. XResolution
8. YResolution
9. ResolutionUnit
LIMITATIONS
W %here are no provisions in %FF for storing vector graphics,
text annotation, etc.
W %FF is based on file-offsets, so that it is not easily
"streamable" in the way JPEG JFF streams are.
W common complaint of %FF is rooted in its flexibility. For
example the %FF format permits both MSB ("Motorola") and
LSB ("ntel") byte order data to be stored, with a header item
indicating which order is used.
W t is very easy to write a %FF-writer, but very difficult to write
a fully %FF compliant reader.
W %FF uses 4-byte integer file offsets to store image data,
with the consequence that a %FF file cannot have more
than 4 Gigabytes of raster data.
Strengths
W %FF is primarily designed for raster data interchange. t's
main strengths are a highly flexible and platform-
independent format which is supported by numerous image
processing applications.
W Since it was designed by developers of printers, scanners
and monitors, it has a very rich space of information
elements for colorimetry calibration, gamut tables, etc.
W nother feature of %FF which is also useful is the ability to
decompose an image by tiIes rather than scanlines.
W %his permits much more efficient access to very large
imagery which has been compressed (since one does not
have to decompress an entire scanline).
GF (Graphic nterchange Format)
%he %FF's flexible nature has a further drawback in that its
tag-based structure inevitably adds an overhead to each
file.
For print work that's a price well worth paying, but it's not
acceptable for Web work where every byte counts.
%he main format that has come to dominate the here is the
GF (Graphic nterchange Format) thanks to its combination
of palette-based indexing and LZW compression.
GF can contain a maximum of 256 colours with an 8-bit
palette though, unlike other formats, takes full advantage of
storing fewer colours at lower bit-depths as well.
%he fact that the number of colours is restricted
automatically suits the typical flat-colour GF for LZW
compression.
dvantages of GF
W typical 8-bit image, can be losslessly compressed by
40% or more.
W part from this minimised file size, the GF format offers
a number of other optimisations for browser-based
display.
W %he use of interlacing, for example, means that all even
scan lines are stored first and then the odd rows are
split into three so that the image appears in four passes
in a venetian blind effect.
W %he advantage is that the viewer can interpret the
whole image after only 50% of the data has
downloaded.
Disadvantages of GIF
W %he problem is that GF by its nature falls between two
stools. On the one hand its palette-based nature is really only
optimised for images based on flat areas of colour, which
would in fact be better handled through a vector format.
W On the other hand, for continuous tone photographic images,
where pixel-based handling is the only option, the format's
256-colour limit and LZW compression are hopelessly
unsuitable resulting in both poor image quality and large files.
W n fact it was to solve just this problem that the fourth of the
crucial bitmap standards, JPEG, was developed back in
1987 by the Joint Photographic Experts Group who gave it its
name.
PEG
W t is a standardized image compression mechanism.
W JPEG stands for oint Photographic Experts Group, the
original name of the committee that wrote the standard. JPEG
is designed for compressing either full-color or gray-scale
images of natural, real-world scenes.
W t works well on photographs, naturalistic artwork, and similar
material; not so well on lettering, simple cartoons, or line
drawings. JPEG handles only still images, but there is a
related standard called MPEG for motion pictures.
PEG
W JPEG is "lossy," meaning that the
decompressed image isn't quite the same as
the one you started with.
W useful property of JPEG is that the degree
of lossiness can be varied by adjusting
compression parameters.
W %his means that the image maker can trade
off file size against output image quality.
PEG
W You can make *extremely* small files if you
don't mind poor quality; this is useful for
applications such as indexing image archives.
W Conversely, if you aren't happy with the
output quality at the default compression
setting, you can jack up the quality until you
are satisfied, and accept lesser compression.
Why use JPEG Format
%here are two good reasons:
W to make your image files smaller,
Making image files smaller is an advantage for
transmitting files across networks and for archiving
libraries of images.
Being able to compress a 2 Mb full-color file down to, say,
100 Kbytes makes a big difference in disk space and
transmission time! nd JPEG can easily provide 20:1
compression of full-color data. f you are comparing GF
and JPEG, the size ratio is usually more like 4:1
Why use JPEG Format
W to store 24-bit-per-pixel color data instead of 8-bit-per-pixel
data.
%he second fundamental advantage of JPEG is that it
stores full color information: 24 bits/pixel (16 million
colors).
GF, the other image format widely used on the net, can
only store 8 bits/pixel (256 or fewer colors).
JPEG photos look much better than GF.
JPEG is far more useful than GF for exchanging images
among people with widely varying display hardware
BRIEF ISTORY OF PNG
%he original specification for PNG was written by %homas
Boutell and %om Lane, with contributions by many others.
On 15 January 1997 it was released by the E%F as RFC
2083.
%he new sections in version 1.1 of the spec were largely
written by dam Costello and Glenn Randers-Pearson; it
was released by the PNG Development Group on
31 December 1998.
Short for Portable Network Graphics, and pronounced
ping, is a new bit-mapped graphics format similar to GF.
n fact, PNG was approved as a standard by the World
Wide Web consortium to replace GF because GF uses
a patented data compression algorithm called LZW.
n contrast, PNG is completely patent- and license-free.
%he recent versions of Netscape Navigator and Microsoft
nternet Explorer now support PNG.
GENERAL
Image DetaiIs
W PNG image is a rectangular pixel array, with pixels appearing left-
to-right within each scanline, and scanlines appearing top-to-bottom.
W t has an alpha channel, representing transparency information on a
per-pixel basis, for grayscale and true color PNG images.
W n alpha value of zero represents full transparency, and a value of
(2
bitdepth
)-1 represents a fully opaque pixel. ntermediate values
indicate partially transparent pixels that can be combined with a
background image to yield a composite image. (%hus, alpha is really
the degree of opacity of the pixel).
W t allows the image data to be 1iltered before it is compressed as it
improves compressibility of the data. ll PNG filters are strictly
lossless.
W PNG images can specify, via the gM chunk, the gamma
characteristic of the image with respect to the original scene.
File Structure
W PNG File Signature :-
%he first eight bytes of a PNG file always contain the
following (decimal) values:

%his signature indicates that the remainder of the file
contains a single PNG image, consisting of a series of
chunks beginning with an HDR chunk and ending with
an END chunk.
Each Chunk Consists of Four Parts
Length
W 4-byte unsigned integer giving the number of bytes in the
chunk's data field.
W Zero is a valid length.
W lthough encoders and decoders treat the length as
unsigned, its value must not exceed (2
31
)-1 bytes.
Structure of Chunk
Structure of Chunk
W Chunk %ype
4-byte chunk type code.
For convenience in description and in
examining PNG files, type codes are
restricted to consist of uppercase and
lowercase SC letters (-Z and a-z, or 65-90
and 97-122 decimal).
Structure of Chunk
W Chunk Data
%he data bytes appropriate to the chunk type, if any.
%his field can be of zero length.
W CRC
4-byte CRC (Cyclic Redundancy Check) calculated on
the preceding bytes in the chunk, including the chunk
type code and chunk data fields, but not including the
length field.
%he CRC is always present, even for chunks containing
no data
Chunk Specifications
valid PNG image must contain an HDR chunk, one or
more D% chunks, and an END chunk.
HDR mage Header
%he HDR chunk must appear FRS%.
t contains:
Width : 4 bytes
Height : 4 bytes
Bit depth : 1 byte
Color type : 1 byte
Compression method : 1 byte
Filter method : 1 byte
nterlace method : 1 byte
Chunk Specifications
PLTE PaIette
The PLTE chunk contains from 1 to 256 paIette entries,
each a three-byte series of the form:
Red : 1 byte (0 = bIack, 255 = red)
Green : 1 byte (0 = bIack, 255 = green)
BIue : 1 byte (0 = bIack, 255 = bIue)
IDAT Image Data
W D% chunk contains the actual image data.
W Multiple D% chunks allowed so that encoders can work in
a fixed amount memory size.
W f so they must appear consecutively with no other
intervening chunks.
W D% chunk boundaries have no semantic significance &
can occur at any point in the compressed data.
END mage %railer
W %he END chunk must appear LS%.
W t marks the end of the PNG data stream.
W %he chunk's data field is empty.
ncillary Chunks
W ll ancillary chunks are optional, in the sense that
encoders need not write them and decoders can
ignore them.
W However, encoders are encouraged to write the
standard ancillary chunks when the information is
available, and decoders are encouraged to interpret
these chunks when appropriate and feasible.
W %he bKGD chunk specifies a default background color
W For color type 3 (indexed color), the bKGD chunk contains:
Palette index: 1 byte
W For color types 0 and 4 (grayscale, with or without alpha),
bKGD contains: Gray: 2 bytes, range 0 .. (2
bitdepth
)-1
W For color types 2 and 6 (true color, with or without alpha),
bKGD contains:
W Red : 2 bytes, range 0 - (2
bitdepth
)-1
W Green : 2 bytes, range 0 - (2
bitdepth
)-1
W Blue : 2 bytes, range 0 - (2
bitdepth
)-1
bKGD or Background coIor Chunk
W Used for applications that need device-independent
specifications of colors in a PNG file.
W Can specify the x,y chromaticities of red, green and blue
primaries used in the image.
W t contains :-
W White Point x : 4 bytes
W White Point y : 4 bytes
W Red x : 4 bytes
W Red y : 4 bytes
W Green x : 4 bytes
W Green y : 4 bytes
W Blue x : 4 bytes
W Blue y : 4 bytes
cRM Chunk
W Specifies the gamma of the camera that produced
the image
W Must precede the first D% & PL%E Chunk
W t contains :-
Image Gamma : 4 Bytes
hIST Chunk
W mage histogram chunk gives the approximate usage
frequency of each color in the palette.
W Can appear only if a palette chunk appears
W t must follow the PL%E chunk and precede the first D%
chunk.
gAMA Chunk
tEXT Chunk
W %extual info that the encoder wishes to record with the image can
be stored in it.
W Each tEX% chunk contains a key word and a text string in the
format:-
W Keyword: 1-79 bytes (character string):
W %itle Short (one line) title or caption for image
W uthor Name of image's creator
W Description Description of image (possibly long)
W Copyright Copyright notice
W Creation %ime %ime of original image creation
W Software Software used to create the image
W Disclaimer Legal disclaimer
W Warning Warning of nature of content
W Source Device used to create the image
W Comment Miscellaneous comment;
W Null separator: 1 byte
W %ext: n bytes (character string)
W %he tME chunk gives the time of the last image modification
W t contains :-
W Year : 2 bytes (complete; for example, 1995, not 95)
W Month : 1 byte (1-12)
W Day : 1 byte (1-31)
W Hour : 1 byte (0-23)
W Minute : 1 byte (0-59)
W Second : 1 byte (0-60)
tIMEChunk
W The pYS chunk specifies the intended pixeI size or
aspect ratio for dispIay of the image.
W It contains :-
PixeIs per unit, X axis: 4 bytes (unsigned integer)
PixeIs per unit, Y axis: 4 bytes (unsigned integer)
Unit specifier: 1 byte
pYS Chunk
Summary of Chunks
:3s (m:st appear i3 tis order, except PLTE is optio3al)
Name M:ltiple Orderi3g o3strai3ts
IHDR No M:st be first
PLTE No Before IDAT
IDAT Yes M:ltiple IDAT's m:st be co3sec:tive
IEND No M:st be last
cHRM No Before PLTE & IDAT
gAMA No Before PLTE & IDAT
bKGD No After PLTE & before IDAT
tEXt Yes No3e
tIME No No3e
pHYS No None

Vous aimerez peut-être aussi