2.3.2 contrast stretching

Post on 30-Dec-2015

166 Views

Category:

Documents

17 Downloads

Preview:

Click to see full reader

DESCRIPTION

2.3.2 Contrast Stretching. Contrast The contrast of an image is its distribution of light and dark pixels. Fig. 2.12 Low and high contrast histogram. Contrast Stretching. Contrast stretching Clipping thresholding. Contrast Stretching. Contrast Stretching, a = 80, b= 160. Original Image. - PowerPoint PPT Presentation

TRANSCRIPT

2.3.2 Contrast StretchingContrast

The contrast of an image is its distribution of light and dark pixels

Fig. 2.12 Low and high contrast histogram.

Contrast Stretching Contrast stretching

Clipping

thresholding

Lubvbu

buavau

auu

v

LvLuufv

b

a

)(

)(

0,

],0[],,0[)(

0 ],[ bautba

Contrast Stretching

5.0

5.0

5.1

5.1

5.0

5.0

5.0

5.1

5.0

Contrast Stretching, a = 80, b= 160

Contrast Stretching

Original Image

Original Image

Basic Contrast Stretching

End-in Search

Original Image Convert ImageContrast Stretching

Red Green Blue

/******************************************** * Func: auto_contrast_stretch * Desc: performs basic contrast stretching on an image

* Params: source - pointer to source image

* cols - number of columns in the image *

rows - height of image * ********************************************* void auto_contrast_stretch(image_ptr source, int cols, int

rows) { long i; /* loop variable */ long number_of_pixels; /* total number of pixels in

image */

long histogram[256]; /* image histogram */ unsigned char LUT[256]; /* Look-up table for point

process */ int lowthresh, highthresh; /* lower and upper

thresholds */ float scale_factor; /* scaling factor for contrast stretch

*/ /* compute histogram */ number_of_pixels = (long)cols * rows; for(i=0; i<256; i++) histogram[i]=0; for(i=0; i<number_of_pixels; i++) histogram[source[i]]++;

/* compute low and high thresholds */ for(i=0; i<256; i++) if(histogram[i]) { lowthresh = i; break; } for(i=255; i>0; i--) if(histogram[i]) { highthresh = i; break; }

printf("Low threshold is %d High threshold is %d\n",

lowthresh,highthresh);

/* compute new LUT */ for(i=0; i<lowthresh; i++) LUT[i]=0;

for(i=255; i>highthresh; i--) LUT[i]=255;

scale_factor = 255.0 / (highthresh-lowthresh); for(i=lowthresh; i<=highthresh; i++) LUT[i]=(unsigned char)((i - lowthresh) *

scale_factor);

/* transfer new image */ for(i=0; i<number_of_pixels; i++) source[i] = LUT[source[i]]; }

2.3.3 Intensity transformations

Digital negative Applications

Display of medical images Produce negative prints of images

Intensity level slicing Applications :

Segmentation of certain gray level regions

Intensity transformations Intensity transformation

Convert an old pixel into a new pixel based on some predefined function

Implemented with simple look-up tables Simple transformation

Null transform new pixel = old pixel

Image negative y = -x+255

Gamma correction function Brightness of an image can be adjusted with a

gamma correction transformation

Intensity transformations

Posterizing reduces the number

of gray levels in an images

Thresholding results when number of gray levels is reduced to 2.

A bounced threshold reduces the thresholding to a limited range and treats the other input pixels as null transformation

Figure 2.18(pp.63) Fig. 2.18 (a) 8-Level posterize transformation; (b) posterized image; (c) threshold transformation; (d) threshold image; (e) bounded threshold; (f) bounded threshold image.

Intensity transformations

Gamma correction

uv

Original gamma=0.45 gamma=2.20

Intensity Transformation Intensity Transformation

Intensity transformation is a point process that converts an old pixel into a new pixel base on some predefined function. This transformation is implemented with the LUT with ease.

Gamma Correction

Intensity Transformation

Intensity Transformation

Intensity Transformation

Intensity transformations

Page 60. 참조

Fig. 2.15 (a) Null transformation; (b) image; (c) negative transformation; (d) negative image.

Fig. 2.16 (a) Gamma collection transformation with gamma=0.45; (b) gamma collected image; (c) gamma collection transformation with gamma=2.2; (d) gamma collected image.

Intensity transformations

Page 62. 참조

Fig. 2.18 (a) 8-Level posterize transformation; (b) posterized image; (c) threshold transformation; (d) threshold image; (e) bounded threshold; (f) bounded threshold image.

Fig. 2.17 (a) Contrast stretch transformation; (b) contrast stretched image; (c) Contrast compression transformation; (d) contrast compressed image.

Intensity transformations

Page 64. 참조

Fig. 2.19 (a) 2-bit bit-clipping transformation; (b) resulting image.

Fig. 2.20 Bit clipped image contrast stretched.Fig. 2.21 (a) Iso-intensity contouring transformation; (b) contoured image.

Intensity tranformations

Page 65. 참조

Fig. 2.22 (a) Range-highlighting transformation; (b) resulting image.

Fig. 2.23 (a) Solarize transformation using a threshold of 150; (b) solarize image.

Fig. 2.24 (a) First parabola transformation; (b) transformed image; (c) second parabola transformation; (d) second transformed image.

HW – 03 a)

Plot กราฟ histogram

HW – 03 b)

Fourier Transform

MTCT DI&SP

2.4 Frequency-based Operations

Spatial Frequency

Efficient data representation Provides a means for modeling and

removing noise Physical processes are often best

described in “frequency domain” Provides a powerful means of image

analysis

What is spatial frequency?

Instead of describing a function (i.e., a shape) by a series of positions

It is described by a series of cosines Fourier series Fourier Transform

1-D Fourier Transform

MTCT DI&SP

Our starting place is the observation that a periodic function may be written as the sum of sines and cosines of varying amplitudes and frequencies.

it is possible to form any function as a summation of a series of sine and cosine terms of increasing frequency

For example, in figure we plot a function, and its decomposition into sine functions.

f(t)

We take the first three terms only (blue, green, red) to provide the approximation of the original function (purple).

The more terms of the series we take, the closer the sum will approach the original function.

(1)

where

(2)

k

tjkwekFtf 0)()(

dtetfT

kF tjkwT

T

02/

2/)(

1)(

Original function (purple) sines and cosines

Fourier coefficient

Equations 1 and 2 are called Fourier transform pairs, and they exist if f(t) is continuous and integrable, and F(k) is integrable. These conditions are usually satisfied in practice.

1

2

3

1

2

3

4

4

I

II

f(t) => time-domain

F(u) => frequency-domain

Any function can be represented in 2 formats: 1) time-domain representation, f(t), or

spatial domain, f(x), and 2) frequency-domain representationor

Fourier domain, F(u)

In other words, any space or time varying data can be transformed into a different

domain called the frequency space.

Time-domain Frequency-domain

FT properties:If F(u) and G(u) are FT of function f(t) and g(t), respectively,

Time scaling

Frequency scaling

)(1

)(a

uH

aatf

)()(1

auHa

tf

a

Time shifting

Frequency shifting

020 )()( utjeuHttf

)()( 02 0 uuHetf tuj

Convolution theorem

Correlation theorem

)()()()()()( uGuHdtgftgtf

dgtftgtfCorr )()())(),((

2-D Fourier Transform

MTCT DI&SP

แนวความค�ดของการแปลงฟ�เร�ยร�สามารถน�ามา ใช้�ก�บฟ�งก�ช้� นหร"อส�ญญาณ 2 ม�ติ� เช้&น ภาพ

ซึ่* งจะเป-นการแปลงฟ�งก�ช้� นบน spatial domain (ร�ปภาพ ) ไปเป-น frequency domain สมการคณ�ติศาสติร�แสดงความส�มพ�นธ์�น�1เป-นด�งน�1

dudvevuFyxf vyuxj )(2),(),(

dxdyeyxfvuF vyuxj )(2),(),(

FT

IFT

ภาพแสดงความส�มพ�นธ์�ระหว&างภาพในspatial domain และความถ� ในfrequency (or Fourier) domain

พบว&าระยะถ� - ห&างทางติ�าแหน&งในภาพ (x-y ในspatial domain) จะแปลงไปเป-นจ4ดในfrequency domain (u-v)

โดยบร�เวณท� ม�ระยะห&าง (ซึ่* งม�ความถ� ทางติ�าแหน&งติ� า ) เช้&น บร�เวณติ�วบ�านรวมท�1งหน�าติ&าง- ประติ� จะไป

อย�&ในติ�าแหน&งท� ใกล�จ4ดก�าเน�ด และในทางกล�บก�นบร�เวณท� ม�ระยะถ� (ซึ่* งม�ความถ�

ทางติ�าแหน&งส�ง ) เช้&น บร�เวณท� ม�ลวดลายบนหล�งคา บ�าน จะไปอย�&ในติ�าแหน&งท� ไกลจ4ดก�าเน�ดออกไป

ค4ณสมบ�ติ�ของการแปลงแบบฟ�เร�ยร�2 ม�ติ�(Properties of the 2-D Fourier Transform)

ค4ณสมบ�ติ�ของ Fourier Transform ของฟ�ง ก�ช้� น 2 ม�ติ�ท� ถ�กขยายมาจากในกรณ� 1 ม�ติ�ม�

ด�งน�1

การแปลงแบบฟาส�ทฟ�เร�ยร� (The Fast Fourier Transform)

ในกรณ�ท� ข�อม�ลเป-นปร�มาณเติ6มหน&วย(discrete) ด�งเช้&นภาพท� ถ�กน�าเข�าส�&ระบบคอมพ�วเติอร� การแปลงฟ�เร�ยร�ข�างติ�นย�งคง

ใช้�ได�อย&างสะดวกหล�งจากม�การปร�บปร4งแล�ว โดยสมการคณ�ติศาสติร�ของความส�มพ�นธ์�ค�&น�1จ*ง

เป-นแบบเติ6มหน&วย (Discrete Fourier Transform-DFT) เป-นด�งน�1

ส�าหร�บภาพท� ม�ขนาด NxM จะได�

)(21

0

1

0

),(),( vyuxjM

v

N

u

evuFyxf

)(21

0

1

0

),(1

),( vyuxjM

y

N

x

eyxfNM

vuF

เม" อติ�องการใช้�คอมพ�วเติอร�ประมวลผลการแปลง น�1 จ�าเป-นติ�องใช้�ข� 1นติอนว�ธ์� (algorith-m) ท�

รวดเร6วและม�ประส�ทธ์�ภาพ ด�งน�1นจ*งม�ผ��เสนอข�1น ติอนว�ธ์�ท� เร�ยกว&า (The Fast Fourier Transfo

rm-FFT ) และได�ร�บความน�ยมอย&างกว�างขวาง

Spatial FrequencyorHow I learned to love the Fourier Transform

Jean Baptiste Joseph Fourier

2.5 Group-based Operations

• Convolution Operation

MTCT DI&SP

• การกระทำ�าแบบคอนโวลู�ชั่��นเป็�นการหาค�าใหม่�ของจุ�ดภาพใด ๆ โดยพ$จุารณาระบบเพ&�อนบ'าน (Neighbors System) • ในข�(นแรกจุะต้'องก�าหนด window หร&อ kernel ซึ่+�งเป็�นต้ารางสี่-�เหลู-�ยม่จุต้�ร�สี่ขนาด 3x3, 5x5 หร&อขนาดอ&�น ๆ • แต้�ลูะชั่�องของต้ารางน-(จุะถู�กก�าหนดให'ม่-ค�าน�(าหน�ก (Weights) โดยแต้�ลูะชั่�องอาจุม่-ค�าเทำ�าก�นหร&อไม่�ก0ได' • จุากน�(นน�า kernel น-(ม่าทำาบบนภาพแลูะหาบวกของผลูค�ณระหว�างค�าน�(าหน�กก�บค�าความ่เข'ม่บนจุ�ดภาพ • แลู'วเลู&�อน kernel น-(เพ&�อไป็หาค�าใหม่�ของจุ�ดภาพถู�ดไป็

MTCT DI&SP

top related