Region_Grow kills IDL Workbench on Windows [message #82766] |
Fri, 18 January 2013 05:57 |
Brian Daniel
Messages: 80 Registered: July 2009
|
Member |
|
|
I ran across a strange behavior in calling Region_Grow.pro (and really when it was calling Label_Region) when there was a bug in my code. On Windows 7, 64-bit, IDL 8.2, the workbench and ENVI all close. No errors. No warnings. Just gone. On Mac OSX, it keeps running interminably (as it should), but I wasn't able to Pause or Stop the run at all. I had to close everything to restore. I was able to find my bug by setting stops and stepping into and over until things died.
My bug, for those who care:
I have an array that is a detection statistic for a target detection algorithm: score_img. I have a mask of where I don't want any detections (1's for allowable, 0's for not): mask. Both are arrays of the same size (NxM) -score_img is float, mask is byte. My code was applying the mask only after I thresholded the score_img. When I sent score_img to Region_Grow, it varied the threshold to hit hundreds of thousands of regions inside the mask. That's my bug. My fault. But it took waaay too long to find it given IDL and the workbench's behavior. My code is below.
; Apply the mask after thresholding the statistic.
detections = (score_img GT threshold) * mask
; label the detections
labeled = Label_Region(detections,/All_Neighbors,/ULONG)
; Count the number of detections, loop through each and grow the regions
hLabel = Histogram(labeled, Locations=targLabel, BinSize=1, Reverse_Indices=lab_ri)
indH = Where(hLabel[1:-1] GE 1, cntH) + 1 ; avoiding 0 label (background)
detections_grown = bytarr(N,M)
FOR ii=0, cntH-1 DO BEGIN
newROIpixels = Region_Grow(score_img, $
lab_ri[lab_ri[targLabel[indH[ii]]]:lab_ri[targLabel[indH[ii] ]+1]-1], $
STDDEV_MULTIPLIER=2)
detections_grown[newROIpixels] = targLabel[indH[ii]]
ENDFOR
For my case, IDL died when ii=34 for a given image situation. For those that read this far, thanks for the therapy.
-Brian
|
|
|