Sei sulla pagina 1di 36

24-03-2010

Rinforzo di Immagini: tecniche spaziali

Elaborazione dei dati multimediali a.a. 2009/10

Analisi del rumore


!!

Def.: disturbo dellimg introdotto dal sistema di acquisizione o dal mezzo di propagazione che ne degrada la qualit. Pi in generale ogni entit nellimg che non rilevante per lo scopo della computazione principale Esempi:
! fluttuazioni dei ldg dei pixel (introdotti dal sistema di acquisizione) che disturbano i processi di estrazione di edge ! risultati di algoritmi che sono degradati dalla precisione finita dei registri ! informazione non rilevante, eg., linee che non appartengono a nessun oggetto

!!

24-03-2010

!!

Il rumore tipicamente modellato come additivo e casuale:

!!

la quantit di rumore pu essere stimata con la varianza, !n2, o la deviazione standard, !n " SNR

!!

dove !s la deviazione standard del segnale e !n la deviazione standard del rumore. Tipicamente si esprime in decibel (dB)

Rumore Gaussiano
!!

Tipicamente, il rumore si modella come un processo casuale BIANCO, GAUSSIANO e a MEDIA NULLA n(i,j) realizzazione di una v.c.
! avente distribuzione Gaussiana ! con spettro piatto (bianco) " senza memoria ! media 0

!!

In dipendenza di ! i ldg variano simmetricamente intorno al loro valore reale. Il loro istogramma

!!

Il 95% dei valori sono compresi entro 2! dal valor medio

24-03-2010

Rumore impulsivo
!! !! !! !!

Anche chiamato spot o peak noise Altera il ldg in maniera marcata, ie., diverso dal valore dei pixel in oggetto e dei suoi vicini Pu essere causato da errori di trasmissione, CCD rovinati, o rumore che corrompe la conversione A/D Si modella come rumore sale& pepe:

dove I img reale; x, y # [0,1] v.c. uniformemente distribuite; l parametro che controlla quanto limg corrotta; imax, imin controllano la forza del rumore

Altri tipi di rumore


!! !!

Uniforme Rayleigh
! Modello di tipo esponenziale utilizzato per modellare rumore di tipo speckle che degrada le img radar/sonar

!!

Gamma
! Modello di tipo esponenziale negativo del tipo

24-03-2010

Rayleigh

H Gamma

originale

Rumore additivo Gaussiano

Rumore additivo uniforme

Rumore sale & pepe (speckle)

24-03-2010

Filtraggio spaziale
!!

!! !!

!!

Use of spatial masks for image processing (spatial filters) Linear and nonlinear filters Smoothing filters eliminate or attenuate sharp image details (and noise) and result in image blurring. Sharpening filters resulting in sharpening edges and other sharp details.

Spatial Filtering
!!

The basic approach is to sum products between the mask coefficients and the intensities of the pixels under the mask at a specific location in the image:

R = w1 f1 + w 2 f 2 + ... + w 9 f 9

(for a 3 x 3 filter)

24-03-2010

Spatial Filtering
a b

g( x, y ) =
!!

# # w(s, t) f ( x + s, y + t )
s = " at = " b

a=(m-1)/2 and b=(n-1)/2, m x n (odd numbers) !! For x=0,1,,M-1 and y=0,1,,N-1 ! ! ! Also called convolution

24-03-2010

Filtraggio lineare
!!

Siano:
! ! ! !

I, img N $ M m, numero dispari < N,M A, kernel di un filtro lineare IA, img filtrata

Operazione di convoluzione, che noi confondiamo con la correlazione se la maschera simmetrica

!!

In pratica, un filtro lineare rimpiazza un valore I(i,j) con una somma pesata dei valori di I nellintorno di (i,j), dove i pesi sono dati dai coefficienti della maschera (correlazione)

Smoothing Filters
!!

Used for blurring (removal of small details prior to large object extraction, bridging small gaps in lines) and noise reduction. Neighborhood averaging

!!

- Results in image blurring

24-03-2010

Inserto: Teorema centrale del limite


!!

Se si mediano n valori intorno al pixel allora la dev. standard del rumore nel pixel si riduce di un fattore pari a sqrt(n) Il teorema afferma che se si ha una somma di variabili aleatorie Xi indipendenti e identicamente distribuite (con densit uguali) con media e varianza 2, allora indipendentemente dalla forma distributiva di partenza, al tendere della dimensione campionaria a infinito la somma tende a distribuirsi come una variabile casuale normale:
n

!!

per n "#
!!

$X
i =1

~ N ( n, n% 2 )

P.S. Questo spiega anche la riduzione del rumore di per averaging.

24-03-2010

24-03-2010

Filtro media 3x3

Immagine originale

Media mobile: finestra 3x3

Media mobile: finestra 5x5

Media mobile: finestra 9x9

10

24-03-2010

Gaussian smoothing
!! !! !! !!

The effect of Gaussian smoothing is to blur an image, in a similar fashion to the mean filter. The degree of smoothing is determined by the standard deviation of the Gaussian. Larger standard deviation Gaussians, of course, require larger convolution kernels in order to be accurately represented. The Gaussian outputs a `weighted average' of each pixel's neighborhood, with the average weighted more towards the value of the central pixels.

Gaussian smoothing
This is in contrast to the mean filter's uniformly weighted average. Because of this, a Gaussian provides gentler smoothing and preserves edges better than a similarly sized mean filter. One of the principle justifications for using the Gaussian as a smoothing filter is due to its frequency response. In fact, the shape of the frequency response curve is itself Gaussian.

!!

!!

!!

11

24-03-2010

Questo filtro pu essere implementato in maniera efficiente in quanto il kernel separabile

Maschera gaussiana unidimensionale

!!

quindi possibile convoluire una Gaussiana 1D con tutte le righe delimg e successivamente con tutte le colonne (complessit lineare invece di quadratica nella dimensione della maschera) Algoritmo: convoluzione dellimg I con G, Gaussiana 2D m$n avente !=!G:
! costruire una Gaussiana 1D, g, di dimensione m e !=!G; ! convoluire ogni riga di I con g % IR ! convoluire ogni colonna di IR con gT % IG

!!

12

24-03-2010

Costruzione di un kernel Gaussiano !! Si consideri una maschera 1D e si campioni una Gaussiana continua !! Si fissi ! e la dimensione della maschera W (dispari) !! Relazione tra W e !: dato !, W deve essere tale da contenere unelevata percentuale dellarea della Gaussiana !! Esempio: W = 5! % 98.76 % dellarea !! Quindi se si sceglie Troppo piccola ! W = 3 pixel % ! = 3/5 = 0.6 pixel ! W = 5 pixel % ! = 1 pixel
!!

In generale : !W = W/5

Troppo grande

Smoothing Gaussiano per medie ripetute


!!

Si filtra ripetutamente limg I col filtro MEDIA Per il teoreme centrale del limite, convoluire una maschera 3 $ 3, n volte con I, approssima la convoluzione con una maschera Gaussiana avente ! e dimensione della maschera W

!!

13

24-03-2010

Non-linear filters
!!

Non-linear filters also use pixel neighborhoods but do not explicitly use coefficients
! e.g. noise reduction by median gray-level value computation in the neighborhood of the filter

Filtro mediano
!!

Median filtering (nonlinear)


! Used primarily for noise reduction (eliminates isolated spikes) ! The gray level of each pixel is replaced by the median of the gray levels in the neighborhood of that pixel (instead of by the average as before).

Iout ( x, y ) = AN 2 / 2 Ai sono i pixel della finestra N " N intorno a (x,y) ordinati

14

24-03-2010

!!

(riduce rumore Gaussiano, elimina rumore impulsivo)


!!

Vantaggi: riduce rumore casuale preservando le zone di contorno

Svantaggi: pi oneroso di una convoluzione causa loperazione di ordinamento, va regolato in modo euristico in base al problema considerato

larghezza filtro

!!

In generale, leffetto di di riduzione del rumore dipende da: Si possono utilizzare pixel sparsi allinterno della maschera per ridurre il costo computazionale (a scapito delle prestazioni) Il filtro mediano un caso particolare di rank filter (anche MIN e MAX): anche un caso particolare di filtro media alfa-trimmed
! Ordino i pixel, scarto testa e coda (T) e ne faccio la media ! Ordino i pixel e prendo quello di posizione (rango) fissato ! dimensione e forma della maschera N (tipicamente N$N) ! il numero di pixel coinvolti (tipicamente N2)

!!

!!

!!

1 Iout ( x, y ) = 2 N " 2T

N 2 " 2T

#A
i =T +1

Ai sono i pixel della finestra N $ N intorno a (x,y) ordinati

!
15

24-03-2010

16

24-03-2010

Applicazione di filtraggio di rango su immagine corrotta da rumore impulsivo

a) Immagine corrotta da rumore impulsivo (sale e pepe)

b) Immagine filtrata rank -order (mediano finestra 5x5)

3x3

5x5

7x7

mean

median

17

24-03-2010

MATLAB demo

Riassunto panoramico
Smoothing
Rumore additivo (gaussiano, uniforme) Rumore impulsivo (sale e pepe) !Media !Gaussiana !Mediana (non lin) Rimozione del rumore Perdita di dettaglio (+lineari, - mediana)

Sharpening

Aumenta nitidezza (enfatizza dettagli) Enfatizza rumore

18

24-03-2010

Sharpening Filters
!!

To highlight fine detail or to enhance blurred detail. Averaging filters smooth out noise but also blur details Sharpening filters enhance details May also create artifacts (amplify noise) Background: Derivative is higher when changes are abrupt Categories of sharpening filters:
! Basic highpass spatial filtering ! High-boost filtering

!! !! !! !! !!

Basic Highpass Spatial Filtering


!!

The filter should have positive coefficients near the center and negative in the outer periphery:

Laplacian mask

Other Laplacian mask (normalization factor is missing)

19

24-03-2010

Basic Highpass Spatial Filtering


!!

!!

!! !! !!

The sum of the coefficients is 0, indicating that when the filter is passing over regions of almost stable gray levels, the output of the mask is 0 or very small. The output is high when the center value differ from the periphery. The output image does not look like the original one. The output image depicts all the fine details Some scaling and/or clipping is involved (to compensate for possible negative gray levels after filtering).

20

24-03-2010

High-boost Filtering
!!

Highpass filtered image = Original lowpass filtered image.

i.e., smoothed image

!!

If A is an amplification factor (say A=2) then:


! High-boost = A ! original lowpass = (A-1) ! original + original lowpass = (A-1) ! original + highpass

Unsharp masking

Unsharp Masking and Sharpening operation


Signal Low- pass

(1)

(2)

High-pass

(3) = (1) - (2)

(A-1) (1) + (3)

21

24-03-2010

High-boost Filtering
!! !!

A=1 : standard highpass result A>1 : the high-boost image looks more like the original with a degree of edge enhancement, depending on the value of A.

w=9A-1, A!1
A> 1 ! Unsharp masking

22

24-03-2010

Unsharp masking

h= I = imread('moon.tif'); 0 -1 0 imshow(I), title('originale') -1 4 -1 h = -fspecial('laplacian',0) 0 -1 0 I2 = filter2(h,I); figure, imshow(I2/255), title('laplaciano') figure, imshow((double(I)+I2)/255),title('originale+laplaciano') h = fspecial('unsharp',0) h= I2 = filter2(h,I)/255; 0 -1 0 figure, imshow(I2), title('unsharp masking') -1 0 5 -1 -1 0

23

24-03-2010

Geometric Image Operations


!! !! !! !!

!!

Slightly more complex than algebraic operations and are less used in image processing Mainly used in computer graphics So we will spend less time on them. In contrast to point operations, geometric image operations modify the spatial positions of pixels but not the gray levels A geometric operation requires two steps
! spatial mapping ! interpolation

Spatial Mapping
!!

!! !!

!! !!

A spatial mapping of the image coordinates yields a new image J: J(i,j) = I(i,j) = I[a(i,j), b(i,j)] The coordinates a(i,j) and b(i,j) are not generally integers Consider: new row: a(i,j) = i+0.3 new column: b(i,j) = j+0.3 Then, J(i,j) = I(i+0.3, j+0.3), which are undefined coordinates This implies the need for second operation - interpolation

24

24-03-2010

Nearest-Neighbor Interpolation
!!

!!

In this approach, the transformed coordinates are mapped to the nearest integer coordinates J(i,j) = I{INT[a(i,j)+0.5], INT[b(i,j)+0.5]} Where there are sudden changes in intensity, this can produce jagged edge effect.

!!

Source scan o forward mapping


source pixel " destination pixel

x y y

f(x,y), (x,y) ! Z
!!

g(x,y), (x,y) ! R

!!

Il pixel sorgente in generale -- cade in mezzo a 4 pixel nella destinazione. Il ldg f(x,y) viene assegnato al pixel di destinazione pi vicino a (x,y).

25

24-03-2010

!!

Destination scan o backward mapping

destination pixel " source pixel (using inverse transf.)

x y y

f(x,y), (x,y) ! R
!!

g(x,y), (x,y) ! Z

!!

Si tratta di assegnare un ldg al pixel (intero) di destinzione g (x,y), che si mappa nel punto f(x,y) (reale) nella immagine sorgente. Si pu usare nearest-neighbour, ma si pu fare di meglio

Bilinear interpolation
!! !!

Usa i lgd dei 4 vicini f(x,y) nota ai vertici di un quadrato unitario e si deve determinare il valore di f allinterno di tale quadrato Si fa il fit di un paraboloide iperbolico definito da

f(1,0)

f(0,0)

f(x,y) x,0
1,0

f(1,1)

!!

0,0

1,1 f(0,1)

0,y
0,1 f(x,y) = (1-x)(1-y)f(0,0) + x(1-y)f(1,0) + (1-x)yf(0,1) + xyf(1,1)

26

24-03-2010

Bilinear Interpolation

Bicubic interpolation
!!

!! !!

This method fits a bicubic surface through existing data points. The value of an interpolated point is a combination of the values of the sixteen closest points. This method is piecewise bicubic, and produces a much smoother surface than bilinear interpolation. This is not always the primary concern, however. For some applications, such as medical image processing, a method like nearest neighbor may be preferred because it doesn't generate any "new" data values

27

24-03-2010

Funzione di partenza

Funzione interpolata su una griglia pi fine con nearest neighbour

Funzione interpolata con bilineare

Funzione interpolata con bicubica

!!

Commenti: Il mapping diretto tipicamente pi oneroso in quanto i pixel di input possono mapparsi fuori dallimg e ogni pixel di output pu essere considerato pi volte Il mapping inverso genera limg di uscita linea per linea, ma richiede un accesso casuale allimg di ingresso e la trasformazione inversa pu non essere disponibile

28

24-03-2010

Spatial Transformations
!!

An image I with pixel coordinates (i, j) undergoes geometric distortion to produce an image J with coordinates (i,j): i = r(i,j) j = s(i,j)
For example, if r(i,j)= i/2 and s(i,j) = j/2. the distortion is simply a shrinking of the size of I( i,j) by one-half in both directions

!!

Basic Geometric Transforms


!!

First order transformations


! Translation ! Rotation ! Scaling

!!

Translation is the simplest geometric operation. Let a(i,j) = i-io, b(i,j) = j-jo where (io, jo) are constants. In this case J(i,j) = I(i-io, j-jo) which is a shift or translation of the image by an amount io in the vertical (row) direction and an amount jo in the horizontal direction

29

24-03-2010

Rotation
!!

!!

Rotation of any image by an angle ! relative to x-axis is accomplished by the following transformation: a(i,j) = i cos(!) j sin(!) b(i,j) = i sin(!) + j cos(!) The rotated image have to be translated for viewing (perch la rotazione attorno a (0,0) )

30

24-03-2010

Scaling (or zooming)


!!

!! !! !! !!

The scaling operation magnifies an image by the mapping functions: a(i,j) = c i; and b(i,j) = d j where c and d are the magnification factors. To enlarge an image, specify a magnification factor greater than 1. To reduce an image, specify a magnification factor between 0 and 1. For large magnifications, the zoomed image will look blocky Reducing the size introduces artifacts, due to subsampling.

Applicando nearest-neighbour nella riduzione, si possono perdere informazioni. Questo non succede se si usa interpolazione bilineare (per riduzioni non troppo spinte) o se si effettua preliminarmente uno smoothing della immagine . Anche usando interpolazione si possono produrre artefatti (Moir patterns) dovuti al sottocampionamento, che si riducono grazie allo smoothing preliminare

Bilineare, senza filtraggio

Bilineare, con filtraggio

31

24-03-2010

Originale

Interpolazione bilineare Interpolazione di ordine zero

Tiepoints
!! !!

In real world, the distortion is not that simple and not known analytically The common method used is to formulate the spatial relocation of pixels by use of tiepoints, which are subset of pixels whose location in the input and output images is known precisely

32

24-03-2010

Tiepoints & Bilinear Equations


!! !! !! !! !!

i = c1 i + c2 j + c3 ij + c4 j = c5 i + c6 j + c7 ij + c8 We need at least 4 tiepoints to solve above equations to find the constants More tiepoints can be used to solve above equations by least-squares method for higher accuracy Therefore, tiepoints establish the geometric distortion model

Example

Original Image

Distortion Model

Distorted Image

Registered Image

33

24-03-2010

Interp. metodo dei punti vicini

Interp. media sui vicini

Interp. bilineare

Registration
!! !! !! !! !!

Rotation, scaling, and translation may be used in a simple registration process Registration is the process of mapping pixel locations from one image to another Registration is often used in remote sensing: a satellite image must be registered to previous images of an area Often, one of the two images may be a map Higher-order functions may be needed to register the images if warping has occurred common in remote sensing due to atmosphere. motion, and shape of the earth (topography)

34

24-03-2010

Images

Base/Reference Image

Unregistered Image

Final Result

35

24-03-2010

Mosaicking
!! !!

An image is the union of several images into one image, where the images may contain overlapping regions The panorama is the simplest example of mosaic

36

Potrebbero piacerti anche