diff --git a/resources/lut/NDVI.png b/resources/lut/NDVI.png new file mode 100644 index 000000000..9be0e2bdc Binary files /dev/null and b/resources/lut/NDVI.png differ diff --git a/resources/scripted_compos/amsu_tpw.lua b/resources/scripted_compos/amsu_tpw.lua new file mode 100644 index 000000000..4a306c1a1 --- /dev/null +++ b/resources/scripted_compos/amsu_tpw.lua @@ -0,0 +1,28 @@ + + +function init() + return 1 -- Number of channels to output +end + +function process() + local d1 = 0.754 + local d2 = -2.265 + local adj = 0.003 + + for x = 0, rgb_output:width() - 1, 1 do + for y = 0, rgb_output:height() - 1, 1 do + local ch23_8 = get_calibrated_value(0, x, y, true) + local ch31_4 = get_calibrated_value(1, x, y, true) + local centerPixel = x - rgb_output:width() / 2 + local theta = (centerPixel / rgb_output:width() * 98) * math.pi / 180 + local d0 = 8.24 - 2.622*math.cos(theta) + 1.846 * (math.cos(theta))^2 + + local result = math.cos(theta)*(d0+d1*math.log(285 - ch23_8)+c2*math.log(285-ch31_4))+c3 + local output = result / 300 + set_img_out(0, x, y, output) + end + + set_progress(x, rgb_output:width()) + end +end + diff --git a/resources/scripted_compos/ndvi.lua b/resources/scripted_compos/ndvi.lua new file mode 100644 index 000000000..9af591bad --- /dev/null +++ b/resources/scripted_compos/ndvi.lua @@ -0,0 +1,31 @@ +-- NDVI + +function init() + img_lut = image8.new() + img_lut:load_png(get_resource_path("lut/NDVI.png")) + return 3 +end + +function process() + for x = 0, rgb_output:width() - 1, 1 do + for y = 0, rgb_output:height() - 1, 1 do + local cch2 = get_calibrated_value(0, x, y, true) + local cch1 = get_calibrated_value(1, x, y, true) + + + + local ndvi = (cch2-cch1)/(cch2+cch1) + + local ndvi_lutval = ((ndvi-(-1))*256)/(1-(-1))+0 + + local lut_result[0] = img_lut:get(0 * img_lut:height() * img_lut:width() + ndvi_lutval) / 255.0 + local lut_result[1] = img_lut:get(1 * img_lut:height() * img_lut:width() + ndvi_lutval) / 255.0 + local lut_result[2] = img_lut:get(2 * img_lut:height() * img_lut:width() + ndvi_lutval) / 255.0 + + for c = 0, 2, 1 do + set_img_out(c, x, y, lut_result[c]) + end + end + set_progress(x, rgb_output:width()) + end +end