histogram and region based processing c. andrés méndez 20/03/2013

16
Histogram and region based processing C. Andrés Méndez 20/03/2013

Upload: alberta-pizzi

Post on 02-May-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Histogram and region based processing C. Andrés Méndez 20/03/2013

Histogram and region based processing

C. Andrés Méndez20/03/2013

Page 2: Histogram and region based processing C. Andrés Méndez 20/03/2013

Where to find the presentations?

http://profs.sci.univr.it/~mendezguerrero

Page 3: Histogram and region based processing C. Andrés Méndez 20/03/2013

Intensity Transformation Functions

• Esercizio 1• Caricare l’immagini pout.tif e tire.tif

– Visualizzare l’immagine e il suo istogramma

• Regolare l’intensità– funzione imadjust (help imadjust)– imadjust(f,[low_in high_in], [low_out high_out], gamma)

Page 4: Histogram and region based processing C. Andrés Méndez 20/03/2013

negative

b=imadjust(pout,[0 1],[1 0]);figure,imshow(b)

Page 5: Histogram and region based processing C. Andrés Méndez 20/03/2013

Istogramma

• L’istogramma è la rappresentazione grafica della quantità di pixel presenti nell’immagine per ciascun livello di grigio.– L’asse orizzontale X rappresenta i valori dei

grigi. L’asse verticale Y rappresenta il numero di pixel per ogni livello.

0

200

400

600

800

1000

1200

1400

1600

0 50 100 150 200 250

Page 6: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma

• E’ una tecnica che mira a modificare la forma dell’istogramma redistribuendo i valori dei livelli di grigio in modo che l’istogramma sia quanto più uniforme possibile.

• L’obiettivo è quello di migliorare l’immagine a debole contrasto.

• Tuttavia, un’equalizzazione non porta necessariamente ad un miglioramento dell’immagine (Es. immagine con istogramma bimodale).

Page 7: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma• L’operazione di equalizzazione ha lo scopo di

ottenere per l’istogramma un andamento praticamente costante.– Per fare ciò si sostituisce al valore x di livello di grigio

un valore y dato dalla seguente trasformazione:

– dove T è il numero complessivo dei pixel dell’immagine, L è il valore massimo dei livelli di grigi Ni è il numero di pixel che hanno un livello di grigio uguale a i, ovvero H(i)

Page 8: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma

0

1000

2000

3000

0 100 200

0

1000

2000

3000

0 100 200

Page 9: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma

• Esercizio 2• Caricare l’immagini pout.tif e tire.tif

– Visualizzare l’immagine e il suo istogramma (imhist)

• Equalizzare l’istogramma– Visualizzare l’immagine equalizzata e il

suo istogramma (histeq)

Page 10: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma

• A volte, l’equalizzazione dell’istogramma non produce i migliori risultati o il contrasto che aspettiamo.– Esempio, presso da Digital Image Processing, Using

MATLAB, by Rafael C. Gonzalez,

adapthisteqhisteq

Page 11: Histogram and region based processing C. Andrés Méndez 20/03/2013

original

0

1

2

3

4

5

6

x 104

0 50 100 150 200 250

equalized

0

1

2

3

4

5

6

x 104

0 50 100 150 200 250

adaptive

0

1

2

3

4

5

6x 10

4

0 50 100 150 200 250

Equalizzazione dell’istogramma

• Esercizio 3• >>help adapthisteq (Contrast-limited adaptive

histogram equalization )

• Load deathstar.jpg• Show original, equalized and adaptive-equalized

images with their respective histograms

Page 12: Histogram and region based processing C. Andrés Méndez 20/03/2013

original

0

1

2

3

4

5

6

x 104

0 50 100 150 200 250

equalized

0

1

2

3

4

5

6

x 104

0 50 100 150 200 250

adaptive

0

1

2

3

4

5

6x 10

4

0 50 100 150 200 250

Page 13: Histogram and region based processing C. Andrés Méndez 20/03/2013

Equalizzazione dell’istogramma

• Esercizio 3 (continuation)

• >>doc adapthisteq (open documentation)• Load deathstar.jpg• Modify parameters>

– ‘NumTiles’ ( for example 'NumTiles', [16 16])– ‘ClipLimit’

• Show image and histograms,• Compare the results (also with POUT.tif and TIRE.tif)

Page 14: Histogram and region based processing C. Andrés Méndez 20/03/2013

Funzioni per la Trasformazione di Intensità

• Le elaborazioni nel dominio spaziale possono essere espresse come:

g(x,y)= T[f(x,y)]

• essendo f l’immagine di ingresso alla elaborazione, g quella di uscita e T un operatore su f, definito in un intorno di (x,y). La dimensione dell’intorno di (x,y) definisce il carattere della elaborazione: – puntuale(l’intorno coincide con il pixel stesso); – locale(per esempio una piccola regione quadrata centrata

sul pixel); – globale(l’intorno coincide con l’intera f).

Page 15: Histogram and region based processing C. Andrés Méndez 20/03/2013

Bimodal histogram• Esercizio 4• Create a 400x400 image with

normally distributed pixels. – Normal dist., mean=100, std=25– Matlab: (randn)

• In the previous image insert a 250x250 square with pixels following the distribution: – normal dist., mean =170, std=20

• Visualize the image and its histogram– imshow – hist (better in this case than imhist)

0

200

400

600

800

1000

1200

1400

1600

1800

2000

0 50 100 150 200 250

Page 16: Histogram and region based processing C. Andrés Méndez 20/03/2013

Bimodal Histogram, optimal threshold

• Esercizio 5• How to automatically select the best

threshold value for segmentation?

• Implement the following automatic procedure 1. Choose initial threshold (e.g. randomly)2. Segment the image into object and

background3. Compute mean intensity of object

(mean1 ) and background (mean2 )4. Set new threshold to (mean1+mean2 )/25. Repeat from Step 2 until convergence

• Apply the procedure to the previous image

• Generate a new combination of two distributions and apply the method

0

200

400

600

800

1000

1200

1400

1600

1800

2000

0 50 100 150 200 250