Image Restoration Comp 344 Tutorial Kai Zhang Outline

  • Slides: 18
Download presentation
Image Restoration Comp 344 Tutorial Kai Zhang

Image Restoration Comp 344 Tutorial Kai Zhang

Outline n DIPUM Tool box n Noise models n Periodical noise and removal n

Outline n DIPUM Tool box n Noise models n Periodical noise and removal n Noise parameter estimation n Spatiral noise removal

The DIPUM Tool box n M-functions from the book Digital Image Processing Using MATLAB

The DIPUM Tool box n M-functions from the book Digital Image Processing Using MATLAB n http: //www. imageprocessingplace. com/DIPU M_Toolbox_1/dipum_toolbox_main_page. htm n Freedownload No original m-functions n But can still used for demo n

Noise models n Given a random number generator, how to generate random numbers with

Noise models n Given a random number generator, how to generate random numbers with a pre-specified CDF? n Suppose the random number w is in [0, 1] We want to generate a Rayleigh distributed sample set n To find z solve the following equation n

Functions n Function r = imnoise(f, type, parameters) n Corrupt image f with noise

Functions n Function r = imnoise(f, type, parameters) n Corrupt image f with noise specified in type and parameters n Results returned in r n Type include: uniform, gaussian, salt & pepper, lognormal, rayleigh, exponential n Function r = imnoise 2(type, M, N, a, b); n Generates arrar r of size M-by-N, n Entries are of the specified distribution type n A and b are parameters

Examples

Examples

Codes n Code 1 n f = imread('lenna. jpg'); n g = imnoise(f, 'gaussian',

Codes n Code 1 n f = imread('lenna. jpg'); n g = imnoise(f, 'gaussian', 0, 0. 01); n figure, imshow(g); n g = imnoise(f, 'salt & pepper', 0. 01); n figure, imshow(g); n Code 2 n r = imnoise 2('gaussian', 10000, 1, 0, 1); n p = hist(r, 50); n bar(p);

Periodical spatial noise n Model n Using 2 -d sinusoid functions n n M,

Periodical spatial noise n Model n Using 2 -d sinusoid functions n n M, N: image size A: magnitude of noise U 0, v 0: frequency along the two directions Bx, By: phase displacement n Observation: when x goes through 0, 1, 2, …, M, the left term will repeat u 0 times. So the horizontal frequency is u 0. Similar for v 0.

n Function: [r, R, S] = imnoise 3(M, N, C, A, B); n Generate

n Function: [r, R, S] = imnoise 3(M, N, C, A, B); n Generate a sinusoide noise pattern r n Of size M by N n With Fourier transform R n And spectrum S n C is a K-by-2 matrix, each row being coordinate (u, v) of an impulse n A 1 -by-K contains the amplitude of each impulse n B is K-by-2 matrix each row being the phase replacement

Periodic noise examples

Periodic noise examples

Codes n C = [0 64; 0 128; 32 32; 64 0; 128 0;

Codes n C = [0 64; 0 128; 32 32; 64 0; 128 0; -32 32]; n [r, R, S] = imnoise 3(256, C); n figure, imshow(S, []); n figure, imshow(r, []);

Noise estimation n How to determine type and parameters of noise given an image

Noise estimation n How to determine type and parameters of noise given an image f corrupted by noise? n n Step 1. Manually choosing a region as featureless as possible, so that variability is primarily due to noise. [B, c, r] = roipoly(f); Step 2. compute the histogram of the selected image patch [p, npix] = histroi(f, c, r); Step 3. determine the noise type through observation Step 4. estimating the central moments [v, unv] = statmoments(p, 2);

Illustrations

Illustrations

Functions n Function: [B, c, r] = roipoly(f); n F is the image n

Functions n Function: [B, c, r] = roipoly(f); n F is the image n C and r are sequential column and row coordinates of the polygon / can also be specified by the mouse n B is the region selected (of value 1), and all the rest part of the image is 0 n Function [p, npix] = histroi(f, c, r); n Generating histogram p of the region of interest(ROI) specified in c and r (vertex coordinates)

codes n n n n n f = imread(‘lenna. jpg’); noisy_f = imnoise(f, 'gaussian',

codes n n n n n f = imread(‘lenna. jpg’); noisy_f = imnoise(f, 'gaussian', 0, 0. 01); figure, imshow(noisy_f, []); [B, c, r] = roipoly(noisy_f); %needs mouse interations figure, plot(B); [p, npix] = histroi(f, c, r); figure, bar(p, 1); [v, unv] = statmoments(p, 2); X = imnoise 2('gaussian', npix, 1, unv(1), unv(2)^0. 5); figure, hist(X, 100);

Spatial noise removal n Function f = spfilter(g, type, m, n, parameter); n Performs

Spatial noise removal n Function f = spfilter(g, type, m, n, parameter); n Performs spatial filtering n Type include: amean, gmean, hmean, chmean, median, max, min, midpoint, artimmed

Codes n Creating a salt noise image n f = imread('lenna. jpg'); n R

Codes n Creating a salt noise image n f = imread('lenna. jpg'); n R = imnoise 2('salt & pepper', M, N, 0. 1, 0); n c = find(R == 0); n gp = f; n gp(c) = 0; n figure, imshow(gp); n Filtering n fp = spfilt(gp, 'chmean', 3, 3, 1. 5); n fpmax = spfilt(gp, 'max', 3, 3); n figure, imshow(fpmax);

Examples of filtering

Examples of filtering