Friday, May 22, 2009

Fill Holes and Slivers in Imagery (Table of Values)

Here is a graphic Spatial Model (PaulBeaty_HoleFiller_Table.gmd) I created when I was at Georgia Tech. It fills DEM and other raster data (including imagery) holes and slivers with data calculated values from surrounding pixel values. These 1, 2 and sometimes 3 pixel wide artifacts are common to users who have reprojected butt-matched raster data. This model finds the "to-be-replaced" values from a table of values and determines whether a 3 x 3 or 5 x 5 focal mean should be applied. The model ignores the replacement values when calculating the focal mean.

Copy and paste the text below into a text editor and save as ANSI text file without the text editor's formatting. Save as PaulBeaty_HoleFiller_Table.gmd and open in Model Maker.


PAGESIZE 6.04444, 8.73889 INCHES;
CELLSIZE MINIMUM;
PRINTERPAGESIZE 8.5, 11;
MARGINS 0.5, 0.5, 0.5, 0.5;
ORIENTATION PORTRAIT;
PRINTSCALE 100;
WINDOW INTERSECTION;
PROJECTION DEFAULT;
AOI NONE;
OPTIMIZE YES;
RASTER {
ID 1;
TITLE "n1_PROMPT_USER";
POSITION 0.855556, 1.4;
PROMPT;
IGNORE 0;
INTERPOLATION NEAREST;
ATHEMATIC;
DATATYPE UNSIGNED16;
DECLARE "Integer";
COMPRESSION UNCOMPRESSED;
COORDINATES MAP;
AREA RECT 26, -2.079167 : 26.628333, -5.184167;
AOI NONE;
RECODE NO;
CHILD 2;
}
FUNCTION {
ID 2;
TITLE "EITHER";
POSITION 2.18889, 3.21111;
VALUE "EITHER (FOCAL MEAN ( $n1_PROMPT_USER , $n6_Low_Pass , IGNORE_VALUE $n28_Custom_Integer , APPLY_AT_VALUE $n28_Custom_Integer ) ) IF ( (FOCAL MAJORITY ( $n1_PROMPT_USER , $n3_Low_Pass ) == $n28_Custom_Integer) ) OR (FOCAL MEAN ( $n1_PROMPT_USER , $n3_Low_Pass , IGNORE_VALUE $n28_Custom_Integer , APPLY_AT_VALUE $n28_Custom_Integer ) ) OTHERWISE";
AREA UNION;
CHILD 4;
}
MATRIX {
ID 3;
TITLE "n3_Low_Pass";
POSITION 3.42222, 5.36667;
SIZE 3, 3;
DATATYPE SIGNED32;
BUILTIN LOWPASS;
VALUE 1, 1, 1,
1, 1, 1,
1, 1, 1;
NORMALIZE NO;
CHILD 2;
}
RASTER {
ID 4;
TITLE "n4_PROMPT_USER";
POSITION 0.944445, 5.24444;
PROMPT;
NEWFILE;
IGNORE 0;
INTERPOLATION NEAREST;
ATHEMATIC;
DATATYPE UNSIGNED16;
DECLARE "Integer";
COMPRESSION UNCOMPRESSED;
COORDINATES MAP;
RECODE NO;
}
MATRIX {
ID 6;
TITLE "n6_Low_Pass";
POSITION 3.26667, 1.68889;
SIZE 5, 5;
DATATYPE SIGNED32;
BUILTIN LOWPASS;
VALUE 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1;
NORMALIZE NO;
CHILD 2;
}
TEXT {
ID 7;
TITLE "Repair Holes and Slivers using a Table of Values";
POSITION 2.67778, 0.344445;
FONT "new century schoolbook";
SIZE 18;
}
TEXT {
ID 8;
TITLE "5 x 5 filter";
POSITION 3.26667, 0.988889;
FONT "new century schoolbook";
SIZE 12;
}
TEXT {
ID 10;
TITLE "Value(s) to Replace";
POSITION 0.788889, 2.57778;
FONT "new century schoolbook";
SIZE 12;
}
TEXT {
ID 11;
TITLE "3 x 3 filter";
POSITION 3.52222, 4.66667;
FONT "new century schoolbook";
SIZE 12;
}
TEXT {
ID 13;
TITLE "Conditional statement to determine";
POSITION 3.8, 2.78889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 14;
TITLE "which filter is more appropriate. If a majority";
POSITION 4.06667, 2.96667;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 15;
TITLE "of the pixels are the \"Value(s) to Replace,\"";
POSITION 4.01111, 3.18889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 16;
TITLE "the 5 x 5 filter is used. Otherwise, ";
POSITION 3.8, 3.38889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 17;
TITLE "the 3 x 3 filter is used.";
POSITION 3.4, 3.58889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 18;
TITLE "Be sure to define the correct";
POSITION 1.03333, 6.23333;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 19;
TITLE "\"Data Type\" in the output file.";
POSITION 1.03333, 6.43333;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 20;
TITLE "Created in IMAGINE 8.4 - Developed by Paul Beaty";
POSITION 2.72222, 7.08889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 21;
TITLE "Center for Geographic Information Systems";
POSITION 2.72222, 7.47778;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 22;
TITLE "Georgia Institute of Technology - Atlanta Georgia, USA";
POSITION 2.82222, 7.65556;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 26;
TITLE "Both filters ignore the \"Value(s) to Replace\"";
POSITION 4.06667, 3.77778;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 27;
TITLE "when calculating the mean.";
POSITION 3.58889, 3.98889;
FONT "new century schoolbook";
SIZE 10;
}
TABLE {
ID 28;
TITLE "n28_Custom_Integer";
POSITION 0.744445, 3.21111;
SIZE 4;
DATATYPE SIGNED32;
VALUE 0, 10, 20, 30;
CHILD 2;
}
TEXT {
ID 29;
TITLE "Add and delete values";
POSITION 0.8, 4.08889;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 30;
TITLE "Integer or float?";
POSITION 0.777778, 4.27778;
FONT "new century schoolbook";
SIZE 10;
}
TEXT {
ID 31;
TITLE "Modified in IMAGINE 8.7 - Paul Beaty";
POSITION 2.71111, 7.27778;
FONT "new century schoolbook";
SIZE 10;
}

No comments: