我知道如何使用GDAL translate命令行工具来缩放并保存为JPG格式:
gdal_translate image.bsq image.jpg -of JPEG -outsize 10% 10% -scale
这将生成一个“好看”的图片:
我想通过Python生成类似的图片,像这样:
from osgeo import gdal
img_bsq = 'image.bsq'
img_jpg = 'image.jpg'
gdal.Translate(img_jpg, img_bsq, format='JPEG', width=1024, height=0, scaleParams=[[500,1000,10,20]])
我认为问题在于如何正确选择scaleParams
。根据man gdal_translate
的说明,cmd行中的-scale
会自动计算值:
-scale [src_min src_max [dst_min dst_max]]:
Rescale the input pixels values from the range src_min to src_max to the range dst_min to dst_max. If omitted the output range is 0
to 255. If omitted the input range is automatically computed from the source data.
有没有关于如何选择scaleParams
(或其他相关选项)的提示?
scaleParams=[[]]
来进行自动化处理。 - KcFnMi