"FILL" algorithm: given starting pixel in 2 or 3-d array, return array in which all pixels with value above threshold and connected to that pixel by a string of pixels above threshold, are set and all others unset. 1. go through map and set all points above threshold to 1, below to zero. value zero -> will never be set, value of 1 may be set, value of 2 has been set. 2. (iterative) first cycle: set value of the given pixel to 2, put this pixel in a list of newly set pixels. subsequent cycles: for each newly set pixel, check 7 or 26 neighbors (7 for 2-d, 26 for 3d). if value of neighbor is 1, change to 2 and add to new list of newly set pixels. After all have been checked, see if new list has any members. if so, replace old list w new list and do another cycle. nnew=0 do ii=1 nmembers do ---- j=1,3 pix(j)=list(ii,j) do ---- i=pix(1)-1, pix(1)+1 do ---- j=pix(2)-1, pix(2)+1 do ---- k=pix(3)-1, pix(3)+1 if map(i,k,j).eq.1) then (map(pix(1)+i,pix(2)+j,pix(3)+k).eq.1) nnew=nnew+1 nlist(nnew,1)=i nlist(nnew,2)=j nlist(nnew,3)=k continue if (nnew.eq.0) goto end nmembers=nnew do ---- i=1,nmembers do ---- j=1,3 list(i,j)=nlist(i,j) goto start