ST_灰度 — 从源栅格和指定的表示红色、绿色和蓝色的波段创建一个新的 8 位无符号整数 (8BUI) 波段栅格
(1) raster ST_灰度(
raster rast, integer redband=1, integer greenband=2, integer blueband=3, text extenttype=INTERSECTION)
;
(2) raster ST_灰度(
rastbandarg[] rastbandargset, text extenttype=INTERSECTION)
;
给定三个输入波段(来自一个或多个栅格),创建一个具有一个 8BUI 波段的栅格。任何像素类型不是 8BUI 的输入波段都将使用 ST_Reclass 进行重分类。
此函数不像使用 |
可用性: 2.5.0
SET postgis.gdal_enabled_drivers = 'ENABLE_ALL'; SET postgis.enable_outdb_rasters = True; WITH apple AS ( SELECT ST_AddBand( ST_MakeEmptyRaster(350, 246, 0, 0, 1, -1, 0, 0, 0), '/tmp/apple.png'::text, NULL::int[] ) AS rast ) SELECT ST_AsPNG(rast) AS original_png, ST_AsPNG(ST_Grayscale(rast)) AS grayscale_png FROM apple;
|
|
SET postgis.gdal_enabled_drivers = 'ENABLE_ALL'; SET postgis.enable_outdb_rasters = True; WITH apple AS ( SELECT ST_AddBand( ST_MakeEmptyRaster(350, 246, 0, 0, 1, -1, 0, 0, 0), '/tmp/apple.png'::text, NULL::int[] ) AS rast ) SELECT ST_AsPNG(rast) AS original_png, ST_AsPNG(ST_Grayscale( ARRAY[ ROW(rast, 1)::rastbandarg, -- red ROW(rast, 2)::rastbandarg, -- green ROW(rast, 3)::rastbandarg, -- blue ]::rastbandarg[] )) AS grayscale_png FROM apple;