Created
January 25, 2013 14:01
-
-
Save robintw/4634668 to your computer and use it in GitHub Desktop.
Getis statistic code (IDL) (This is an extract of the code, so some variables aren't properly defined etc - but it should give you an idea of what I am doing.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Get the global mean | |
GlobMean = MEAN(WholeBand, /NAN) | |
; Get the global variance | |
GlobVariance = VARIANCE(WholeBand, /NAN) | |
; Get the number of values in the whole image | |
GlobNumber = (NumRows * NumCols - CountOfNAN) | |
; Converts a distance to the length of each side of the square | |
; Eg. A distance of 1 to a length of 3 | |
DimOfArray = (distance * 2) + 1 | |
NumOfElements = DimOfArray * DimOfArray | |
; Create the kernel for the summing CONVOL operation | |
Kernel = FLTARR(DimOfArray, DimOfArray) | |
Kernel = Kernel + 1 | |
; Create an image where each element is the sum of the elements within | |
; d around it | |
SummedImage = CONVOL(FLOAT(WholeBand), Kernel, /CENTER, /EDGE_TRUNCATE, /NAN) | |
; Create an image where each element is the result of the top fraction part | |
; of the getis formula | |
TopFraction = SummedImage - (FLOAT(NumOfElements) * GlobMean) | |
; Calculate the square root bit of the formula and then create a single variable | |
; with the bottom fraction part of the formula (this is constant for all pixels) | |
SquareRootAnswer = SQRT((FLOAT(NumOfElements) * (GlobNumber - NumOfElements))/(GlobNumber - 1)) | |
BottomFraction = SQRT(GlobVariance) * SquareRootAnswer | |
; Create an image with the getis values in it | |
Getis = FLOAT(TopFraction) / BottomFraction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment