I am new in Earth Engine. Here is an image collection [img1,img2,img3,img4,img5]. I want to get List or image collection [img1+img2 , img2+img3, img3+img4, img4+img5]. I tried to complete the following code https://code.earthengine.google.com/1256826da91886b9242f29f20339d604 But the result is incorrect, I don't know where the error is. I try not to use for loops because I will have a lot of data to calculate.
var img1 = ee.Image(1);//3
var img2 = ee.Image(2);//5
var img3 = ee.Image(3);//7
var img4 = ee.Image(4);//9
var img5 = ee.Image(5);
var image=ee.ImageCollection([img1,img2,img3,img4,img5]);
var list = image.toList(image.size());
var newList = list.slice(1);
print(list.size());
newList = newList.map(function(data) {
data = ee.Image(data);
var l = data.add(ee.Image(list.get(list.size().subtract(1))));
return l;
})
print(newList)