560 likes | 749 Views
Digital Image Processing. Some Special Techniques Dithering. Dithering. 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 )
E N D
Digital Image Processing Some Special Techniques Dithering Duong Anh Duc - Digital Image Processing
Dithering • 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. Duong Anh Duc - Digital Image Processing
Dithering • 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. Duong Anh Duc - Digital Image Processing
Dithering Duong Anh Duc - Digital Image Processing
DitheringGrey-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. Duong Anh Duc - Digital Image Processing
DitheringGrey-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. Duong Anh Duc - Digital Image Processing
Threshold dithering ordered dither stochastic dither dot diffusion .... Error diffusion dithering Floyd-Steinberg Burkes Stucki Sierra Jarvis, Judice and Ninke Stevenson and Arce … Dithering Methods(Digital Halftoning) Duong Anh Duc - Digital Image Processing
Dithering in Printing Industry • Newspapers • black ink on light paper, rasterization of theimages enables also grey levels, equal pointdensity everywhere, variable size • Color printing • every primary color is rasterized separately,different printing angles ensure unbiased results Duong Anh Duc - Digital Image Processing
Simple shading techniquesA 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. Duong Anh Duc - Digital Image Processing
Simple shading techniquesAn 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 are not desirable. Duong Anh Duc - Digital Image Processing
Simple shading techniquesAn 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. Duong Anh Duc - Digital Image Processing
Simple shading techniquesAn 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. Duong Anh Duc - Digital Image Processing
Threshold 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 Duong Anh Duc - Digital Image Processing
Constant Threshold Dithering sample image threshold values result (values between 0 and 9) corresponds to rounding Duong Anh Duc - Digital Image Processing
Principle of Dithering • Available values a, b • Missing value x between a and b shall besimulated by mixing a-pixels and b-pixels Duong Anh Duc - Digital Image Processing
Principle of Dithering Duong Anh Duc - Digital Image Processing
Dithering a Uniform Area • for a uniform area regular application of this pattern will produce this grey tone interval borders all grey levels in this interval will be mapped to 1/4 Duong Anh Duc - Digital Image Processing
Dithering a Uniform Area • This can be done by using a different threshold for every pixel (using the interval borders) Duong Anh Duc - Digital Image Processing
Threshold 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,n2–1] • Value k corresponds to threshold value: 2k+1/2n2 Duong Anh Duc - Digital Image Processing
Dither Matrix Example dither matrix threshold matrix Value k corresponds to threshold value: 2k+1/2n2 Duong Anh Duc - Digital Image Processing
Threshold Matrix Dithering Example sample image threshold values result (values between 0 and 9) Duong Anh Duc - Digital Image Processing
Generation of Threshold Matrices • recursive method: 4 copies of smaller matrices Duong Anh Duc - Digital Image Processing
Generation of Threshold Matrices • Direct method: use of magic squares example magic squares produce fewer diagonal stripes Duong Anh Duc - Digital Image Processing
Dithering 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) Duong Anh Duc - Digital Image Processing
Grey Level Dithering Example Duong Anh Duc - Digital Image Processing
Dot Diffusion Dithering Duong Anh Duc - Digital Image Processing
Stochastic Dithering? • Use of random numbers as threshold values • expectation value of total error = 0 • no regular artificial patterns possible • Unfortunately: very bad results! (due to bad distribution of random numbers) Duong Anh Duc - Digital Image Processing
Forced 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! Duong Anh Duc - Digital Image Processing
Error distribution algorithmsFloyd-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. Duong Anh Duc - Digital Image Processing
Floyd-SteinbergDistribution Weighting Current Pixel 3/8 error Current scan line of image 3/8 error 1/4 error Next scan line of image Duong Anh Duc - Digital Image Processing
DitheringSome drawbacks • A dithered image is an image with less information in it than the original. • Resolution and apparent colour content are a trade-off, particularly with thermal wax transfer printers etc. • 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. Duong Anh Duc - Digital Image Processing
Diffusion Direction Variations • to gain better results, the error is distributed toseveral neighbors (with weights) Duong Anh Duc - Digital Image Processing
Error Diffusion Dithering Example sample image threshold values result (values between 0 and 9) corresponds to rounding Duong Anh Duc - Digital Image Processing
Serpentine Method • Artificial stripes can be reduced drastically byprocessing the scanlines in serpentine order no additional memory necessary Duong Anh Duc - Digital Image Processing
Colour SystemsColour in the environment • 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. Duong Anh Duc - Digital Image Processing
Colour SystemsColour in the environment • 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. Duong Anh Duc - Digital Image Processing
Colour SystemsMeasuring 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! Violet Blue Cyan Green Yellow Orange Red 400 480 500 520 580 600 650 700 720 Light Wavelength (nanometres) Duong Anh Duc - Digital Image Processing
Colour SystemsColour 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 different shades of colour. Duong Anh Duc - Digital Image Processing
Colour SystemsColour 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. Duong Anh Duc - Digital Image Processing
Colour SystemsPrimary Colours • In the real world we do not have pure, single-wavelength colour sources to add - this means that some colour shades are impossible to match. • A way of specifying colours in a sensible way was developed by the CIE (Comission Internationale de L’Eclairage) in 1931. • The CIE chromaticity diagram is widely used. Duong Anh Duc - Digital Image Processing
Green Yellow Cyan White Red Magenta Blue Colour SystemsThe 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. Duong Anh Duc - Digital Image Processing
Yellow Green Cyan White (Greys) Red Black Blue Magenta Colour SystemsThe 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. Duong Anh Duc - Digital Image Processing
Colour SystemsThe 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. Green Yellow Cyan White Red Blue Magenta Duong Anh Duc - Digital Image Processing
Green 120 Yellow 60 Cyan 180 V=1 Red 0 Magenta 300 Blue 240 V=0 Colour SystemsThe 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 top. Duong Anh Duc - Digital Image Processing
L=1 Green 120 Cyan 60 Blue 0 Yellow 180 Red 240 Magenta 300 L=0 Colour SystemsThe 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. Duong Anh Duc - Digital Image Processing
References • 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 and P. Baker: • Section 4 of Chapter 15, Halftone Patterns and Dithering Techniques • Chapter 15, Colour Models and Colour Applications Duong Anh Duc - Digital Image Processing
Digital Image Processing Some Special Techniques Thinning (Lọc xương) Duong Anh Duc - Digital Image Processing
Thinning • Các pixel trên một ảnh có thể chia làm 2 loại: • Pixel nền • Pixel thuộc một đối tượng Ở đây ta chỉ quan tâm đến loại sau. • Các pixel thuộc một đối tượng lại có thể chia làm 2 loại: • Điểm biên • Điểm bên trong • Thinning là quá trình biến đổi để trên ảnh chỉ còn các điểm biên và nền. Duong Anh Duc - Digital Image Processing
Thinning • 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. Duong Anh Duc - Digital Image Processing
Thinning • 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. Duong Anh Duc - Digital Image Processing