GISarabia.org
PostGIS › الدليل الرسمي › 11. مرجع الرستر › 11.12. معالجة الرستر: جبر الخرائط (Map Algebra)
PostGIS 3.6 · Official Manual · ترجمة عربية

ST_Grayscale

الصفحة الأصلية بالإنجليزية postgis.net ↗

الاسم

ST_Grayscale — تُنشئ رسترًا جديدًا بنطاق 8BUI واحد من الرستر المصدر والنطاقات المحددة التي تمثل الأحمر والأخضر والأزرق

المختصر

(1) raster ST_Grayscale(raster rast, integer redband=1, integer greenband=2, integer blueband=3, text extenttype=INTERSECTION);

(2) raster ST_Grayscale(rastbandarg[] rastbandargset, text extenttype=INTERSECTION);

الوصف

تُنشئ رسترًا بنطاق 8BUI واحد انطلاقًا من ثلاثة نطاقات مُدخلة (من رستر واحد أو أكثر). أي نطاق مُدخل لا يكون نوع بكسلاته 8BUI سيُعاد تصنيفه باستخدام ST_Reclass.

[ملاحظة]

لا تشبه هذه الدالة ST_ColorMap مع الكلمة المفتاحية grayscale، إذ تعمل ST_ColorMap على نطاق واحد فقط بينما تتوقع هذه الدالة ثلاثة نطاقات لـ RGB. تطبّق هذه الدالة المعادلة التالية لتحويل RGB إلى تدرّج رمادي: 0.2989 * RED + 0.5870 * GREEN + 0.1140 * BLUE

متاحة منذ: 2.5.0

أمثلة: الصيغة 1

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;
                    

original_png

grayscale_png

أمثلة: الصيغة 2

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;
                    

انظر أيضًا

ST_AsPNG, ST_Reclass, ST_ColorMap