CLOUD DETECTION AND REMOVAL
TECHNIQUES FOR LANDSAT 8 IMAGERY
WITH GPU ACCELERATION 2016衛星影像處理理 / B10209047 / 倪鈵斯
INTRODUCTION
Abstract
此報告採⽤用之演算法主要是參參考「Cloud Detection and Removal
Techniques for Landsat 8 Imagery」(詳⾒見見「Previous Work」)中,
所介紹之雲層去除技巧,並使⽤用Nvidia CUDA平⾏行行運算框架實作之。

在報告中,學⽣生實作了了兩兩個版本: CPU計算以及GPU計算,⽤用以比較
兩兩者的效能差異異。
VS
Previous Work
http://wiki.theoutpost.io/files/remote-sensing/hallahan-prepperneau-
geo544-final-abstract.pdf
Previous Work
在前半段⽂文獻提到ACCA演算法。然⽽而,⽂文獻認為Landset-8的Quality
Assessment Bands尚未善⽤用Landset-8新增的頻帶,此外,也無法偵測雲
層所造成的陰影。

在此,它參參考了了⼀一個更更簡單的哲學: 針對⼤大量量的影像做排序,取出RGB數
值較暗的⼦子集合,再加以平均。
Previous Work
有別於直接使⽤用RGB數值,⽂文獻採⽤用Coastal Aerosol Band作為排序的
依據,因為此頻帶對雲層更更加敏感。
Band Number Name µm Resolution
1 Coastal / Aerosol 0.433–0.453 30 m
2 Visible Blue 0.450–0.515 30 m
3 Visible Green 0.525–0.600 30 m
4 Visible Red 0.630–0.680 30 m
5 Near Infrared 0.845–0.885 30 m
… … … …
Previous Work
此外,為了了避免雲層所造成的陰影被歸類為最暗的區域,⽂文獻中另外將
Coastal Aerosol Band增加⼀一個修正項。
CUDA
https://documen.tician.de/pycuda/array.html
CUDA
使⽤用CPU運算
(馮‧紐曼架構)
使⽤用GPU運算

(平⾏行行運算)
IMPLEMENT
Get the Target Image
band_a = rasterio.open(image_file_path.format(scene_id, 1))
band_g = rasterio.open(image_file_path.format(scene_id, 3))
x_min, x_max, y_min, y_max = (
354479.71320833557, 395642.8506635118, 2764434.5394466477, 2702420.0095054144
)
gt = band_a.get_transform()
x_min, x_max = floor((x_min - gt[0]) / gt[1]), ceil((x_max - gt[0]) / gt[1])
y_min, y_max = floor((y_min - gt[3]) / gt[5]), ceil((y_max - gt[3]) / gt[5])
band_a, band_g = (
gpuarray.to_gpu(
band_a.read(1, window=((y_min, y_max), (x_min, x_max))).astype(float)
),
gpuarray.to_gpu(
band_g.read(1, window=((y_min, y_max), (x_min, x_max))).astype(float)
)
) GPU
Correction
correct = ElementwiseKernel(
"double *band_a, double *band_g, double *result",
"result[i] = band_a[i] + ((1 / 4.0) * (band_a[i] - band_g[i]) / band_g[i])",
"correct"
)
correct(band_a, band_g, result)
GPU
result = band1 + (1 / 4.0) * (band1 - band3) / band1
CPU
Bubble Sort
cmp_swap = ElementwiseKernel(
"double *x, double *y, char *xx, char *yy",
'''
if(x[i] > y[i]) {
double tmp_d;
char tmp_u;
tmp_d = x[i]; x[i] = y[i]; y[i] = tmp_d;
tmp_u = xx[i]; xx[i] = yy[i]; yy[i] = tmp_u;
}
''',
“cmp_swap")
for j in range(len(images)-1, 0, -1):
for i in range(0, j):
cmp_swap(images[i], images[j], images_index[i], images_index[j])
GPUCPU times: user 1.42 s, sys: 460 ms, total: 1.88 s Wall time: 1.99 s
Bubble Sort
def cmp_swap(x, y, xx, yy):
shape_y, shape_x = x.shape
for i in range(shape_y):
for j in range(shape_x):
if x[i, j] > y[i, j]:
x[i, j] , y[i, j] = y[i, j], x[i, j]
for j in range(len(images)-1, 0, -1):
for i in range(0, j):
cmp_swap(images[i], images[j], images_index[i], images_index[j])
CPUSpend too much time. Details are as “Evaluation”
EVALUATION
Evaluation
程式主邏輯時間複雜度⼤大約為 ,m為混合影像數量量、n為影像⾼高度、k為影像長
度。根據此規則,完整排序相同⼤大⼩小的影像,GPU僅需花費1.99秒,⽽而CPU卻需要花5000秒。
秒
0
1250
2500
3750
5000
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85
CPU GPU
END
THANK YOU FOR YOUR ATTENTION

Landset 8 的雲層去除技巧實作