added back NDWI/NDVI and they're better, faster, stronger like Daft Punk

This commit is contained in:
RAD750 2025-04-02 12:09:07 +02:00
parent 97da24e43a
commit 7ee2e635be
6 changed files with 47 additions and 111 deletions

View file

@ -141,6 +141,7 @@
},
{
"name": "NDVI",
"expression": "cch1=(1, sun_angle_compensated_reflective_radiance, 0.000000, 46.203000);cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);lut=lut(lut/NDVI.png);lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 0),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 1),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
@ -148,6 +149,7 @@
},
{
"name": "NDWI",
"expression": "cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);cch3a=(3a, sun_angle_compensated_reflective_radiance, 0.000000, 5.416650);lut=lut(lut/NDWI.png);lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 0),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 1),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},

View file

@ -8,6 +8,22 @@
{
"name": "321",
"expression": "ch3, ch2, ch1"
},
{
"name": "NDVI",
"expression": "cch1=(3, sun_angle_compensated_reflective_radiance, 0.000000, 46.203000);cch2=(4, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);lut=lut(lut/NDVI.png);lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 0),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 1),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDVI.md"
},
{
"name": "NDWI",
"expression": "cch2=(4, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);cch3a=(7, sun_angle_compensated_reflective_radiance, 0.000000, 5.416650);lut=lut(lut/NDWI.png);lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 0),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 1),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDWI.md"
}
],
"default": {

View file

@ -311,7 +311,23 @@
"image": {
"geo_correct": true
}
}
},
{
"name": "NDVI",
"expression": "cch1=(1, sun_angle_compensated_reflective_radiance, 0.000000, 46.203000);cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);lut=lut(lut/NDVI.png);lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 0),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 1),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDVI.md"
},
{
"name": "NDWI",
"expression": "cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);cch3a=(3, sun_angle_compensated_reflective_radiance, 0.000000, 5.416650);lut=lut(lut/NDWI.png);lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 0),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 1),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDWI.md"
},
],
"default": {
"calibration_ranges": {

View file

@ -177,7 +177,19 @@
},
{
"name": "NDVI",
"expression": "cch1=(1, sun_angle_compensated_reflective_radiance, 0.000000, 46.203000);cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);lut=lut(lut/NDVI.png);lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 0),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 1),lut(0, ((cch2-cch1)/((cch2+cch1) == 0 ? 0.000001 : (cch1+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDVI.md"
},
{
"name": "NDWI",
"expression": "cch2=(2, sun_angle_compensated_reflective_radiance, 0.000000, 97.050700);cch3a=(3, sun_angle_compensated_reflective_radiance, 0.000000, 5.416650);lut=lut(lut/NDWI.png);lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 0),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 1),lut(0, 1-((cch2-cch3a)/((cch2+cch3a) == 0 ? 0.000001 : (cch3a+cch2))+1)/2, 2)",
"image": {
"geo_correct": true
},
"description": "descriptions/NDWI.md"
}
],
"default": {

View file

@ -1,56 +0,0 @@
-- NDVI
function init()
--create an empty image for the LUT
img_lut = image_t.new()
--load the LUT
image_load_png(img_lut, get_resource_path("lut/NDVI.png"))
--return 3 channels, RGB
return 3
end
function process()
for x = 0, rgb_output:width() - 1, 1 do
for y = 0, rgb_output:height() - 1, 1 do
--get channels from satdump.json
get_channel_values(x, y)
local cch1 = get_channel_value(0)
local cch2 = get_channel_value(1)
--perform NDVI
local ndvi = (cch2-cch1)/(cch2+cch1)
--range convert from -1 -> 1 to 0 -> 256
local ndvi_lutval = (((ndvi-(-1))*256) / (1-(-1)))
--sanity checks (noise)
if ndvi_lutval < 0 then
ndvi_lutval = 0
end
if ndvi_lutval > 255 then
ndvi_lutval = 255
end
--don't forget to create a table!
local lut_result = {}
--send the ndvi_lutval to the LUT, retrieve it back in the table as 3 R,G,B channels
lut_result[0] = img_lut:get(0 * img_lut:height() * img_lut:width() + ndvi_lutval * img_lut:width() + ndvi_lutval) / 255.0
lut_result[1] = img_lut:get(1 * img_lut:height() * img_lut:width() + ndvi_lutval * img_lut:width() + ndvi_lutval) / 255.0
lut_result[2] = img_lut:get(2 * img_lut:height() * img_lut:width() + ndvi_lutval * img_lut:width() + ndvi_lutval) / 255.0
--return RGB 0=R 1=G 2=B
set_img_out(0, x, y, lut_result[0])
set_img_out(1, x, y, lut_result[1])
set_img_out(2, x, y, lut_result[2])
end
--set the progress bar accordingly
set_progress(x, rgb_output:width())
end
end

View file

@ -1,54 +0,0 @@
-- NDWI
function init()
--create an empty image for the LUT
img_lut = image_t.new()
--load the LUT
image_load_png(img_lut, get_resource_path("lut/NDWI.png"), false)
--return 3 channels, RGB
return 3
end
function process()
for x = 0, rgb_output:width() - 1, 1 do
for y = 0, rgb_output:height() - 1, 1 do
--get channels from satdump.json
get_channel_values(x, y)
local cch2 = get_channel_value(0)
local cch3a = get_channel_value(1)
--perform NDWI
local ndwi = (cch2-cch3a)/(cch2+cch3a)
--range convert from -1 -> 1 to 0 -> 256
local ndwi_lutval = (((ndwi-(-1))*256) / (1-(-1)))
--sanity checks (noise)
if ndwi_lutval < 0 then
ndwi_lutval = 0
end
if ndwi_lutval > 255 then
ndwi_lutval = 255
end
--don't forget to create a table!
local lut_result = {}
--send the ndwi_lutval to the LUT, retrieve it back in the table as 3 R,G,B channels
lut_result[0] = img_lut:get(0 * img_lut:height() * img_lut:width() + ndwi_lutval * img_lut:width() + ndwi_lutval) / 255.0
lut_result[1] = img_lut:get(1 * img_lut:height() * img_lut:width() + ndwi_lutval * img_lut:width() + ndwi_lutval) / 255.0
lut_result[2] = img_lut:get(2 * img_lut:height() * img_lut:width() + ndwi_lutval * img_lut:width() + ndwi_lutval) / 255.0
--return RGB 0=R 1=G 2=B
set_img_out(0, x, y, lut_result[0])
set_img_out(1, x, y, lut_result[1])
set_img_out(2, x, y, lut_result[2])
end
--set the progress bar accordingly
set_progress(x, rgb_output:width())
end
end