簡體   English   中英

使用 Python 中的高斯濾波器重新采樣(增加像素大小)衛星圖像

[英]Resample (increase the pixel size) a satellite image using a Gaussian filter in Python

我有一個 15m 像素大小的衛星圖像(Landsat 8,全色波段)。 我的目標是使用 sigma = 0.5 的Gaussian filter在 460m 處放大圖像(即改變像素大小)。 python 中是否有python可以做到這一點(即,使用Gaussian filter增加像素大小)? 我沒有要展示的示例,因為我找不到如何在python中執行此操作。 是圖像。

檢查Pyresample它有resample_gauss

這個 function 允許您指定sigmaradius_of_influence和其他參數。

在您想要降低輸入圖像的分辨率的情況下,您只需要根據目標分辨率和區域范圍定義 output 的高度和寬度。

詳情請查看以上鏈接。

我嘗試了這段代碼,它似乎使用Gaussian filter來放大圖像。 我使用OSGeo4W Shell作為代碼。

from osgeo import gdal
from skimage.transform import resize


filepath ="some\\path" #This is the path to pan15.tif
dataset = gdal.Open(filepath + "\\pan15.tif", gdal.GDT_Float32) 
band = dataset.GetRasterBand(1)
array = band.ReadAsArray() #Getting the band, reading the image as array


ratio = 15/460 #This is necessary to calculate the desired image resolution. Previous pixel size divided by current.
newimg = resize(array, (int(array.shape[0]*ratio), int(array.shape[1]*ratio)), anti_aliasing_sigma=0.5) #If you wish to change the sigma then change the last parameter (0.5 currently).


#This section is to add the geographical coordinates back onto the image.
driver = gdal.GetDriverByName("GTiff")
out_ds = driver.Create(filepath + "\\pan17.tif", newimg.shape[1], newimg.shape[0], 1, gdal.GDT_Float32)
out_ds.SetProjection(dataset.GetProjection())
print(dataset.GetGeoTransform())
#out_ds.SetGeoTransform(dataset.GetGeoTransform())
out_ds.SetGeoTransform((582765.0, 460.0, 0.0, 1047405.0, 0.0, -460.0)) #This line does the same as the one commented out except I changed the 15m to 460m.
band = out_ds.GetRasterBand(1)
band.WriteArray(newimg)
band.FlushCache()
del out_ds

目前我不能接受任何正確答案,因為我仍在調查該主題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM