Link Search Menu Expand Document

Tutorial 11

Edge Detection/Enhancement

/*Load a Landsat 8 image and select only the panchromatic band.  
The panchromatic band includes reflectance in the 0.503–0.676 µm 
wavelength range with a ground sample distance of 15 m. */
var image = ee.Image('LANDSAT/LC08/C01/T1/LC08_015030_20140307').select("B8");

//Center map display on Syracuse with a zoom level of 12
Map.setCenter(-76.1467, 43.0458,12);  

//Display image as color infrared composite.
Map.addLayer(image, '', 'input image'); 

/* Perform Canny edge detection and display the result.  This function uses the threshold parameter to determine the minimum gradient magnitude; the sigma parameter is the standard deviation (SD) of a Gaussian pre-filter to remove high-frequency noise. A sigma of 0 means apply no filtering.*/
var canny = ee.Algorithms.CannyEdgeDetector({
  image: image, threshold: 200, sigma: 1 });

//Display the outcome of the canny edge detection.
Map.addLayer(canny, {}, 'canny');

// Perform a Hough transform of the Canny result. In this function gridSize means size of grid for analysis (default is 256), inputThreshold is the value threshold for the input image (pixels at or above this value are considered active) and lineThreshold is the threshold for line detection (values at or above this threshold on the Hough transform are considered detected lines). Each of these parameters can be determined experimentally. The defaults provided in GEE for the parameters are intended as a starting point for use with unsigned 8-bit integers.
var hough = ee.Algorithms.HoughTransform(canny, 256, 7000, 80);

//Display the outcome of the Hough transformed canny edge detection.
Map.addLayer(hough, {}, 'hough');

Pan Sharpening using HSV space

// Import a Landsat 8 top-of-atmosphere reflectance image 
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_015030_20140307');

//Display image as normal color composite.
Map.addLayer(image,{bands: ['B4', 'B3', 'B2']}, 'RGB image');

// Convert the visible bands from the input image to HSV color space.
var hsv = image.select(['B4', 'B3', 'B2']).rgbToHsv();

/* Create a new image by concatenating the hue and saturation bands (HSV image) with the panchromatic band from the original image and converting back to RGB. */

//Concatenate bands
var combined = ee.Image.cat([hsv.select('hue'), hsv.select('saturation'), image.select('B8')]);

//Convert back to RGB space
var sharpened = ee.Image(combined).hsvToRgb();

//Set the map display to center at City of Syracuse and a zoom level of 14
Map.setCenter(-76.14, 43.04,14);

// Display the pan-sharpened result.
Map.addLayer(sharpened,'','pan-sharpened');

Performing visual interpretation through texture analysis

//Import a high-resolution NAIP image.
var image = ee.Image('USDA/NAIP/DOQQ/m_4307663_se_18_1_20130619');

//Zoom map to Oakwood Cemetary at level 16 and display input image.
Map.setCenter(-76.13, 43.03,16);
//The catch with entropy is that it needs discrete values, hence the image is rescaled.
Map.addLayer(image, {max: 255}, 'Input image'); 

//Select NIR band from input image.
var nir = image.select('N');

//Define size and shape of neighborhood for deriving the texture information. 
var square = ee.Kernel.square({radius: 3});

//Compute entropy (texture) using the defined neighborhood information. 
var entropy = nir.entropy(square);

//Display computed image texture outcome.
Map.addLayer(entropy,{min: 1, max: 5, palette: ['0000CC', 'CC0000']}, 'entropy');