Skip to content

Commit 1bd7cd9

Browse files
Merge pull request #345 from azlinszkysinergise/sentinel2_magic_eyes
Sentinel2 magic eyes
2 parents 38fab8d + 4ffdea5 commit 1bd7cd9

File tree

8 files changed

+122
-0
lines changed

8 files changed

+122
-0
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/sentinel-2.md

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ Dedicated to supplying data for [Copernicus services](https://www.esa.int/Our_Ac
155155
- [Aesthetic Neon](/sentinel-2/aesthetic-neon) - Aesthetic visualization for urban and dry (desert) areas
156156
- [Total Ozone Column over Antarctica snow](/sentinel-2/ozone_column_over_snow)
157157
- [BRDF normalisation](/sentinel-2/brdf)
158+
- [Simple Panchromatic](/sentinel-2/simple_panchromatic) - Create a simple greyscale visualization by averaging the 10m true color and NIR bands
158159

159160
#### Scripts including machine learning techniques (eo-learn)
160161

426 KB
Loading
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: Sentinel-2 Simple Panchromatic
3+
parent: sentinel-2
4+
layout: script
5+
nav_exclude: true
6+
scripts:
7+
- - Sentinel-2
8+
- script.js
9+
- - Sentinel-2 Quarterly Cloudless Mosaics
10+
- script_mosaics.js
11+
examples:
12+
- zoom: '14'
13+
lat: '42.76703'
14+
lng: '36.823'
15+
datasetId: S2L2A
16+
fromTime: '2025-03-03T00:00:00.000Z'
17+
toTime: '2025-03-03T23:59:59.999Z'
18+
platform:
19+
- CDSE
20+
- EOB
21+
evalscripturl: https://custom-scripts.sentinel-hub.com/custom-scripts/sentinel-2\simple_panchromatic\script.js
22+
---
23+
24+
## General description of the script
25+
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.
27+
28+
## Description of representative images
29+
30+
This scene is a Sentinel-2 image of Nairobi, Kenya
31+
32+
!['Sentinel-2 simple panchromatic image of Nairobi, Kenya on 3 March 2025'](.\img\nairobi.jpg)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//VERSION=3
2+
//Simple Panchromatic visualization of Sentinel-2 data, using the mean of the band intensities for Red, Green, Blue and Near Infrared
3+
//By András Zlinszky, Sinergise - with help from GitHub Copilot
4+
//https://bsky.app/profile/azlinszky.bsky.social
5+
6+
function setup() {
7+
return {
8+
input: ["B01", "B02", "B03", "B08", "dataMask"],
9+
output: { bands: 4 }
10+
};
11+
}
12+
13+
const gain = 2.5;
14+
15+
function evaluatePixel(sample) {
16+
// Calculate the mean of the bands
17+
let pan = (sample.B01 + sample.B02 + sample.B03 + sample.B08) / 4;
18+
19+
return [gain * pan, gain * pan, gain * pan, sample.dataMask];
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//VERSION=3
2+
//Simple Panchromatic visualization of Sentinel-2 data, using the mean of the band intensities for Red, Green, Blue and Near Infrared
3+
//By András Zlinszky, Sinergise - with help from GitHub Copilot
4+
//https://bsky.app/profile/azlinszky.bsky.social
5+
6+
function setup() {
7+
return {
8+
input: ["B01", "B02", "B03", "B08", "dataMask"],
9+
output: { bands: 4 }
10+
};
11+
}
12+
13+
const gain = 0.00025;
14+
15+
function evaluatePixel(sample) {
16+
// Calculate the mean of the bands
17+
let pan = (sample.B01 + sample.B02 + sample.B03 + sample.B08) / 4;
18+
19+
return [gain * pan, gain * pan, gain * pan, sample.dataMask];
20+
}

0 commit comments

Comments
 (0)