با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ماسک یک تصویر را می گیرد یا تنظیم می کند. تصویر خروجی ابرداده و ردپای تصویر ورودی را حفظ می کند. پیکسلهایی که ماسک از صفر به مقدار دیگری تغییر میکند، با صفر یا نزدیکترین مقادیر به صفر در محدوده نوع پیکسل پر میشوند.
استفاده
برمی گرداند
Image.mask ( mask )
تصویر
استدلال
تایپ کنید
جزئیات
این: image
تصویر
تصویر ورودی
mask
تصویر، پیش فرض: null
تصویر ماسک. اگر مشخص شده باشد، تصویر ورودی در خروجی کپی می شود اما با مقادیر این تصویر ماسک داده می شود. اگر این یک باند باشد، برای همه باندهای تصویر ورودی استفاده می شود. اگر مشخص نشده باشد، تصویری را که از ماسک تصویر ورودی ایجاد شده است، با مقیاس [0:1] (نامعتبر = 0، معتبر = 1.0) برمی گرداند.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eImage.mask()\u003c/code\u003e retrieves or sets an image's mask, impacting pixel values based on the mask's transitions.\u003c/p\u003e\n"],["\u003cp\u003eWhen retrieving a mask, \u003ccode\u003eImage.mask()\u003c/code\u003e returns a new image representing the mask, scaled to 0-1, where 0 is invalid and 1 is valid.\u003c/p\u003e\n"],["\u003cp\u003eWhen setting a mask, \u003ccode\u003eImage.mask()\u003c/code\u003e is deprecated in favor of \u003ccode\u003eImage.updateMask\u003c/code\u003e and \u003ccode\u003eImage.unmask\u003c/code\u003e for more controlled mask manipulation.\u003c/p\u003e\n"],["\u003cp\u003eThe output image retains the original image's metadata and footprint.\u003c/p\u003e\n"],["\u003cp\u003eMasks can be applied to individual bands or to the entire image.\u003c/p\u003e\n"]]],[],null,["# ee.Image.mask\n\nGets or sets an image's mask. The output image retains the metadata and footprint of the input image. Pixels where the mask changes from zero to another value will be filled with zeros, or the values closest to zero within the range of the pixel type.\n\n\u003cbr /\u003e\n\n| **Note:** the version that sets a mask will be deprecated. To set a mask from an image on previously unmasked pixels, use Image.updateMask. To unmask previously masked pixels, use Image.unmask.\n\n| Usage | Returns |\n|------------------------|---------|\n| Image.mask`(`*mask*`)` | Image |\n\n| Argument | Type | Details |\n|---------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `image` | Image | The input image. |\n| `mask` | Image, default: null | The mask image. If specified, the input image is copied to the output but given the mask by the values of this image. If this is a single band, it is used for all bands in the input image. If not specified, returns an image created from the mask of the input image, scaled to the range \\[0:1\\] (invalid = 0, valid = 1.0). |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// A Sentinel-2 surface reflectance image.\nvar img = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');\nvar trueColorViz = {\n bands: ['B4', 'B3', 'B2'],\n min: 0,\n max: 2700,\n gamma: 1.3\n};\nprint('Sentinel-2 image', img);\nMap.setCenter(-122.36, 37.47, 10);\nMap.addLayer(img, trueColorViz, 'Sentinel-2 image');\n\n// Get masks for all image bands; each band has an independent mask.\n// Valid pixels are value 1, invalid are 0.\nvar multiBandMaskImg = img.mask();\nprint('Multi-band mask image', multiBandMaskImg);\nMap.addLayer(multiBandMaskImg, null, 'Multi-band mask image');\n\n// Get the mask for a single image band.\nvar singleBandMaskImg = img.select('B1').mask();\nprint('Single-band mask image', singleBandMaskImg);\nMap.addLayer(singleBandMaskImg, null, 'Single-band mask image');\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# A Sentinel-2 surface reflectance image.\nimg = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG')\ntrue_color_viz = {\n 'bands': ['B4', 'B3', 'B2'],\n 'min': 0,\n 'max': 2700,\n 'gamma': 1.3,\n}\ndisplay('Sentinel-2 image', img)\nm = geemap.Map()\nm.set_center(-122.36, 37.47, 10)\nm.add_layer(img, true_color_viz, 'Sentinel-2 image')\n\n# Get masks for all image bands each band has an independent mask.\n# Valid pixels are value 1, invalid are 0.\nmulti_band_mask_img = img.mask()\ndisplay('Multi-band mask image', multi_band_mask_img)\nm.add_layer(multi_band_mask_img, None, 'Multi-band mask image')\n\n# Get the mask for a single image band.\nsingle_band_mask_img = img.select('B1').mask()\ndisplay('Single-band mask image', single_band_mask_img)\nm.add_layer(single_band_mask_img, None, 'Single-band mask image')\nm\n```"]]