User's Guide

SMOOTH

Smooth image, replacing flagged pixels with neighboring values.

Function:

Replaces flagged (negative) pixels in an image with unflagged neighboring pixel class values. A pairwise weight table may be used to determine the precedence that adjacent pixel values have for replacing flagged pixels. If no pairwise weight table is specified, the default weight is used for all candidate classes.

Parameters:

IN
Input image. Single-band image containing INTEGER*2 or INTEGER*4 pixel data. Window options may be specified.

OUT
Output image. The output image is the same size as the input image specification. Output data type is determined based on the data type necessary to accommodate the class values in the output image.

DFLTWGHT
Default weight value. Used when the combination of flagged and replacement classes is not found in INLT.

INLT(--)
Input labeled table. Table containing class pairs and corresponding weight values to be used in determining which class values should replace the flagged pixels' class values in the input image. The first class in each row of the table is the flagged class value. The second class represents a neighboring class value that is a candidate for replacing the flagged class. The third entry is a number that represents the weighting that this particular candidate class should have when being considered as a potential replacement for the flagged pixel's class value.

CONNECT(EIGHT )
Candidate connectedness criteria.

  = FOUR:   Four-way connected.  Candidate classes must
	    be either vertically or horizontally
	    adjacent to the flagged pixel in order
	    to be considered valid candidates for
	    replacing the flagged pixel.  (They must
	    make contact along an edge.)
  = EIGHT:  Eight-way connected.  Candidate classes may
	    be vertically, horizontally, or diagonally
	    adjacent to the flagged class.

Examples:

  1. LAS> smooth in=landflag out=landsmooth dfltwght=20 inlt=landwght

    The image LANDFLAG is filtered, replacing the flagged pixels with adjacent pixel's class values. The class weights are read from LANDWGT labeled table. For those pairs of pixel values not found in the table, the default weight of 20 is applied.

  2. LAS> smooth in=landflag out=landsmooth dfltwght=1 connect=four

    The image LANDFLAG is filtered, replacing the flagged pixels with adjacent pixels' class values. Since no pairwise weight table is specified, all class values are weighted the same. Strict four-way connectedness critera will be enforced.

Description/Algorithm:

SMOOTH replaces flagged (negative) pixels in an image with unflagged neighboring pixel class values. The image input to SMOOTH will normally have been processed by FLAG to flag regions whose areas were smaller than those specified by area parameters. SMOOTH normally uses a pairwise weight table (see user note 2) to determine the precedence that adjacent pixel values have for replacing flagged pixels. If no pairwise weight table is specified, the default weight is used for all candidate classes.

SMOOTH reads the input image and creates two temporary images during processing before storing the final smoothed data in the output image. The temporary images serve as input and output images on successive passes through the data. The temporary images are deleted when processing has been completed.

The replacement of flagged pixels starts at the borders of the flagged regions and progresses inward with each successive pass through the data. The number of passes required to process the data will depend on the ratio of interior pixels to border pixels in flagged reqions. During each pass SMOOTH attempts to replace the pixels that make up the border of the flagged areas within the image. All unflagged (positive) and background (zero valued) pixels are simply transferred to the output image.

When attempting to replace a flagged pixel, SMOOTH looks at a 3 X 3 window around the flagged pixel to determine candidates for replacing the flagged pixel. All non-zero, positive pixels in this 3 X 3 window are considered to be candidate classes for replacing the flagged pixel. When the flagged pixel is located at the edge of the input image, the cells of the 3 X 3 window that extend over the edge of the image are filled with zeros. A weight factor is computed for each class that is considered to be a candidate for replacing the flagged pixel. The candidate class with the highest total weight factor will normally be used to replace the flagged pixel. The only exceptions are: 1) When more than one class ties for having the highest total weight factor, the class is picked at random from the tied candidate classes. 2) When the candidate class with the highest total weight factor makes contact with the flagged pixel exclusively through corner connections and strict four-way connectedness criteria are to be enforced, the candidate class with the next highest weight factor that contacts the flagged pixel along an edge is chosen. 3) When no non-zero weight factors are computed for the valid candidate classes, no replacement occurs.

The total weight factors for each of the candidate classes is computed based upon the following three criteria:

  1) The relative weighting that the candidate class should be 
     given when considering it as a replacement for the flagged 
     pixel's class.  

 	Weights are either obtained from the pairwise weight 
	table or they take on a default value.  The pairwise 
	weight table is searched first.  If a weight value 
     	is found in the table, that weight is used.  The user 
     	specified default weight is used for all other candidate
     	classes not found in the table.

  2) The position of the candidate class in relation to the 
     flagged pixel.

        The weights of the candidates that are located in the 
	corners of the 3 X 3 window are divided by a distance 
	factor (square root of 2) to compensate for the fact 
	that they are farther removed from the flagged pixel. 

  3) The number of occurrences of the candidate class in the 
     proximity of the flagged pixel. 

  	The weights for all candidates in the 3 X 3 window are 
	summed based on common class values.  Thus, a candidate 
	class with a lower individual weight factor (as 
	specified in the table) can take precedence over a 
	candidate class with a higher individual weight factor, 
	provided that the number of occurrences of the former 
	class in the 3 X 3 window is sufficient to cause the sum
	of the individual weights to exceed the total of the 
	weights for the latter. 

The following examples illustrates how the weight factors are computed and how the replacement class is selected.

	Flagged pixel in context:	4  7  4	
					3 -2  3
					4 -5  6	

	Pairwise weight table:	FCLASS 	CCLASS 	WEIGHT
				   2       3      10
				   2       4      10
				   2	   5      20
				   2   	   6	  25

	Default weight:   	15

	Connectedness criteria:	Eight-way 


	When looking at the flagged pixel ("-2") above, we see 
	that there are four candidate classes ("3" "4" "6" "7") 
	for replacing the flagged pixel.  Class "5" is not a 
	candidate, since it too is flagged. In order to choose 
	between candidate classes, we compute their total weight 
	factors as follows:

		Candidate class "3" occurs in the window twice, 
		and neither occurrence is in a corner of the 
		window.  Thus, the total weight factor for class 
		"3" is simply two times the weight factor given 
		for candidate class "3" replacing flagged class 
		"2" (weight = 10 from the table).  
 
		Total weight for class "3" = 2 * 10     
					   = 20

		Candidate class "4" occurs in the window three 
		times, and all three times it is in a corner of 
		the window.  These corner weights must be 
		divided by a distance factor (sqrt 2) before 
		adding them into the total weight factor.  The 
		unadjusted weight factor given in the table for
	    	candidate class "4" replacing flagged class "2" 
		is 10.  Thus, the total weight factor for class 
		"4" is computed as follows:

		Total weight for class "4" = 3 * (10 / sqrt(2))
					   = 21.21 

		Candidate class "6" occurs in the window only 
		once, and it occurs in the corner of the window.  
	 	Thus the weight factor given in the table (25) 
		is divided by the distance factor (sqrt 2).

		Total weight for class "6" = 25 / sqrt(2)
					   = 17.68 

		Candidate class "7" occurs in the window only 
		once, and it is not in a corner.  Since there is 
		no entry in the weight table for candidate class 
		"7" replacing class "2" the default weight is 
		used.

		Total weight for class "7" = 15

	Since the total weight factor for class 4 is largest, 
	the flagged pixel ("-2") will be replaced by candidate 
	class "4".

	Note: If strict four-way connectedness criteria had been 
	specified, the replacement class would have been class 
	"3" instead of class "4".

Nonfatal Error Messages:

  1. [smooth-flag] Output image still contains flagged pixels

    There remain some flagged pixels in the output image that could not be replaced by any of their neighboring pixels. Modifications to the pairwise weight table may be necessary to resolve these anomalies.

  2. [smooth-weights] Class pair <XXXX> <XXXX> occurs more than once in pairwise weight table

    The pairwise weight table contains duplicate entries. The sorting and searching of the table cannot guarantee which of the entries will be used in processing. Therefore, you should eliminate all duplicates in the table and reprocess.

Fatal Error Messages:

  1. [smooth-alloc] Error allocating dynamic memory

    A system error occurred when trying to allocate dynamic memory. This may be due to the work load on the system. Please try again when the system is not as busy.

  2. [smooth-dtype] Image <XXXX> not of type integer*2, or integer*4

    The image input to SMOOTH is assumed to be a single band image created by FLAG that has one of the data types listed above. Please enter an appropriate image.

  3. [smooth-fatal] Fatal error encountered

    A fatal error was encountered during processing. Processing was terminated. The error message that is displayed immediately preceding this message is the specific error that was encountered.

  4. [smooth-getfield] Error getting field pointer from pairwise weight labeled table

    The pairwise weight labeled table has been corrupted. Please regenerate the labeled table.

  5. [smooth-nbands] Only single band input allowed

    The image input to SMOOTH is assumed to be a single band image created by FLAG. Please enter an appropriate image.

  6. [smooth-odtype] Could not write ODTYPE to PARBLK

    Error occurred when passing output data type back to pdf. Call system manager.

  7. [smooth-parblk] Could not pass PARBLK back to PDF

    Error occurred when passing parameter block back to pdf. Call system manager.

  8. [smooth-tempout] Could not write TEMPOUT to PARBLK

    Error occurred when passing temporary image name back to pdf. Call system manager.

User Notes:

  1. Other functions used in conjunction with SMOOTH to perform area filtering on classified images are NOMFIL, REGLABEL, and FLAG.

  2. The labeled table containing pairs of flagged classes along with candidate classes and their relative weight factors (INLT parameter) should be modeled after the following example:

    	;
    	"PAIRWGTS","Pairwise weights file";
    	"FCLASS","I4","Flagged class",1,1
    	"CCLASS","I4","Candidate class",1,1
    	"WEIGHT","I4","Weighting factor",1,1;
    	1,2,10;
    	1,4,20;
    	2,3,15;
    	3,4,0;
    
    
    Simply enter as many pairs of classes and associated weight values as necessary--one pair of classes and a weight value on each line as shown in the example. The field names "FCLASS", "CCLASS", and "WEIGHT" and their defined types are critical to the successful use of the table.