Skip to content

Commit 4ffdea5

Browse files
added magic eyes custom script
1 parent b4c674f commit 4ffdea5

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

sentinel-2/magic_eyes/img/liberec.jpg

1.05 MB
Loading

sentinel-2/magic_eyes/index.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
title: Magic Eyes
3+
parent: Sentinel-2
4+
layout: script
5+
nav_exclude: true
6+
examples:
7+
- zoom: '11'
8+
lat: '50.81917'
9+
lng: '15.07599'
10+
datasetId: S2L2A
11+
fromTime: '2025-03-08T00:00:00.000Z'
12+
toTime: '2025-03-08T23:59:59.999Z'
13+
platform:
14+
- CDSE
15+
- EOB
16+
evalscripturl: https://custom-scripts.sentinel-hub.com/sentinel-2/magic_eyes/script.js
17+
---
18+
19+
## General description of the script
20+
21+
This script is based on a band combination that is regularly used for visual interpretation of satellite imagery: NIR, SWIR and Red assigned to Red, Green and Blue respectively. The aim is to make areas that are different in reality also look different on the visualization, but not to create a scene that is close to true color. This is achieved by using three bands from rather different parts of the optical spectrum (NIR, SWIR and VIS), providing independent measurements of the spectral characteristics of each pixel. However, since Band 11 has a reduced resolution compared to Band 4 and Band 8, we have added a simple pansharpening effect.
22+
This was created by simulating a "panchromatic band", calculating the mean of Bands 2, 3, 4, and 8, and adding those values to Band 11. The intensity of this pansharpening can be modified using a simple weighting factor.
23+
Additionally, the brightness of the image can be adjusted with a simple gain factor.
24+
25+
## Description of representative images
26+
27+
This image shows the Polish-German-Czech triple border on 8 March 2025. Vegetation is bright red to orange and yellow depending on its greenness, deep red areas are coniferous forests. Snow is pink and ice is purple. Open water areas and fresh lava surfaces are black. Urban areas and roads are shown in various shades of grey. Active fires and other hot areas are bright neon green.
28+
29+
!['Sentinel-2 Magic Eye custom script image from 8 March 2025'](.\img\liberec.jpg)

sentinel-2/magic_eyes/script.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//VERSION=3
2+
//Combination of NIR, SWIR and visible Red band to create a visualization that aids visual interpretation of Land Cover from Sentinel-2 images. Based on a band combination used for creating CORINE Land Cover maps.
3+
//By András Zlinszky, Sinergise - with help from GitHub Copilot, based on code by Ottó Petrik from Lechner Institute, Hungary.
4+
//https://bsky.app/profile/azlinszky.bsky.social
5+
function setup() {
6+
return {
7+
input: ["B02","B03","B08","B11","B04", "dataMask"],
8+
output: { bands: 4 }
9+
};
10+
}
11+
12+
//this is the gain for the image. Increase for a brighter image. If you are using Sentinel-2 monthly mosaics, divide by 10000, eg the default value would be 0.00025
13+
const gain = 2.5
14+
//this is the weighting between the SWIR Band 11 and the panchromatic band. Increase it for more sharpness, decrease it to stay closer to B11 values
15+
const weighting = 0.25
16+
17+
function evaluatePixel(sample) {
18+
let pan = (sample.B02 + sample.B03 + sample.B04 + sample.B08) / 4;
19+
return [gain * sample.B08, (((1 - weighting) * gain) * sample.B11 + weighting * gain * pan), gain * sample.B04, sample.dataMask];
20+
}

sentinel-2/simple_panchromatic/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ examples:
2323

2424
## General description of the script
2525

26-
This script is for creating a simple panchromatic greyscale visualization from Sentinel-2. It simulates the way a panchromatic band works by taking the average of bands 2 (Red), 3 (Green), 4 (Blue), and 8 (wide-band near infrared). The suggested use is for backgrounds in a scene compare, or as an input for pansharpening of lower resolution bands. The script also works for quarterly cloudless mosaics.
26+
This script is for creating a simple panchromatic greyscale visualization from Sentinel-2. It simulates the way a panchromatic band works by taking the average of bands 2 (Red), 3 (Green), 4 (Blue), and 8 (wide-band near infrared). The suggested use is for backgrounds in a scene compare, or as an input for pansharpening of lower resolution bands. The script also works for quarterly cloudless mosaics. Using the "opacity" function in compare mode and a panchromatic Sentinel-2 cloudless mosaic as a background, you can make the interpretation of low-resolution datasets such as Sentinel-3 or Sentinel-5P imagery a lot easier.
2727

2828
## Description of representative images
2929

0 commit comments

Comments
 (0)