Thông báo: Tất cả dự án phi thương mại đã đăng ký sử dụng Earth Engine trước ngày 15 tháng 4 năm 2025 phải xác minh điều kiện sử dụng phi thương mại để duy trì quyền truy cập vào Earth Engine.
Có một số phương thức biến đổi phổ trong Earth Engine. Các phương thức này bao gồm các phương thức thực thể trên hình ảnh như normalizedDifference(), unmix(), rgbToHsv() và hsvToRgb().
Làm sắc nét theo chiều dọc
Tính năng làm sắc nét toàn cảnh cải thiện độ phân giải của hình ảnh đa băng thông thông qua tính năng nâng cao do hình ảnh toàn sắc tương ứng có độ phân giải tốt hơn cung cấp.
Phương thức rgbToHsv() và hsvToRgb() hữu ích cho việc làm sắc nét khi kéo.
Tính năng phân tách phổ được triển khai trong Earth Engine dưới dạng phương thức image.unmix().
(Để biết các phương thức linh hoạt hơn, hãy xem trang Chuyển đổi mảng). Sau đây là ví dụ về việc tách riêng Landsat 5 với các thành phần cuối là đô thị, thực vật và nước được xác định trước:
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[[["\u003cp\u003eEarth Engine provides spectral transformation methods like \u003ccode\u003enormalizedDifference()\u003c/code\u003e, \u003ccode\u003eunmix()\u003c/code\u003e, \u003ccode\u003ergbToHsv()\u003c/code\u003e, and \u003ccode\u003ehsvToRgb()\u003c/code\u003e for image manipulation.\u003c/p\u003e\n"],["\u003cp\u003ePan sharpening enhances image resolution by integrating a panchromatic band, often achieved using \u003ccode\u003ergbToHsv()\u003c/code\u003e and \u003ccode\u003ehsvToRgb()\u003c/code\u003e for color space conversion.\u003c/p\u003e\n"],["\u003cp\u003eSpectral unmixing, facilitated by \u003ccode\u003eimage.unmix()\u003c/code\u003e, decomposes image pixels into fractions of predetermined spectral endmembers (e.g., urban, vegetation, water).\u003c/p\u003e\n"],["\u003cp\u003eCode examples demonstrate pan-sharpening with Landsat 8 and spectral unmixing with Landsat 5 using both JavaScript and Python APIs in Earth Engine.\u003c/p\u003e\n"]]],[],null,["# Spectral transformations\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|\n| [Run in Google Colab](https://colab.research.google.com/github/google/earthengine-community/blob/master/guides/linked/generated/image_transforms.ipynb) | [View source on GitHub](https://github.com/google/earthengine-community/blob/master/guides/linked/generated/image_transforms.ipynb) |\n\nThere are several spectral transformation methods in Earth Engine. These include instance\nmethods on images such as `normalizedDifference()`, `unmix()`,\n`rgbToHsv()` and `hsvToRgb()`.\n\nPan sharpening\n--------------\n\nPan sharpening improves the resolution of a multiband image through\nenhancement provided by a corresponding panchromatic image with finer resolution.\nThe `rgbToHsv()` and `hsvToRgb()` methods are useful for pan\nsharpening.\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 top-of-atmosphere reflectance image.\nvar image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');\nMap.addLayer(\n image,\n {bands: ['B4', 'B3', 'B2'], min: 0, max: 0.25, gamma: [1.1, 1.1, 1]},\n 'rgb');\n\n// Convert the RGB bands to the HSV color space.\nvar hsv = image.select(['B4', 'B3', 'B2']).rgbToHsv();\n\n// Swap in the panchromatic band and convert back to RGB.\nvar sharpened = ee.Image.cat([\n hsv.select('hue'), hsv.select('saturation'), image.select('B8')\n]).hsvToRgb();\n\n// Display the pan-sharpened result.\nMap.setCenter(-122.44829, 37.76664, 13);\nMap.addLayer(sharpened,\n {min: 0, max: 0.25, gamma: [1.3, 1.3, 1.3]},\n 'pan-sharpened');\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# Load a Landsat 8 top-of-atmosphere reflectance image.\nimage = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')\n\n# Convert the RGB bands to the HSV color space.\nhsv = image.select(['B4', 'B3', 'B2']).rgbToHsv()\n\n# Swap in the panchromatic band and convert back to RGB.\nsharpened = ee.Image.cat(\n [hsv.select('hue'), hsv.select('saturation'), image.select('B8')]\n).hsvToRgb()\n\n# Define a map centered on San Francisco, California.\nmap_sharpened = geemap.Map(center=[37.76664, -122.44829], zoom=13)\n\n# Add the image layers to the map and display it.\nmap_sharpened.add_layer(\n image,\n {\n 'bands': ['B4', 'B3', 'B2'],\n 'min': 0,\n 'max': 0.25,\n 'gamma': [1.1, 1.1, 1],\n },\n 'rgb',\n)\nmap_sharpened.add_layer(\n sharpened,\n {'min': 0, 'max': 0.25, 'gamma': [1.3, 1.3, 1.3]},\n 'pan-sharpened',\n)\ndisplay(map_sharpened)\n```\n\nSpectral unmixing\n-----------------\n\nSpectral unmixing is implemented in Earth Engine as the `image.unmix()` method.\n(For more flexible methods, see the [Array Transformations\npage](/earth-engine/guides/arrays_transformations)). The following is an example of unmixing Landsat 5 with predetermined urban,\nvegetation and water endmembers:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 5 image and select the bands we want to unmix.\nvar bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7'];\nvar image = ee.Image('LANDSAT/LT05/C02/T1/LT05_044034_20080214')\n .select(bands);\nMap.setCenter(-122.1899, 37.5010, 10); // San Francisco Bay\nMap.addLayer(image, {bands: ['B4', 'B3', 'B2'], min: 0, max: 128}, 'image');\n\n// Define spectral endmembers.\nvar urban = [88, 42, 48, 38, 86, 115, 59];\nvar veg = [50, 21, 20, 35, 50, 110, 23];\nvar water = [51, 20, 14, 9, 7, 116, 4];\n\n// Unmix the image.\nvar fractions = image.unmix([urban, veg, water]);\nMap.addLayer(fractions, {}, 'unmixed');\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# Load a Landsat 5 image and select the bands we want to unmix.\nbands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7']\nimage = ee.Image('LANDSAT/LT05/C02/T1/LT05_044034_20080214').select(bands)\n\n# Define spectral endmembers.\nurban = [88, 42, 48, 38, 86, 115, 59]\nveg = [50, 21, 20, 35, 50, 110, 23]\nwater = [51, 20, 14, 9, 7, 116, 4]\n\n# Unmix the image.\nfractions = image.unmix([urban, veg, water])\n\n# Define a map centered on San Francisco Bay.\nmap_fractions = geemap.Map(center=[37.5010, -122.1899], zoom=10)\n\n# Add the image layers to the map and display it.\nmap_fractions.add_layer(\n image, {'bands': ['B4', 'B3', 'B2'], 'min': 0, 'max': 128}, 'image'\n)\nmap_fractions.add_layer(fractions, None, 'unmixed')\ndisplay(map_fractions)\n```\nFigure 1. Landsat 5 imagery unmixed to urban (red), vegetation (green) and water (blue) fractions. San Francisco bay area, California, USA."]]