2.3.2 Contrast Stretching
-
Upload
florence-holder -
Category
Documents
-
view
168 -
download
17
description
Transcript of 2.3.2 Contrast Stretching
![Page 1: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/1.jpg)
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.
![Page 2: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/2.jpg)
Contrast Stretching Contrast stretching
Clipping
thresholding
Lubvbu
buavau
auu
v
LvLuufv
b
a
)(
)(
0,
],0[],,0[)(
0 ],[ bautba
![Page 3: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/3.jpg)
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
![Page 4: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/4.jpg)
Contrast Stretching
Original Image
Original Image
Basic Contrast Stretching
End-in Search
![Page 5: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/5.jpg)
Original Image Convert ImageContrast Stretching
![Page 6: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/6.jpg)
Red Green Blue
![Page 7: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/7.jpg)
/******************************************** * 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 */
![Page 8: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/8.jpg)
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]]++;
![Page 9: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/9.jpg)
/* 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; }
![Page 10: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/10.jpg)
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;
![Page 11: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/11.jpg)
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]]; }
![Page 12: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/12.jpg)
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
![Page 13: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/13.jpg)
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
![Page 14: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/14.jpg)
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.
![Page 15: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/15.jpg)
Intensity transformations
Gamma correction
uv
Original gamma=0.45 gamma=2.20
![Page 16: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/16.jpg)
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
![Page 17: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/17.jpg)
Intensity Transformation
![Page 18: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/18.jpg)
Intensity Transformation
![Page 19: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/19.jpg)
Intensity Transformation
![Page 20: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/20.jpg)
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.
![Page 21: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/21.jpg)
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.
![Page 22: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/22.jpg)
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.
![Page 23: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/23.jpg)
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.
![Page 24: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/24.jpg)
Fig. 2.24 (a) First parabola transformation; (b) transformed image; (c) second parabola transformation; (d) second transformed image.
![Page 25: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/25.jpg)
HW – 03 a)
Plot กราฟ histogram
![Page 26: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/26.jpg)
HW – 03 b)
![Page 27: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/27.jpg)
Fourier Transform
MTCT DI&SP
2.4 Frequency-based Operations
![Page 28: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/28.jpg)
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
![Page 29: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/29.jpg)
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
![Page 30: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/30.jpg)
1-D Fourier Transform
MTCT DI&SP
![Page 31: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/31.jpg)
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.
![Page 32: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/32.jpg)
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.
![Page 33: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/33.jpg)
f(t)
![Page 34: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/34.jpg)
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.
![Page 35: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/35.jpg)
(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.
![Page 36: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/36.jpg)
1
2
3
1
2
3
4
4
I
II
f(t) => time-domain
F(u) => frequency-domain
![Page 37: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/37.jpg)
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.
![Page 38: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/38.jpg)
Time-domain Frequency-domain
![Page 39: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/39.jpg)
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
![Page 40: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/40.jpg)
Time shifting
Frequency shifting
020 )()( utjeuHttf
)()( 02 0 uuHetf tuj
![Page 41: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/41.jpg)
Convolution theorem
Correlation theorem
)()()()()()( uGuHdtgftgtf
dgtftgtfCorr )()())(),((
![Page 42: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/42.jpg)
2-D Fourier Transform
MTCT DI&SP
![Page 43: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/43.jpg)
แนวความค�ดของการแปลงฟ�เร�ยร�สามารถน�ามา ใช้�ก�บฟ�งก�ช้� นหร"อส�ญญาณ 2 ม�ติ� เช้&น ภาพ
ซึ่* งจะเป-นการแปลงฟ�งก�ช้� นบน spatial domain (ร�ปภาพ ) ไปเป-น frequency domain สมการคณ�ติศาสติร�แสดงความส�มพ�นธ์�น�1เป-นด�งน�1
dudvevuFyxf vyuxj )(2),(),(
dxdyeyxfvuF vyuxj )(2),(),(
FT
IFT
![Page 44: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/44.jpg)
ภาพแสดงความส�มพ�นธ์�ระหว&างภาพในspatial domain และความถ� ในfrequency (or Fourier) domain
![Page 45: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/45.jpg)
พบว&าระยะถ� - ห&างทางติ�าแหน&งในภาพ (x-y ในspatial domain) จะแปลงไปเป-นจ4ดในfrequency domain (u-v)
โดยบร�เวณท� ม�ระยะห&าง (ซึ่* งม�ความถ� ทางติ�าแหน&งติ� า ) เช้&น บร�เวณติ�วบ�านรวมท�1งหน�าติ&าง- ประติ� จะไป
อย�&ในติ�าแหน&งท� ใกล�จ4ดก�าเน�ด และในทางกล�บก�นบร�เวณท� ม�ระยะถ� (ซึ่* งม�ความถ�
ทางติ�าแหน&งส�ง ) เช้&น บร�เวณท� ม�ลวดลายบนหล�งคา บ�าน จะไปอย�&ในติ�าแหน&งท� ไกลจ4ดก�าเน�ดออกไป
![Page 46: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/46.jpg)
![Page 47: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/47.jpg)
![Page 48: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/48.jpg)
![Page 49: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/49.jpg)
![Page 50: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/50.jpg)
![Page 51: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/51.jpg)
![Page 52: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/52.jpg)
ค4ณสมบ�ติ�ของการแปลงแบบฟ�เร�ยร�2 ม�ติ�(Properties of the 2-D Fourier Transform)
ค4ณสมบ�ติ�ของ Fourier Transform ของฟ�ง ก�ช้� น 2 ม�ติ�ท� ถ�กขยายมาจากในกรณ� 1 ม�ติ�ม�
ด�งน�1
![Page 53: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/53.jpg)
![Page 54: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/54.jpg)
การแปลงแบบฟาส�ทฟ�เร�ยร� (The Fast Fourier Transform)
ในกรณ�ท� ข�อม�ลเป-นปร�มาณเติ6มหน&วย(discrete) ด�งเช้&นภาพท� ถ�กน�าเข�าส�&ระบบคอมพ�วเติอร� การแปลงฟ�เร�ยร�ข�างติ�นย�งคง
ใช้�ได�อย&างสะดวกหล�งจากม�การปร�บปร4งแล�ว โดยสมการคณ�ติศาสติร�ของความส�มพ�นธ์�ค�&น�1จ*ง
เป-นแบบเติ6มหน&วย (Discrete Fourier Transform-DFT) เป-นด�งน�1
![Page 55: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/55.jpg)
ส�าหร�บภาพท� ม�ขนาด NxM จะได�
)(21
0
1
0
),(),( vyuxjM
v
N
u
evuFyxf
)(21
0
1
0
),(1
),( vyuxjM
y
N
x
eyxfNM
vuF
![Page 56: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/56.jpg)
เม" อติ�องการใช้�คอมพ�วเติอร�ประมวลผลการแปลง น�1 จ�าเป-นติ�องใช้�ข� 1นติอนว�ธ์� (algorith-m) ท�
รวดเร6วและม�ประส�ทธ์�ภาพ ด�งน�1นจ*งม�ผ��เสนอข�1น ติอนว�ธ์�ท� เร�ยกว&า (The Fast Fourier Transfo
rm-FFT ) และได�ร�บความน�ยมอย&างกว�างขวาง
![Page 57: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/57.jpg)
Spatial FrequencyorHow I learned to love the Fourier Transform
Jean Baptiste Joseph Fourier
![Page 58: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/58.jpg)
2.5 Group-based Operations
• Convolution Operation
MTCT DI&SP
![Page 59: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/59.jpg)
• การกระทำ�าแบบคอนโวลู�ชั่��นเป็�นการหาค�าใหม่�ของจุ�ดภาพใด ๆ โดยพ$จุารณาระบบเพ&�อนบ'าน (Neighbors System) • ในข�(นแรกจุะต้'องก�าหนด window หร&อ kernel ซึ่+�งเป็�นต้ารางสี่-�เหลู-�ยม่จุต้�ร�สี่ขนาด 3x3, 5x5 หร&อขนาดอ&�น ๆ • แต้�ลูะชั่�องของต้ารางน-(จุะถู�กก�าหนดให'ม่-ค�าน�(าหน�ก (Weights) โดยแต้�ลูะชั่�องอาจุม่-ค�าเทำ�าก�นหร&อไม่�ก0ได' • จุากน�(นน�า kernel น-(ม่าทำาบบนภาพแลูะหาบวกของผลูค�ณระหว�างค�าน�(าหน�กก�บค�าความ่เข'ม่บนจุ�ดภาพ • แลู'วเลู&�อน kernel น-(เพ&�อไป็หาค�าใหม่�ของจุ�ดภาพถู�ดไป็
MTCT DI&SP
![Page 60: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/60.jpg)
![Page 61: 2.3.2 Contrast Stretching](https://reader031.fdocuments.us/reader031/viewer/2022020710/56812ac5550346895d8e98a0/html5/thumbnails/61.jpg)