代做 R – Image Representation

Image Representation

代做 R – 这是一个 R 面向对象设计的practice, 考察 R 的理解, 涵盖了 R 等程序代做方面

R语言 统计代做 代写统计

Rynson W.H. Lau
CS4185/CS5185 Multimedia Technologies and Applications

Pixels

Pixel: comes from the words picture and element. A pixel corresponds to the smallest unit in a digital picture.

Image resolution refers to the number of pixels in a digital image. For example, HDTV has a resolution of 1920
1080 pixels.
pixel
Rynson W.H. Lau:

Binary Images

Each pixel is represented by a single bit (0 or 1).

Such an image is also called a monochrome image since it contains only a single foreground color on a single background color (usually black/white).
Rynson W.H. Lau:
original image
binary image

8-Bit Gray-Level Images

Each pixel is represented by an 8-bit black and white value, i.e., between 0 and 255, where 0 corresponds to the smallest value (completely black) while 255 corresponds to the highest value (maximum brightness).
Rynson W.H. Lau:
original image 8-bit gray-level image

Example Images

1-Bit Binary Image
8-Bit Gray-Level Image
1 0
255 0
Rynson W.H. Lau:

Number of Bits per Pixel

Bits per pixel (color depth)
Number of different gray values that can be specified by a fixed number of bits in a pixel of a digital image.

As the number of bits per pixel increases by one, the number of gray values is doubled.

As the number of different gray values increases, the boundary between any two adjacent values becomes less visible.
Rynson W.H. Lau:

Gamma Correction

To display an image, we typically need to convert each RGB value to a voltage to drive the display screen.

However, the mapping between the driving voltage and the amount of light emitted is typically non-linear for most display devices, such as CRTs and LCDs. The light emitted is roughly proportional to the voltage
raised to a power
; and
this power is called
gamma
, with symbol
.
Hence, if a pixel value in the red channel is R, the screen emits light proportional to R
. For
CRTs, the gamma value is about 2.2.
GammaCorrection
CRTSystem
RR = R
1 /
(R
)= R
CRTSystem
R

R Image with Gamma Correction Image without Gamma Correction

Rynson W.H. Lau:

Histogram

A histogram shows the number of occurrences,
p(
g), of
each individual gray-level value,
g, in an image.
Rynson W.H. Lau:

The distribution of pixel values tells the quality of the image. For examples: If majority of the pixels have small gray values, the image

will appear dark.
  • If majority of the pixels have large gray values, the image
will appear bright.
Rynson W.H. Lau:

If majority of pixel values are within a small range, the

image will appear to have a low contrast. (The previous two images are also considered as low contrast images.)
 On the contrary, a high contrast image covers a wide range
of gray values.
Rynson W.H. Lau:

Brightness

original image
image with
increased brightness
Brightness of the image can be adjusted as follows:
pixel
(x
, y
) =
pixel
(x
, y
) +
brightness
If the sum or difference exceeds the range (0, 255), the output value is clipped to the minimum/maximum value.

This brightness adjustment is equivalent to shifting the histogram horizontally.

Contrast

Contrast of an image can be adjusted as follows:
pixel
(x
, y
) =
contrast
* (
pixel
(x
, y
)
gmean
) +
gmean
where
gmean
is the mean gray value of the original image.
If
X
and
Y
represent the horizontal and vertical resolutions
of the image,
gmean
can be computed as:
Again, if an output value exceeds the range (0, 255), it is clipped to the minimum/maximum value.
Rynson W.H. Lau:
Y
X
y
x
pixel
g
X x
Y y
mean
*
)
,
(
0
0
=
=
=
original image

Contrast correction is similar to scaling the histogram distribution. We reduce the contrast of an image by setting contrast

(in the equation) to smaller than 1 and increase it
by setting
contrast
to larger than 1. image with
increased contrast
Rynson W.H. Lau:

Inversion (Negative)

Image inversion can be achieved as follows:
pixel(x, y) = 255  pixel(x, y)
Films are negative, while photographs are positive.Original image
negative Image
Rynson W.H. Lau:

Quantization

This is to uniformly quantize the gray values of an image into a smaller number of levels.original image(256 levels)
quantized Image
(16 levels)
Rynson W.H. Lau:

Thresholding (Binarization)

original image
binary image(threshold = 128)
This is to convert a gray-level image into a binary image:
pixel(x, y) = 0
if pixel(x, y) < threshold
pixel(x, y) = 255
if pixel(x, y) >= threshold

Dithering

In existing black-and-white printers, each pixel can only have 2 levels of intensity (1 bit), i.e., with or without ink.

Color printers provide 15 levels (or 15 different colors), by combining four types of inks, cyan, magenta, yellow and black.

Dithering
is a technique to print more intensity (or color)
levels by reducing the printing resolution, i.e., trading off spatial resolution for intensity resolution.

The idea is to replace and print each image pixel with a pixel pattern (using multiple pixels) such that the average intensity (or color) of the pixel pattern approximates the original image pixel intensity.

Consider printing an 8-bit gray-level image on a black-and-whit

e

laser printer. We may replace each image pixel with, say, a 2
^2
pixel pattern. A 2
2 matrix produces a total of 5 possible pixel
patterns:
image pixel value
0  50
51  101
102  152 153  203 204  255
code to represent the range
abcde
pixel pattern for printing

Given an image pixel, we first
map its value (between 0 and 255
)
into a new value (between 0 to 4). We then map the new pixel value to one of the above 5 pixel patterns.

An example:
 
 
240
180
69
122
    
    
W
W
W
B
W
W
W
W
B
B
W
B
B
W
B
W dithered binary image for printing
a 2
2 image
map each pixel value to a code
 
 
B
B
B
B
 
 
B
B
B
W
 
 
W
B
B
W
 
 
W
B
W
W
 
 
W
W
W
W
map each code to a pixel pattern

A dithered example image:

magnification of a dithered region
dithered binary image
original gray-level
image
Rynson W.H. Lau:

Printer dithering (also called halftoning) examples:

Rynson W.H. Lau:
black-and-white
dithering
Color dithering

Pixel Per Inch (PPI)

PPI is a measure of the pixel density. It refers to the display
or printing resolution of an input image.

As suggested by Fotomax (
http://www.fotomaxonline.com/serv
ice.asp?lang=en&page=175
),
the PPI requirement for digital photo printing is 300 PPI for best resolution, or 180 PPI for minimum resolution.
Product
Image Size(Inch)
The Best Resolution
(Pixels)
Minimum Resolution
(Pixels)
1.5"x2" ID Photo 8 pcs
1.5 x 2
450 x 600
270 x 360
2R
2.5 x 3.5
750 x 1050
450 x 630
3R
3.5 x 5
1050 x 1500
630 x 900
4D (4.5"x6")
4.5 x 6
1350 x 1800
810 x 1080
4R
4 x 6
1200 x 1800
720 x 1080
5R
5 x 7
1500 x 2100
900 x 1260
6R
6 x 8
1800 x 2400
1080 x 1440
8R
8 x 10
2400 x 3000
1440 x 1800
8F
8 x 12
2400 x 3600
1440 x 2160Rynson W.H. Lau:

Dot Per Inch (DPI)

DPI refers to the printer resolution. It controls the printing quality.

It specifies the number of droplets of ink that can be printed on one inch of the paper.

Typical printer DPIs include 360DPI, 720DPI, 1440DPI and 2880DPI, but the differences among these setting may be small and not visible to naked eyes. Changing the DPI setting has no effect on the size of the print.

To print an image, the PPI of the image file is mapped to the DPI of the printer  based on the dithering method that we have discussed.
Rynson W.H. Lau:

Light and Spectra

Light is an electromagnetic (EM) wave.

Human visible light ranges from 400nm to 700nm.
Rynson W.H. Lau:

Spectral Power Distribution (SPD), or

spectrum

, E

(

),
shows the relative amount of light energy at each wavelength
.

E(
)
Spectrum of Daylight
Rynson W.H. Lau:

Human Vision

Retina consists of an array of rods and three kinds of cones Rods are for night vision Cones are for color vision
  1. L-cone: most sensitive to red light 2. M-cone: most sensitive to green light3. S-cone: most sensitive to blue light

Spectral Sensitivity of the Eye


The eye is most sensitive to li
ght in the middle of the visible
spectrum.

The response in each color channel in the eye is proportional t
o the
corresponding number of cones: Red Receptor Sensitivity
qR
()
  • Green Receptor Sensitivity
qG
()
  • Blue Receptor Sensitivity
qB
()

Luminous-efficiency function
V(
):
q(R
)
q(G
)
q(B
)
V(
)

overall sensitivity formed by the sum of the response curves for Red, Green and Blue.
The Blue receptor sensitivity is not shown to scale because it is much smaller than the curves
for Red or Green.

Total response on each channel is given by:

R
= 
E(
)
qR
()
d
G
= 
E(
)
qG
(
) d

B
= 
E(
)
qB
()
d
q(R
)
q(G
)
q(B
)
V(
)


E(
)
Spectrum of Daylight
Source:
http://escience.anu.edu.au/lecture/cg/Color/index.en.html

Image Formation

Light from the illuminant (light source) with SPD
E(
)
impinges on a surface, with surface spectral reflectance function
S(
), is reflected, and then is filtered by the eye's
cone functions
q(
).
The
color signal, C
(
), is defined by
C(
) =
E(
)
S(
).
Total response on each channel is now given by:
R
= 
E(
)
S(
)
qR
()
d
= 
C(
)
qR
(
) d

G
= 
E(
)
S(
)
qG
()
d
= 
C(
)
qG
()
d
B
= 
E(
)
S(
)
qB
(
) d
=
C
(
) q
(B
) d

RGB Color Space

Different combinations of the red, green, blue channel values result in different colors.
RGB Color Cube
Red Channel
Blue Channel
Green Channel
Rynson W.H. Lau:

24-Bit Color Images

In a 24-bit color image, each pixel is represented by three bytes, usually in RGB format.  With 1 byte each for R, G, and B, this representation provides
a total of 256
^256
256 (or 16,777,216) possible colors.
  • However, this will consume a lot of memory. A single HD
image of 1920
1080, without any compression, will require
5.93MB to store.

Many 24-bit color images are actually stored as 32-bit images. The extra byte in each pixel is used to store an alpha
value representing some special effect information
(e.g., transparency).
Rynson W.H. Lau:

An example

24-Bit Color Image
R Channel B Channel
G Channel
Rynson W.H. Lau:
  • Another example
24-Bit Color Image
R Channel
B Channel
G Channel
Rynson W.H. Lau:

Color Models

In the previous discussion, we assume that each image is represented by the RGB channels.

Such a representation is called the
RGB color model
.
Another two popular models are the YUV and YIQ models.

The YUV color model is used in PAL color TV broadcasting, while the YIQ is used in NTSC color TV broadcasting.

(PAL was developed by the UK and NTSC by the US. PAL and NTSC are two popular analog video broadcasting standards.)
Rynson W.H. Lau:

The YUV Model

In YUV,
Y
is the luminance signal and is computed as:Y = 0.299R + 0.587G + 0.114B
U
and
V
are the chrominance signals and are computed as:U = B  YV =  R  Y
As human eyes are more sensitive to the luminance signal, a high percentage of the bandwidth can then be allocated to carry the luminance signal in the PAL system.
Rynson W.H. Lau:

An example:

Rynson W.H. Lau:
original color image
YUV

The YIQ Model

In YIQ,
Y
is again the luminance signal and computed in
the same way as in YUV.

Iand
Q
are also the chrominance signals, but rotated by
33
oas: I = 0.877(R  Y)cos33
o 0.492(B  Y)sin33
o
= 0.596R 0.275G 0.321B
Q = 0.877(R  Y)sin33
o 0.492(B  Y)cos33
o
= 0.212R 0.523G 0.311B
Similar to PAL, a high percentage of the bandwidth can be allocated to carry the Y signal in the NTSC system.
Rynson W.H. Lau:

An example:

Rynson W.H. Lau:
original color image
YI
Q

Additive/Subtractive Color Models

When two light beams hit the same point, their colors add together.

When two nearby LCD points are turned on, their colors also add together.

Hence, RGB (and so as YUV and YIQ) is referred to as an additive color model.
Rynson W.H. Lau:

However, in color printing, the opposite situation occurs.

When depositing a drop of yellow ink, it subtracts blue color from the white paper. Hence, it reflects red and green colors. As a result, it appears yellow.

So, instead of red/green/blue, we have -red/-green/-blue. These subtractive color primaries then become Cyan (C), Magenta (M) and Yellow (Y).
Rynson W.H. Lau:
See
video