comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Can this be done using array operations instead?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Can this be done using array operations instead? [message #66104 is a reply to message #65921] Thu, 02 April 2009 12:43 Go to previous messageGo to previous message
robintw is currently offline  robintw
Messages: 37
Registered: March 2009
Member
Thank you everyone for your help. I've now managed to write a function
to do this with array functions. I've put the code below if anyone is
interested. I realised that all I really needed was the sum of the
values, and I could do all the rest by arithmetic operations on the
array itself.

However, the next part of this project will require using subarrays as
I will need to get the Standard Deviation of each 3x3 square. Is there
a way to do this?

Cheers,

Robin

Code Here:

; Creates a Getis image given a FID, the dimensions of the file, a
distance to use for the getis routine
; and a base window to send progress updates to
PRO CREATE_GETIS_IMAGE, file, dims, distance, report_base
; TODO: Get this to loop through bands
; Get the data for the first band of the file (ignores pos from
earlier)
WholeBand = ENVI_GET_DATA(fid=file, dims=dims, pos=0)

; Calculate the dimensions of WholeBand
SizeInfo = SIZE(WholeBand, /DIMENSIONS)
NumRows = SizeInfo[0]
NumCols = SizeInfo[1]

; Get the global mean
GlobMean = MEAN(WholeBand)

; Get the global variance
GlobVariance = VARIANCE(WholeBand)

; Get the number of values in the whole image
GlobNumber = NumRows * NumCols

DimOfArray = (distance * 2) + 1
Kernel = FLTARR(DimOfArray, DimOfArray)
Kernel = Kernel + 1
print, Kernel
SummedImage = CONVOL(FLOAT(WholeBand), Kernel, /CENTER, /EDGE_ZERO)

TopFraction = SummedImage - (FLOAT(9) * GlobMean)

SquareRootAnswer = SQRT((FLOAT(9) * (GlobNumber - 9))/(GlobNumber -
1))
BottomFraction = GlobVariance * SquareRootAnswer

Getis = FLOAT(TopFraction) / BottomFraction

ENVI_ENTER_DATA, Getis

print, "Program finished."
END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: simultaneous use of multiple font on a postscript file
Next Topic: Re: highlight text in text widget

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 10:01:34 PDT 2025

Total time taken to generate the page: 0.67486 seconds