Dither Removal. Bart M. ter Haar Romeny. Image Dithering. This article has not been updated for Mathematica 8.

Similar documents
Examples of Fourier series

Gaussian derivatives and Eigen-images

Color Dithering with n-best Algorithm

Image processing in frequency Domain

Assignment #4 Curvature-based interest operators, more spatial frequency filtering, and illusions

Image Restoration and Reconstruction

Image Restoration and Reconstruction

Lecture note on Senior Laboratory in Phyhsics. Fraunhofer diffraction and double-split experiment

Noise Model. Important Noise Probability Density Functions (Cont.) Important Noise Probability Density Functions

Image Processing. Alpha Channel. Blending. Image Compositing. Blending Errors. Blending in OpenGL

Texture. Outline. Image representations: spatial and frequency Fourier transform Frequency filtering Oriented pyramids Texture representation

x' = c 1 x + c 2 y + c 3 xy + c 4 y' = c 5 x + c 6 y + c 7 xy + c 8

Computer Vision and Graphics (ee2031) Digital Image Processing I

Image Processing. CSCI 420 Computer Graphics Lecture 22

Computer Vision. Fourier Transform. 20 January Copyright by NHL Hogeschool and Van de Loosdrecht Machine Vision BV All rights reserved

ECE 176 Digital Image Processing Handout #14 Pamela Cosman 4/29/05 TEXTURE ANALYSIS

Digital Image Processing. Image Enhancement in the Frequency Domain

Introduction to Image Processing and Analysis. Applications Scientist Nanotechnology Measurements Division Materials Science Solutions Unit

Digital image processing

Image Recognition of Shape Defects in Hot Steel Rolling

Digital copying involves a process. Developing a raster detector system with the J array processing language SOFTWARE.

Computer Vision 2. SS 18 Dr. Benjamin Guthier Professur für Bildverarbeitung. Computer Vision 2 Dr. Benjamin Guthier

Schedule for Rest of Semester

New Edge-Enhanced Error Diffusion Algorithm Based on the Error Sum Criterion

EECS 556 Image Processing W 09. Image enhancement. Smoothing and noise removal Sharpening filters

EE 701 ROBOT VISION. Segmentation

IMAGE DE-NOISING IN WAVELET DOMAIN

Sampling and Reconstruction

Plane Wave Imaging Using Phased Array Arno Volker 1

Classification of Subject Motion for Improved Reconstruction of Dynamic Magnetic Resonance Imaging

CoE4TN3 Medical Image Processing

Black generation using lightness scaling

International ejournals

Image Enhancement. Digital Image Processing, Pratt Chapter 10 (pages ) Part 1: pixel-based operations

CS 325 Computer Graphics

Filtering, scale, orientation, localization, and texture. Nuno Vasconcelos ECE Department, UCSD (with thanks to David Forsyth)

A Novel Image Transform Based on Potential field Source Reverse for Image Analysis

Image Segmentation Based on Watershed and Edge Detection Techniques

Biomedical Image Analysis. Spatial Filtering

Index. 1. Motivation 2. Background 3. JPEG Compression The Discrete Cosine Transformation Quantization Coding 4. MPEG 5.

Image Transformation Techniques Dr. Rajeev Srivastava Dept. of Computer Engineering, ITBHU, Varanasi

1. (10 pts) Order the following three images by how much memory they occupy:

Image Processing. Overview. Trade spatial resolution for intensity resolution Reduce visual artifacts due to quantization. Sampling and Reconstruction

A Novel Field-source Reverse Transform for Image Structure Representation and Analysis

Biometrics Technology: Image Processing & Pattern Recognition (by Dr. Dickson Tong)

Locating Salient Object Features

Computer Graphics. Texture Filtering & Sampling Theory. Hendrik Lensch. Computer Graphics WS07/08 Texturing

Biomedical Image Processing

Fine Arts in Solow Model. Abstract

Detecting Salient Contours Using Orientation Energy Distribution. Part I: Thresholding Based on. Response Distribution

GIST. GPU Implementation. Prakhar Jain ( ) Ejaz Ahmed ( ) 3 rd May, 2009

ONED Version 2.00 (X Windows version)

TEXTURE ANALYSIS USING GABOR FILTERS

3. (a) Prove any four properties of 2D Fourier Transform. (b) Determine the kernel coefficients of 2D Hadamard transforms for N=8.

An Intuitive Explanation of Fourier Theory

Computer Graphics. Sampling Theory & Anti-Aliasing. Philipp Slusallek

Texture Segmentation by using Haar Wavelets and K-means Algorithm

Fraunhofer Institute for Computer Graphics Research Interactive Graphics Systems Group, TU Darmstadt Fraunhoferstrasse 5, Darmstadt, Germany

Zero Order Correction of Shift-multiplexed Computer Generated Fourier Holograms Recorded in Incoherent Projection Scheme

Image Compression Techniques

Lecture 2 Image Processing and Filtering

IMAGE PROCESSING USING DISCRETE WAVELET TRANSFORM

JNTUWORLD. 4. Prove that the average value of laplacian of the equation 2 h = ((r2 σ 2 )/σ 4 ))exp( r 2 /2σ 2 ) is zero. [16]

Introduction to Digital Image Processing

Diffusion Wavelets for Natural Image Analysis

Construction of an Active Triangulation 3D Scanner for Testing a Line Following Strategy

Bioimage Informatics. Lecture 8, Spring Bioimage Data Analysis (II): Point Feature Detection

Curvelet Transform with Adaptive Tiling

Spatial Enhancement Definition

The 2D Fourier transform & image filtering

Chapter 7. Widely Tunable Monolithic Laser Diodes

Outline. Medical Image Processing with Orientation Scores. Mathematica in the BioMIM lab. The Biomedical Image Analysis group

Lab 1: Basic operations on images in Matlab

Periodicity Extraction using Superposition of Distance Matching Function and One-dimensional Haar Wavelet Transform

A Novel Approach to Saliency Detection Model and Its Applications in Image Compression

Image Processing

2D Image Processing INFORMATIK. Kaiserlautern University. DFKI Deutsches Forschungszentrum für Künstliche Intelligenz

IMAGING. Images are stored by capturing the binary data using some electronic devices (SENSORS)

Lecture 4: Spatial Domain Transformations

Ulrik Söderström 17 Jan Image Processing. Introduction

Assignment 3: Edge Detection

Image and Multidimensional Signal Processing

DATA EMBEDDING IN TEXT FOR A COPIER SYSTEM

Image restoration. Restoration: Enhancement:

Edge detection. Stefano Ferrari. Università degli Studi di Milano Elaborazione delle immagini (Image processing I)

Lecture 4 Image Enhancement in Spatial Domain

Examination in Image Processing

Fourier transforms and convolution

A COMPARISON OF WAVELET-BASED AND RIDGELET- BASED TEXTURE CLASSIFICATION OF TISSUES IN COMPUTED TOMOGRAPHY

CHAPTER 1 Introduction 1. CHAPTER 2 Images, Sampling and Frequency Domain Processing 37

Erosion, dilation and related operators

EXAM SOLUTIONS. Image Processing and Computer Vision Course 2D1421 Monday, 13 th of March 2006,

Digital Halftoning Algorithm Based o Space-Filling Curve

Fourier Transform and Texture Filtering

Error-Diffusion Robust to Mis-Registration in Multi-Pass Printing

INTENSITY TRANSFORMATION AND SPATIAL FILTERING

EECS490: Digital Image Processing. Lecture #19

Analysis of Planar Anisotropy of Fibre Systems by Using 2D Fourier Transform

Simulations of the Angular Dependence of the Dipole-Dipole Interaction

Algebraic Iterative Methods for Computed Tomography

Transcription:

This article has not been updated for Mathematica 8. The Mathematica Journal Dither Removal Bart M. ter Haar Romeny Mathematica is ideal for explaining the design of seemingly complex mathematical methods. In this article we explain the use of the 2D Fourier transform to remove unwanted dithering artifacts from images. All steps are visualized, so the reader can get a good idea of what the Fourier transform of an image looks like, the location of the origin, the artifacts and their extent, and how geometric reasoning works in the Fourier domain. The method leads to a marked clean up of images deteriorated by dither. Image Dithering Image dithering is often used for commercial print products like newspapers and magazines. Many printers (e.g., laser and inkjet printers) can only put a series of single black dots on paper. Intensity is then regulated by the local density of the dots. This process is called dithering. However, when a dithered image is scanned, the interaction between the discrete scanning process and dithering may seriously degrade the image. Dithering and scanning are often both periodic, leading to periodic interference artifacts. These can be removed by proper filtering in the spatial 2D Fourier domain. We first give an example of how dithering can be applied to an image. It is simplest to replace each pixel with a small array of random black dots, with the number of dots proportional to the intensity. Some general settings: In[1]:= SetOptions ListDensityPlot, Mesh False, ImageSize, AspectRatio Automatic, PlotRange All ; LinearAlgebra MatrixManipulation ; SetDirectory DirectoryName ToFileName "FileName". NotebookInformation EvaluationNotebook ; The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Dither Removal 433 In[4]:= url "http: www.bmi2.bmt.tue. nl image analysis People BRomeny images "; pixels Import url "mr64.gif" 1, 1 ; ListDensityPlot pixels 6 5 4 3 2 1 1 2 3 4 5 6 In[7]:= Out[7]= min, max Min pixels, Max pixels, 214 The dithering function creates a small 16 µ 16 array, which enables us to make 256 different intensities. In[8]:= dither int_ : Table If Random int,1,, 16, 16 ; 214. We map this onto every pixel and get an image that is 16 times larger with dithered points. The function BlockMatrix (available in LinearAlgebra Ma trixmanipulation ) combines the different submatrices. The Mathematica Journal 1:2 6 Wolfram Media, Inc.

434 Bart M. ter Haar Romeny In[9]:= dithered Map dither, pixels, 2 ; ListDensityPlot BlockMatrix dithered 1 8 6 4 4 6 8 1 There are many sophisticated ways to dither an image. For a good overview see [1]. One of the best methods is the Floyd Steinberg dithering method, based on error-diffusion [2]. The following graphic is an example. In[11]:= Show Import "http: www.webstyleguide.com graphics graphics 7.9.gif" Scanning a Dithered Image A problem occurs when the dithering mask is not made up of randomly placed black-and-white pixels but has some regularity. The dithered image then contains many highly regular spatial frequencies, which may give rise to interference patterns when the image is sampled with a regular scanner, which likely has a different sampling frequency. The result is a range of extra harmonics (i.e., frequencies that are the result of the interference). They come as the products of The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Dither Removal 435 the frequencies involved. An example of the period of the frequencies that emerge follows. In[12]:= Plot Sin x Sin 1.1 x, x,, 1 Π 1.5 5 1 15 25 3 -.5-1 This occurs because the product signal is actually the addition of the sum and the difference of the base frequencies. In[13]:= Out[13]= TrigReduce Sin x Sin 1.1 x 1 Cos.1 x Cos 2.1 x 2 The lower frequencies are rarely a problem. The higher frequencies can be removed by proper low-pass filtering. Dither Removal by Filtering A large dithered and scanned input image follows (345 µ 117 pixels, 1.9MB). Note the periodic artifacts. In[14]:= im Import url "AIA19E tiger.gif" ; Show im, ImageSize 3 Figure 1. Image of a tiger, produced by printing a stock-art photo with an 85 lines per inch dot screen printer and then scanning. The image is imported as a structure, in which the pixels and the header data are embedded. The pixels can be extracted as the 1,1 element. The Mathematica Journal 1:2 6 Wolfram Media, Inc.

436 Bart M. ter Haar Romeny In[16]:= Out[17]= pixels im 1, 1 ; Dimensions pixels 117, 345 To develop the method, we do not need the whole image. For speed and lower memory use, we take a subimage. We can see the periodic dithering more clearly by zooming in. In[18]:= ListDensityPlot subim Take pixels, 5, 78, 38, 7 25 15 1 5 5 1 15 25 3 In[19]:= ydim, xdim Dimensions subim ; Because the dithering has a high spatial frequency, we suspect these frequencies to be higher than most of the other frequencies in the image. We compute the Fourier spectrum of the input image and plot its absolute value. Because the origin is really large, the image is automatically scaled with a large factor, which reduces the contrast. We zoom in on a limited range ( 1) of spectral values. In[2]:= ListDensityPlot Abs fft Fourier subim, PlotRange, 1 25 15 1 5 5 1 15 25 3 The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Dither Removal 437 The significant image frequencies are around the origin (i.e., in the corners of the periodic spectrum plot). The marked peaks at other locations are proof of the existence of strong periodic signals due to dithering. We will use a mask that allows only frequencies near the origin to be included: a low-pass filter for spatial frequencies. The mask is most easily created by an elliptic Gaussian weighting function in the center (different standard deviations in the x and y directions), which is then shifted over half the image size in each dimension to put the kernel at the origin of the Fast Fourier Transform (FFT) domain, which is in the lower left. Note that the Fourier domain is periodic in either dimension, so we actually see a single tile of a whole tiled 2D space in the x and y directions. The standard deviations have to be estimated from the 2D plot of the spectrum. For speed, we exploit the separability of the 2D Gaussian kernel. We first make two 1D arrays of Gaussian values and then multiply them into a matrix with Outer in a compiled function. This is about 14 times faster than a 2D Table command. Σxs and Σys are the standard deviations of the Gaussian in the x and y directions of the subimage. In[21]:= Σxs 4.; Σys 35.; mask Compile, Outer Times, In[24]:= ydim xdim Range ydim Range xdim 2 2 Exp, Exp ; 2 Σys 2 2 Σxs 2 maskr RotateLeft mask, Floor ydim 2, xdim 2 ; ListDensityPlot maskr 2 2 25 15 1 5 5 1 15 25 3 We also can inspect the amplitude spectrum and the low-pass Gaussian filter (both functions are scaled for plotting) along the interpolated diagonal positions of the rectangular image. In[25]:= interpolated ListInterpolation afft Abs fft Fourier subim ; The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Bart M. ter Haar Romeny 438 Here we view the mask as a height plot. In[26]:= ListPlot3D maskr, Mesh False, PlotRange All 1.75.5.25 1 1 3 We multiply the Fourier spectrum with the mask and study it visually. In[27]:= ListDensityPlot maskr Abs fft, PlotRange, 1 25 15 1 5 5 1 15 25 3 We mask out the unwanted frequencies by multiplying the spectrum with the mask, and we get the resulting image by the inverse Fourier transform. The Gaussian filtering is still letting some periodic frequencies through (we only like to keep the information near the corners), so we make it steeper by raising it to the third power. The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Dither Removal 439 In[28]:= ListDensityPlot maskr 3 Abs fft, PlotRange, 1 25 15 1 5 5 1 15 25 3 In[29]:= restored Abs InverseFourier fft maskr 3 ; The result is a markedly improved image, without the disturbing dithering frequencies. In[3]:= ListDensityPlot subim, restored 25 15 1 5 5 1 15 25 3 The Mathematica Journal 1:2 6 Wolfram Media, Inc.

44 Bart M. ter Haar Romeny 25 15 1 5 5 1 15 25 3 The dither is clearly removed, and details, such as the local hair bundles, can now clearly be discriminated. The following reads the whole image, processes the data in the Fourier domain (note that s x and s y are proportionally rescaled), and writes the restored image to disk, in this case as a GIF file. In[31]:= pixels im 1, 1 ; ydim, xdim Dimensions pixels ; fft Fourier pixels ; Σy, Σx Σys, Σxs Dimensions pixels Dimensions subim ; mask Compile, Outer Times, In[38]:= ydim xdim Range ydim Range xdim 2 2 Exp, Exp ; 2 Σy 2 2 Σx 2 maskr RotateLeft mask, Floor ydim 2, xdim 2 ; restored Abs InverseFourier fft maskr 3 ; 2 Display "restored.gif", ListDensityPlot restored, ImageSize Reverse Dimensions restored, DisplayFunction Identity, "GIF" ; 2 Conclusion This example shows the use of Fast Fourier Transform to remove periodic artifacts from an image. Despite the large size of the input image, the numerical performance of Mathematica is good. The Mathematica Journal 1:2 6 Wolfram Media, Inc.

Dither Removal 441 References [1] R. L. Adler, B. P. Kitchens, M. Martens, C. P. Tresser, and C. W. Wu, The Mathematics of Halftoning, IBM Journal of Research and Development, 47(1), 3 pp. 5 15 www.research.ibm.com/journal/rd/471/adler.pdf. [2] R. Floyd and L. Steinberg, An Adaptive Algorithm for Spatial Grey Scale, SID International Symposium Digest of Technical Papers, San Jose, CA: The Society for Information Display (SID), 1975 pp. 36 37. B. M. ter Harr Romeny, Dither Removal, The Mathematica Journal, 212. dx.doi.org/1.3888/tmj.1.2-9. About the Author Bart M. ter Haar Romeny received an M.S. in applied physics from Delft University and a Ph.D. in 1983 from Utrecht University, The Netherlands. Ter Haar Romeny served from 1983 to 1 as principal physicist and associate professor in the Department of Radiology and Image Sciences Institute at Utrecht University. He is now a full professor in the Department of Biomedical Engineering at Eindhoven University of Technology. His interests are medical image analysis and multiscale computer vision, including its mathematical foundations and clinical applications. A focus on the human visual system gives biological inspiration for mathematics. He is the author of a popular, interactive tutorial book on perceptually inspired multiscale image analysis written in Mathematica. Bart M. ter Haar Romeny Eindhoven University of Technology Department of Biomedical Engineering Biomedical Image Analysis Den Dolech 2, WH2.16 NL-56 MB Eindhoven, The Netherlands B.M.terHaarRomeny@tue.nl bmia.bmt.tue.nl/people/bromeny/index.html The Mathematica Journal 1:2 6 Wolfram Media, Inc.