在 ArcGIS Pro 中,可以使用 Raster 函数来实现 Gamma Stretch 的禁用。具体代码示例如下:
import arcpy
from arcpy.sa import *
# 设置输入路径和文件名
input_raster = "C:/data/input.tif"
output_raster = "C:/data/output.tif"
# 打开 Gamma Stretch
arcpy.env.histogramEquilization = "Gamma Stretch"
# 打开临时影像放大模式以提高处理速度
arcpy.env.pyramids = "NONE"
arcpy.env.rasterStatistics = "NONE"
# 打开影像
in_raster = arcpy.sa.Raster(input_raster)
# 禁用 Gamma Stretch
gamma_disabled_raster = (in_raster ** (1/GammaStretch.gamma)) * GammaStretch.gamma
# 保存修改后的影像
gamma_disabled_raster.save(output_raster)
在这个示例代码中,我们首先设定了输入路径和输出路径。接着,我们设置了Gamma Stretch选项,这将允许我们使用Gamma Stretch变换算法。在这之后,我们打开了一个临时影像放大模式,以便加快处理速度。我们使用Raster函数来打开我们的输入影像,并通过将Gamma Stretch指数的倒数幂应用于影像中的每一个像元来禁用Gamma Stretch。最后,我们使用save函数来保存我们修改后的影像。