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

Home » Public Forums » archive » IDL & ENVI error: WIDGET_CONTROL: Invalid widget identifier: 17
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
IDL & ENVI error: WIDGET_CONTROL: Invalid widget identifier: 17 [message #65887] Fri, 27 March 2009 09:10
robintw is currently offline  robintw
Messages: 37
Registered: March 2009
Member
Hi,

I'm very much an IDL newbie, but I have experience in other
programming languages. I'm trying to use IDL with ENVI to do some
image processing.

My code is below, and is relatively simple - just calculating some
statistics for the image. However, every so often when I run it I get
the error "WIDGET_CONTROL: Invalid widget identifier: 17.". If I close
the IDL/ENVI Workbench and reload it then the error goes away and I
can run it fine again a few times, until the error starts coming up
again.

I'm not doing anything with widgets explicitly (although I think the
ENVI_SELECT_FILE function uses widgets) so I can't think what I'm
doing. I use the "envi" command at the beginning to load the envi
environment, is there a command I need to run at the end to close the
envi environment and release all the files and widgets etc. If so,
what is this command - I can't seem to find it anywhere!

My code is below:

PRO GetImage
envi
; Use the ENVI dialog box to select a file
ENVI_SELECT, fid=file,dims=dims,pos=pos

; 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)

;Set Distance to be considered
Distance = 3

; Therefore the area to go each side is (d-1)/2
DistanceEachSide = (Distance - 1)/2

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

FOR Rows = 3, NumRows DO BEGIN
FOR Cols = 3, NumCols DO BEGIN
; Make sure RowBottom doesn't go below 0
RowBottom = Rows - DistanceEachSide
IF RowBottom LT 0 THEN RowBottom = 0

; Make sure RowTop doesn't go above NumRows
RowTop = Rows + DistanceEachSide
IF RowTop GE NumRows THEN RowTop = NumRows - 1

ColBottom = Cols - DistanceEachSide
IF ColBottom LT 0 THEN ColBottom = 0

ColTop = Cols + DistanceEachSide
IF ColTop GE NumCols THEN ColTop = (NumCols - 1)

print, RowTop
print, ColTop

AOI = WholeBand[RowBottom:RowTop, ColBottom:ColTop]
;print, AOI
;print, "---"
ENDFOR
ENDFOR


; --- Calculate variable values for the WholeBand

; Get the global mean
GlobMean = MEAN(WholeBand)

; Get the global variance
GlobVariance = VARIANCE(WholeBand)

; Get the number of values in the whole image
SizeInfo = SIZE(WholeBand, /DIMENSIONS)
GlobNumber = SizeInfo[0] * SizeInfo[1]

; --- Calculate variable values for the AOI

; Get the Sum of the values in the AOI
AOISum = TOTAL(aoi)

; Get number of values in AOI
SizeInfo = SIZE(aoi, /DIMENSIONS)
AOINumber = SizeInfo[0] * SizeInfo[1]

; --- Start Calculating Getis Statistic

; Calculate the top of the fraction
TopFraction = AOISum - (AOINumber * GlobMean)

; Calculate the square root
SquareRootAnswer = (AOINumber * (GlobNumber - AOINumber))/(GlobNumber
- 1)

; Calculate bottom of fraction
BottomFraction = GlobVariance * SquareRootAnswer

; Calculate Getis Statistic
Getis = TopFraction / BottomFraction

print, Getis

END

Thanks,

Robin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: FORMAT question
Next Topic: Re: IDL - EXP fitting function

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

Current Time: Wed Oct 08 13:52:22 PDT 2025

Total time taken to generate the page: 0.00481 seconds