I am working on Sentinel-1 images. I have created a mosaic and want to apply functions related to band mathematics on it.
//Define the time interval
var start_date = ee.Date('2021-11-15');
var end_date = start_date.advance(5,'days');
var date_filter = ee.Filter.date(start_date, end_date);
// Filter the collection for the VV product from the descending track
var collection1 = ee.ImageCollection('COPERNICUS/S1_GRD')
.filter(ee.Filter.eq('instrumentMode', 'IW'))
//.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))
.filterMetadata ('resolution_meters', 'equals', 10)
.filter(date_filter)
.filterBounds(roi)
// .select(['VV','angle']);
print(collection1);
var vis_paraVV = {bands:'VV', min:-25, max:5};
var vis_paraVH = {bands:'VH', min:-25, max:5};
var vis_paraAN = {bands:'angle', min:30.3, max:46.8};
Map.centerObject(roi, 6);
Map.addLayer(collection1,vis_paraVV,'VV');
//Map.addLayer(collection1,vis_paraVH,'VH');
Map.addLayer(collection1,vis_paraAN,'Angle');
////Mosaic
var Mo_VVVH1 = collection1.select(['VV','VH']).mosaic().clip(roi);
var Mo_Angl1 = collection1.select(['Angle']).mosaic().clip(roi);
// var VH_mosaic = collection1.select(['VH']).mosaic();
// var AN_mosaic = collection1.select(['angle']).mosaic();
//////Speckel Filter boxcar
var boxcar = ee.Kernel.square({ radius: 1.5, units: 'pixels', normalize: true});
////apply filter to VV and VH
var Mo_VVVH1 = Mo_VVVH1.convolve(boxcar);
///Subtraction
function addVHminusVV(image) {
var VHminusVV = ((image.select('VH')).subtract(image.select('VV'))).rename('Diff');
return image.addBands(VHminusVV);
}
function addVHbyVV(image) {
var VHbyVV = (image.select('VH')).divide(image.select('VV')).rename('Div');return image.addBands(VHbyVV);
}
If it's for image collection we can do following
var collection = collection1.map(addVHminusVV).map(addVHbyVV)
but how to do it for an image?