I want to create an image collection where all the median images can get stored so that later on it can be exported to drive.
Link to my code: https://code.earthengine.google.com/4dc5685ed79044086587d811c4ee584f
//cloud mask along with function to add image as layer in the collection
function addImage(img)
{
var id = img.id;
var image = ee.Image(img.id);
Map.addLayer(image);
var cloudBitMask = ee.Number(2).pow(10).int();
var cirrusBitMask = ee.Number(2).pow(11).int();
var qa = image.select('QA60');
Map.addLayer(qa.bitwiseAnd(cloudBitMask).neq(0), {}, 'clouds');
Map.addLayer(qa.bitwiseAnd(cirrusBitMask).neq(0), {}, 'cirrus');
function maskS2clouds(image)
{
var qa = image.select('QA60');
var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask);
}
var cloudMasked = sentinel.filterBounds(agra).map(maskS2clouds);
var median = cloudMasked.median();
Map.addLayer(median
, {bands: ['B4', 'B3', 'B2'], max: 2000}, 'median');
print(median);
}