I used a set of LS8 TOA images to produce a quality mosaic based on NDVI values. I wonder if there is a way do figure out a source / origin image ID for each pixel of the result mosaic. I guess it should be some kind of a thematic raster of the same resolution.
Source code I used to produce mosaic is attached below.
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA');
// Get the least cloudy image in 2015.
var image = ee.Image(
l8.filterBounds(ee.Geometry.Point(-122.2929, 37.8206))
.filterDate('2015-01-01', '2015-12-31')
.sort('CLOUD_COVER')
.first()
);
Map.setCenter(-122.2929, 37.8206, 10)
// Compute the Normalized Difference Vegetation Index (NDVI).
var nir = image.select('B5');
var red = image.select('B4');
var ndvi = nir.subtract(red).divide(nir.add(red)).rename('NDVI');
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
var addNDVI = function(image) {
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
return image.addBands(ndvi);
};
var withNDVI = l8.map(addNDVI);
// Make a "greenest" pixel composite.
var greenest = withNDVI.qualityMosaic('NDVI');
// Display the result.
var visParams = {bands: ['B4', 'B3', 'B2'], max: 0.3};
Map.addLayer(greenest, visParams, 'Greenest pixel composite');