;Find the bounding box, the smallest rectangle with sides parallel to the grid which ;circumscribes all the 'true' values in a 2D boolean array ; Input ; map - 2d array of booleans ; ; returns ; an array of 4 integers. First two are row and column of one corner of the box, ; second two are row and column of opposite corner of the box function findbbox,map,status=status w=where(map,n_map) status=0 if n_map eq 0 then begin status=-1 return,[-1,-1,-1,-1] end n=min(w) x=max(w) c1=(array_indices(map,n))[1] c2=(array_indices(map,x))[1] tmap=transpose(map) w=where(tmap) n=min(w) x=max(w) r1=(array_indices(tmap,n))[1] r2=(array_indices(tmap,x))[1] return,[r1,c1,r2,c2]; end