Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Bitmapped Images
Created : Rawesak Tanawongsuwan itrtw@mahidol.ac.th Modified : Damras Wongsawang itdws@mahidol.ac.th
Bitmapped Images
Also known as raster graphics Record a value for every pixel in the image Often created from an external source
Scanner, digital camera,
Painting programs allow direct creation of images with analogues of natural media, brushes,
Resolution
A measure of how finely a device approximates continuous images using finite pixels (density of dots or pixels)
299
755
Device Resolution
Printers, scanners: specify as dots per unit length, often dots per inch (dpi)
Desktop printer 600 dpi, typesetter 1270 dpi, scanner 300 3600 dpi,
Image Resolution
Array of pixels has pixel dimensions, but no physical dimensions By default, displayed size depends on resolution (dpi) of output device
physical dimension = pixel dimension image resolution
Can store image resolution (ppi) in image file to maintain image's original size
Scale by displaying device resolution original device resolution
Resolution Calculation
128-pixel line displayed 6 x 4 inches image scanned at 600 dpi at 72 dpi 45 mm 3600 x 2400 pixels at 115 dpi 28 mm Displayed at 72 dpi at 600 dpi 5 mm 50 x 33.3 To make it appear at 6 x 4 inches must be scaled by 72/600 = 0.12
Changing Resolution
Changing Resolution can be done by resampling Reducing the pixel dimensions is called downsampling ; increasing them is called upsampling . Both can lead to a loss of quality.
10
Image Scaling
Scaling can be done either by applying a transformation to each original pixel or by applying the inverse transformation to each pixel in the scaled image. Interpolation is needed because of the finite size of pixels.
11
Trouble in scaling-up
12
Interpolation
Nearest neighbour
13
Use value of pixel whose centre is closest in the original image to real coordinates of ideal interpolated pixel Bilinear interpolation Use value of all four adjacent pixels, weighted by intersection with target pixel Bicubic interpolation Use values of all 16 adjacent pixels, weighted using cubic splines Nearest-neighbour interpolation is quickest but produces poor-quality results; bicubic is slowest but produces very good results; bilinear is in between.
14
15
16
bicubic
17
Other Ideas
Cropping Super-resolution Big Image (Gigapixel Image) Content Aware Image Resizing (Seam Carving)
18
Compression
Image files may be too big for network transmission, even at low resolutions Use more sophisticated data representation or discard information to reduce data size Effectiveness of compression will depend on actual image data For any compression scheme, there will always be some data for which 'compressed' version is actually bigger than the original
19
Lossless Compression
Always possible to decompress compressed data and obtain an exact copy of the original uncompressed data
Data is just more efficiently arranged, none is discarded
Run-length encoding (RLE) Huffman coding Dictionary-based schemes LZ77, LZ78, LZW (LZW used in GIF, licence fee charged)
20
RLE is an easy compression algorithm to understand It replaces sequences of the same data values within a file by a count number and a single value. Suppose the following string of data (17 bytes) has to be compressed:
ABBBBBBBBBCDEEEEF
Using RLE compression, the compressed file takes up 10 bytes and could look like this:
A *8B C D *4E F
21
RLE
Huffman code
Another use of binary trees Binary trees are not only for searching alone (binary search trees) Speedup the sending process over the Internet or other communication medium Efficient in compressing text or program files Images are sometimes better handled by other compression algorithms
22
Character codes
ASCII code
23
Characters are represented by 8 bits (1 byte) There are 256 possible values Every character requires the same number of bits (8 bits) Example:
A B C 65 66 67 01000000 01000001 01000010
Compressing text
SUSIE SAYS IT IS EASY
Character A E I S T U Y Space Linefeed frequency 2 2 3 6 1 1 2 4 1
24
If using the same number of bits for each character, then the number of bits required to represent N-character texts are constant Goal: Try to reduce the number of bits used to represent text to reduce the amount of data A method: represent the most used characters with the fewest bits as possible
25
26
27
28
9 4 SP 2 A 1 T 1 LF 5
13 6 S 3 2 1 U 3 I 2 Y 7 4
2 E
frequency 2 2 3 6 1 1 2 4 1
29
30
0
A T LF U I E
31
Dictionary-based Coding
LZW uses fixed-length codewords to represent variable-length strings of symbols/characters that commonly occur together, e.g., words in English text The LZW encoder and decoder build up the same dictionary dynamically while receiving the data LZW places longer and longer repeated entries into a dictionary, and then emits the code for an element, rather than the string itself, if the element has already been placed in the dictionary
32
33
34
Input codes to the decoder are 1 2 4 5 2 3 4 6 1 LZW decompression output string ABABBABCABABBA The initial string table is identical to what is used by the encoder.
36
A photo of a flower compressed with successively higher compression ratios from left to right. http://en.wikipedia.org/wiki/Jpeg
Materials on the JPEG topic are obtained from fundamentals of Multimedia by Ze-Nian Li and Mark S. Drew http://en.wikipedia.org/wiki/Jpeg Digital multimedia text book
37
JPEG Compression
Lossy technique, well suited to photographs, images with fine detail and continuous tones Consider image as a spatially varying signal that can be analyzed in the frequency domain Experimental fact: people do not perceive the effect of high frequencies in images very accurately Hence, high frequency information can be discarded without perceptible loss of quality
38
http://stargate.ecn.purdue.edu/~ips/tutorials/jpeg/jpegtut1.html
39
Transform RGB to YIQ or DCT on image blocks Quantization Zig-zag ordering and
run-length encoding
Entropy coding
40
41
Similar to Fourier Transform, analyses a signal into its frequency components Takes array of pixel values, produces an array of coefficients of frequency components in the image Computationally expensive process time proportional to square of number of pixels
Apply to 8x8 blocks of pixels Using blocks, however, has the effect of isolating each block from its neighboring context. This is why JPEG images look choppy blocky when a high compression ratio is specified by the user
42
Definition of DCT
Given an input function f(i; j) over two integer variables i and j (a piece of an image), the 2D DCT transforms it into a new function F(u; v), with integer u and v running over the same range as i and j. The general definition of the transform is:
43
7 7 ~ C(u)C(v) (2i 1) uT (2 j 1) vT f (i, j) ! cos cos F(u, v) 4 16 16 u!0 v!0
DCT (example)
If one such 8x8 8-bit subimage is:
44
45
Quantization
The human eye is fairly good at seeing small differences in brightness over a relatively large area but not so good at distinguishing the exact strength of a high frequency brightness variation So we can get away with greatly reducing the amount of information in the high frequency components. Divide each component in the frequency domain by a constant for that component, and then round to the nearest integer (u , v )
(u , v ) ! round Q (u , v )
46
JPEG Quantization
Applying DCT does not reduce data size
Array of coefficients is same size as array of pixels
Allows information about high frequency components to be identified and discarded Use fewer bits (distinguish fewer different values) for higher frequency components Number of levels for each frequency coefficient may be specified separately in a quantization matrix
F (u , v ) ~ F (u , v ) ! round (u , v ) The entries of Q(u,v) tend to have larger values towards the lower right corner. This aims to introduce more loss at the higher spatial frequencies The tables below show the default Q(u,v) values obtained from psychophysical studies with the goal of maximizing the compression ratio while minimizing perceptual losses in JPEG images.
New result after quantization
Quantization
47
48
DCT
49
IDCT
Diff
50
51
JPEG Encoding
52
53
JPEG Decompression
Expand runs of zeros and decompress Huffmanencoded coefficients to reconstruct array of frequency coefficients Use Inverse Discrete Cosine Transform (IDCT) to take data back from frequency to spatial domain Data discarded in quantization step of compression procedure cannot be recovered Reconstructed image is an approximation (usually very good) to the original image
Decoding process
54
Apply IDCT
55
Compression Artifacts
If use low quality setting (i.e. coarser quantization), boundaries between 8x8 blocks become visible If image has sharp edges, these become blurred
Rarely a problem with photographic images, but especially bad with text Better to use good lossless method with text or computer-generated images
Example
56
JPEG2000
57
JPEG2000 improves on JPEG in many areas, including image quality at high compression ratios. It can be used losslessly as well as lossily. For JPEG2000 compression the image is divided into tiles, but these can be any size, up to the entire image. Take advantage of a Discrete Wavelet Transform (DWT) Encode by using Arithmetic Coding
58
File Formats
GIF (Graphics Interchange Format)
59
GIF files use LZW compression ( lossless) Restricted to 256 colours (indexed colour) One colour may be used to designate transparency. They are most suitable for simple images with areas of flat colour (cartoon-style drawing, animation)
60
61
62
JPEG Format
JPEG data can be stored in several different formats. JFIF and SPIFF are compatible formats for JPEG images and are widely used on the Web. Exif can hold either JPEG or TIFF data, together with extensive metadata. JP2 and JPX formats are defined for storing JPEG2000 data.
63
64
65
66
Raw Formats
Camera raw data is used when complete control over image processing is required There is no standard format for camera raw data. Adobe s DNG (Digital Negative) format is a standard, based on the TIFF format, intended for archiving camera raw images.
67
A Raw File
A record of the data captured by the camera sensor Unprocessed sensor data
68
69
Digital Camera
Most digital cameras sample an image with red, green and blue sensors arranged in a photoreceptor array
70
Digital Camera
The purpose of the microlens array is to focus the light onto each pixel The color filter array changes the color responsivity of each pixel Finally, the sensor array captures the light and generates the electrical signal
71
72
73
74
Filter patterns
RGB or CMY or 4-color-mix are possible Each element in the sensor captures only one color The red-filtered elements produce a grayscale value proportional to the amount of red light reaching the sensor Same as the green-filtered and blue filtered elements
75
76
Raw Converter
77
Demosaicing
To display the image, we must create an image that has a red, green and blue pixel at each location Interpolate the missing sensor values
78
Demosaicing Illustration
79
Demosaicing Illustration
A simulated sampling taken by a Bayer filtered sensor array Each pixel only has a value of either R or G or B
80
Demosaicing Illustration
A zoom-in version
81
Demosaicing Illustration
An example reconstruction
82
Demosaicing Illustration
A zoom-in version
original
reconstruct
Demosaicing Algorithms
Nearest Neighbor Replication Simple interpolation
Bilinear, Bicubic, Spline, Laplacian interpolation
83
Adaptive
Adapt their methods of estimation depending on features of the area surrounding the pixel of interest
Proprietary
Commercial products
84
Raw Conversion
In addition to demosaicing
White balance Colorimetric interpretation assigns the correct, specific color meanings to the red , green , and blue pixels, usually in a colorimetrically defined color space such as CIE XYZ, which is based directly on human color perception Gamma correction is done to redistribute the tonal information so that it corresponds more closely to the way our eyes see light and shade Noise reduction, anti-aliasing, and sharpening
Benefits
Finer control is easier for the settings
85
For example, the white point can be set to any value, not just discrete values like "daylight" or "incandescent"
The settings can be previewed and tweaked to obtain the best quality image or desired effect Camera raw files have 12 or 14 bits of brightness information JPEG loses fine details and is ill-suited for major color or brightness changes The working color space can be set to whatever is desired Different demosaicing algorithms can be used, not just the one coded into the camera
Drawbacks
86
Camera raw files are typically 2-6 times larger than JPEG Fewer images can fit on a given memory card It also takes longer for the camera to write raw images to the card
fewer pictures can be taken in quick succession (a sports sequence)
Specific software may be required to open raw files on some systems, as opposed to JPEG or TIFF Time taken in the image workflow
Software Supports
Dcraw Adobe Photoshop / Adobe Photoshop Lightroom Microsoft's Digital Image Mac OS X
87
added raw support directly to the system which adds raw support automatically to the majority of Mac OS X applications (such as Preview, Mac OS X's PDF and image viewing application)
88
References
Adobe.com Wikipedia.org http://www.imageval.com/public/Produ cts/ISET/ISET_Manual/Demosaicing.htm http://photo.net/learn/raw/ http://www.cambridgeincolour.com/tut orials/RAW-file-format.htm
89
Image Manipulation
Image manipulation software provides high level operations for systematically altering pixels Most operations are described by analogy with traditional photographic techniques, such as the use of masks and filters. Bitmapped images are manipulated to correct technical deficiencies, alter the content (retouch) or create artificial compositions.
90
91
Compositing
The process of assembling multiple images to make a final image. Images are often organized into layers, which are like overlaid sheets that may have transparent areas. Layers are used for compositing or experimenting with different versions of an image.
92
93
Selection
Areas may be selected by drawing with
marquee : geometrical shape lasso tools or Bzier pen : free hand magic wand : selected on the basis of colour similarity magnetic lasso : selected on the basis of edges
94
95
96
97
(Knock-out)
98
p = Ep1 + (1-E)p2
99
p = f(p)
Brightness, contrast and levels are relatively crude pixel point adjustments.
100
(Original image)
101
102
Levels adjustment
(Adjust B&W independently)
103
Curve Adjustments
Curves adjustments provide full control over the relationship between original and new values. A sigmoid curve is often used to enhance contrast.
104
Increase white
fixed
Increase black
105
106
107
108
Gaussian Filter
Simple blurring uses a 3 x 3 mask with equal values but produces crude results. Gaussian blur is preferred, as it produces more natural results.
109
110
Sharpening
Sharpening with a 3x3 mask is crude. Unsharp masking combining an image with a Gaussian blurred copy of itself produces better-looking results. Over-sharpening should always be avoided.
111
112
113