Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# EdgeFill.sml
#
# Script designed to fill only a few pixels into gaps in a filtered DEM.
#
# Method:
# -------
#
# Where cells are not NULL input Raster value is retained. Where input
# Raster is NULL and there are Non-NULL cells nearby the median of the
# Non-Null cells used. The window size is determined by the number of
# pixels that the user wants to fill in.
#
# Assumes null value is set for raster.
#
# Terranean Mapping Technologies, Brisbane, Australia:
# 12/5/2009
#####################################################################
clear();
class RVC_RASTER OutputDEM, InputDEM;
numeric numpixels, windowSize, row, col;
#Get input DEM with Null values
GetInputRaster(InputDEM);
string rvc$ = GetObjectFileName(InputDEM);
string name$ = GetObjectName(rvc$,GetObjectNumber(InputDEM));
numeric nullValue = NullValue(InputDEM);
#Create output DEM
string desc$ = "Edgefill "+ NumToStr(numpixels) + "px"+InputDEM.$Info.Desc;
CreateRaster(OutputDEM,rvc$,name$+"_edgefill",desc$,NumLins(InputDEM),NumCols(InputDEM),"32-bit float");
CopySubobjects(InputDEM, OutputDEM, "georef");
#Get number of pixels to fill in
numpixels = PopupNum("Number of pixels to fill", 1, 1, 10, 0);
windowSize = (numpixels*2)+1;
#Replace null cells with median value of nearby non-null cells
for each OutputDEM[row, col]{
if(IsNull(InputDEM))
OutputDEM = FocalMedian(InputDEM, windowSize, windowSize, row, col);
else
OutputDEM = InputDEM;
}
#Clean up.
SetNull(OutputDEM,0);
CreateHistogram(OutputDEM);
CreatePyramid(OutputDEM);