Dithering, also called Halftoning or Color Reduction, is the process of rendering an image on a display device with fewer colors than are in the image. Digital Image Processing: Some Special Techniques Dithering presents about it.
Trang 1Digital Image Processing
Some Special Techniques
Dithering
Trang 2 Dithering, also called Halftoning or Color
Reduction, is the process of rendering an
image on a display device with fewer colors
than are in the image (Mateus Pins and
Hermann Hild)
The number of different colors in an image or
on a device is used called its Color Resolution
Trang 3 If the display device has a higher spatial resolution
than the image that you are trying to reproduce, it can show a very good image even if its color resolution is less This is what we will call 'dithering' and is the
subject of this work
Dithering is a one-way operation
Once an image has been dithered, although it may look like
a good reproduction of the original, information is
permanently lost
Many image processing functions fail on dithered images
Trang 4Dithering
Trang 5Dithering Grey-scale and colour simulation
Dithering on a screen or printer is analogous to the half-toning techniques used in the print
industry
A CRT can be considered to be a complex
colour “dithering” device with variable colour
intensity
Trang 6Dithering Grey-scale and colour simulation
We need to display colour and grey-scale
images on output devices that have a lower information-carrying capacity
Cheap printers are bi-level or CMYK - clearly
we need to add colours/intensities to
approximate an image
Trang 7Dithering Methods (Digital Halftoning)
Floyd-Steinberg
Burkes
Stucki
Sierra
Jarvis, Judice and Ninke
Stevenson and Arce
…
Trang 8Dithering in Printing Industry
every primary color is rasterized
separately,different printing angles ensure
unbiased results
Trang 9Simple shading techniques
A series of examples
Original picture, half-toning
simulation by a non-PostScript
laser printer.
The original image has an
8-bit grey scale palette.
The laser printer has only got
a 1-bit palette (ie bi-level,
black and white) and must
simulate the original shading.
Trang 10Simple shading techniques
An example
Bayer - Ordered Dithering
This method uses a set of
regular arrays of values,
leading to a regular (and
visually poor) output.
This method creates abrupt
changes between areas,
changes that do not exist on
the original Such artefacts
Trang 11Simple shading techniques
An example
Burkes
This method uses an
error-distribution algorithm to
minimise percieved errors.
Changes in the average
intensity vary quite smoothly,
resolution permitting, leading
to a more acceptable image.
Trang 12Simple shading techniques
An example
Floyd-Steinberg
FS dithering is popular and
commonly used It is
robust and quite general
FS dithering works best on
images with few
high-contrast transitions
Trang 13Threshold Dithering
every pixel is compared to a threshold t:
t can be:
equal everywhere (e.g (b–a)/2,arbitrary value,
mean value, median, )
location dependent (defined locally or globally)
p t a
p > t b
Trang 14Constant Threshold Dithering
sample image threshold values result
(values between 0 and 9) corresponds to rounding
Trang 15Principle of Dithering
Available values a, b
Missing value x between a and b shall
besimulated by mixing a-pixels and b-pixels
Trang 16Principle of Dithering
Trang 17Dithering a Uniform Area
for a uniform area regular application of
Trang 18Dithering a Uniform Area
This can be done by using a different threshold for every pixel (using the interval borders)
Trang 19Threshold Matrix
Distances between interval borders are equal,
therefore it suffices to define the sequence of the
pixel values in the matrix:
instead of only
i.e for an nxn matrix: values [0,n 2–1]
Value k corresponds to threshold value: 2k+1/2n2
Trang 20Dither Matrix Example
dither matrix threshold matrix
Value k corresponds to threshold value: 2k+1/2n2
Trang 21Threshold Matrix Dithering Example
sample image threshold values result
(values between 0 and 9)
Trang 22Generation of Threshold Matrices
recursive method: 4 copies of smaller matrices
Trang 23Generation of Threshold Matrices
Direct method: use of magic squares
example
magic squares produce fewer diagonal stripes
Trang 24Dithering between Grey Levels
threshold values have to lie between a and b:
calculation is done separately for every pixel
(not once for a dithering matrix)
Trang 25Grey Level Dithering Example
Trang 26Dot Diffusion Dithering
Trang 27Stochastic Dithering?
values
expectation value of total error = 0
no regular artificial patterns possible
(due to bad distribution of random
numbers)
Trang 28Forced Random Matrix Dithering
Improved "random" matrices very good results
Method: insert threshold values one by one into
matrix, always use the position farthest away from all previous points
Repulsive force field:
precalculate large threshold matrices: 300x300
very good results!
Trang 29Error distribution algorithms
Floyd-Steinberg (1975)
If an image has a pixel with a normalised value
of 0.5, ie half intensity, we cannot accurately
represent it with a black or white dot
However, we can remember the error and feed
it into the approximation calculation for the
surrounding pixels
The error value gets distributed locally and the eye reintegrates the values, “recreating” the
grey scale
Trang 30Floyd-Steinberg Distribution Weighting
3/8 error
Current Pixel
1/4 error
3/8 error
Trang 31Dithering Some drawbacks
A dithered image is an image with less information in
it than the original.
Resolution and apparent colour content are a off, particularly with thermal wax transfer printers etc.
trade- Accurate conversion between original images and
dithered images is generally one-way.
Some dithering methods cause ugly banding on some images Careful choice of dithering methods can
minimise this problem.
Trang 32Diffusion Direction Variations
to gain better results, the error is distributed
toseveral neighbors (with weights)
Trang 33Error Diffusion Dithering Example
sample image threshold values result
(values between 0 and 9) corresponds to rounding
Trang 34Serpentine Method
Artificial stripes can be reduced drastically
byprocessing the scanlines in serpentine order
no additional memory necessary
Trang 35 Diffuse reflection of white light gives an object its colour.
Perception of colour is, therefore, dependent upon lighting
Specular reflection has the colour content of
the light source - what is the colour of a mirror?
Colour is an everyday experience
Colour Systems Colour in the environment
Trang 36 Colour can be measured in terms of the
frequency or wavelength of electromagnetic radiation (light)
Some light sources have a narrow band of
frequencies, eg lasers, but this is rare
Incandescent lighting has a broad range of
frequencies
Sodium lamps have two bright frequencies
Colour Systems Colour in the environment
Trang 37Colour Systems Measuring Colour
Wavelength and intensity are measurable
quantities - intensity expresses the energy per unit area carried by the radiation
This is not an intuitive way of specifying
colours!
Light Wavelength (nanometres)
Trang 38Colour Systems Colour Matching
The eye cannot discern between a colour
made of a single wavelength and a “visually identical” colour made of a mixture of
wavelengths
This allows monitors (RGB) and magazines (CMYK) to show the “same” pictures
The eye is very sensitive to colour and can
distinguish between approximately 300 000
Trang 39Colour Systems Colour Matching
For practical purposes, the physical
descrip-tion of colour is abandoned in favour of a more natural way of describing what we see
Any colour shade can be matched by mixing three monochromatic primary colours, by
definition
Colour matching is an important problem for
commercial users of print and video
Trang 40Colour Systems Primary Colours
In the real world we do not have pure, wavelength colour sources to add - this means that some colour shades are impossible to
Trang 41Colour Systems The CIE Chromaticity Diagram
The CIE diagram represents all hue and saturation values, with normalised intensity
The outer curve represents all the visible 100% saturated
or pure colours.
Cyan
Blue
Red White
Yellow Green
Magenta
Trang 42Colour Systems The RGB colour cube
A system with three
independent variables
can be represented by
a three-dimensional
position.
The RGB colour cube
represents all of the
colours that an RGB
monitor can create, in a
Yellow Green
White
Black Cyan
Blue Magenta
Red (Greys)
Trang 43Colour Systems The RGB colour cube
A system with three
independent variables
can be represented by
a three-dimensional
position.
The RGB colour cube
represents all of the
colours that an RGB
monitor can create, in a
non-normalized form.
Yellow Green
White Cyan
Blue
Magenta
Red
Trang 44Colour Systems The HSV model
Hue, Saturation, Value is
a more intuitive model.
“Value” is brightness,
constant value hexagons
lie parallel to the top
surface.
Grey shades run up the
vertical axis, black at the
bottom and white at the V=0
Trang 45Colour Systems The HLS model
The Hue, Lightness, Saturation
model was developed by
Tektronix.
HLS is similar to HSV but with a
double cone.
This and other models are
combinations of the CIE, RGB
and HSV models.
Translations are always possible. L=0
Green 120 Yellow 180
Cyan 60
Red 240
L=1
Blue 0 Magenta 300
Trang 46 http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT
- dither.txt – everything you ever wanted to
know about dithering!
Computer Graphics, (C version) by D Hearn
Trang 47Digital Image Processing
Some Special Techniques Thinning (Lọc xương)
Trang 48Ở đây ta chỉ quan tâm đến loại sau.
làm 2 loại:
còn các điểm biên và nền.
Trang 49 Thinning là quá trình loại bỏ các pixel phụ
(dư thừa) để làm đối tượng trở nên đơn giản hơn, chỉ gồm các thành phần mảnh, không
có diện tích
Thinning rất giống với phép co: xóa liên tiếp
các pixel dư thừa cho đến khi chỉ còn khung xương đối tượng
Trang 50 Thinning phải thỏa các tính chất cơ bản sau:
Đối tượng kết quả phải mảnh, có độ rộng 1 pixel
Các pixel tạo nên khung xương phải định vị gần tâm của mặt cắt đối tượng.
Đảm bảo tính liên thông giống như đối tượng ban đầu.
Trang 51Thuật toán Zhang – Suen
Việc giải quyết có xóa hay không xóa 1 pixel sẽ
chỉ phụ thuộc vào 8 pixel lân cận với nó.
xóa 1 pixel:
Trang 52Quy tắc 1
Pixel p có thể được xóa nếu 1 < N8(p) < 7 với
N8(p) là số lân cận 8 của p.
Điều kiện N8(p) > 1 đảm bảo điểm đầu mút của đối
tượng không bị xóa, không bị bào mòn
Điều kiện N8(p)<7 đảm bảo đối tượng không bị đục
lỗ (trong trường hợp N8(p)=8) hoặc bào mòn quá mức (trong trường hợp N8(p)=7).
Trang 53Quy tắc 2:
Pixel p được xóa nếu chỉ số đếm (counting
index hay crossing index - CI) của nó bằng 1
Định nghĩa: Chỉ số đếm là số ngã rẽ từ pixel
đang xét
Trang 55Quy tắc 3:
Trong pha thứ nhất, ảnh sẽ được quét từ
trên xuống dưới và từ trái sang phải Một
pixel chỉ được xóa nếu thỏa cả 2 điều kiện:
Có ít nhất 1 trong các lân cận 1, 3, 5 là pixel nền.
Có ít nhất 1 trong các lân cận 3, 5, 7 là pixel nền.
1
7 p 3
5
Trang 56Quy tắc 4:
Trong pha thứ nhất, ảnh sẽ được quét từ
dưới lên trên và từ phải sang trái Một pixel chỉ được xóa nếu thỏa cả 2 điều kiện:
Có ít nhất 1 trong các lân cận 1, 3, 7 là pixel nền.
Có ít nhất 1 trong các lân cần 1, 5, 7 là pixel nền.
1
7 p 3